From e0af668f6c4729b5fcb14c9bba764d69f7b8cca8 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 16 Aug 2022 15:35:57 +0200 Subject: [PATCH] [dxvk] Use DxvkBindingLayoutObjects for set lookup directly Avoids pointer dereferencing on a really hot code path. This is also safe since there's a 1:1 mapping between the VkPipelineLayout and the given ovbject type. --- src/dxvk/dxvk_descriptor.cpp | 7 +++---- src/dxvk/dxvk_descriptor.h | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/dxvk/dxvk_descriptor.cpp b/src/dxvk/dxvk_descriptor.cpp index ae155c26..13cc93a6 100644 --- a/src/dxvk/dxvk_descriptor.cpp +++ b/src/dxvk/dxvk_descriptor.cpp @@ -161,14 +161,13 @@ namespace dxvk { DxvkDescriptorSetMap* DxvkDescriptorPool::getSetMap( const DxvkBindingLayoutObjects* layout) { - auto pair = m_setMaps.find(layout->getPipelineLayout(false)); - if (likely(pair != m_setMaps.end())) { + auto pair = m_setMaps.find(layout); + if (likely(pair != m_setMaps.end())) return &pair->second; - } auto iter = m_setMaps.emplace( std::piecewise_construct, - std::tuple(layout->getPipelineLayout(false)), + std::tuple(layout), std::tuple()); for (uint32_t i = 0; i < DxvkDescriptorSets::SetCount; i++) { diff --git a/src/dxvk/dxvk_descriptor.h b/src/dxvk/dxvk_descriptor.h index 7c874f65..876aae04 100644 --- a/src/dxvk/dxvk_descriptor.h +++ b/src/dxvk/dxvk_descriptor.h @@ -136,10 +136,19 @@ namespace dxvk { DxvkDescriptorManager* m_manager; DxvkContextType m_contextType; - std::vector m_descriptorPools; - std::unordered_map m_setLists; - std::unordered_map m_setMaps; - std::pair m_cachedEntry; + std::vector m_descriptorPools; + + std::unordered_map< + VkDescriptorSetLayout, + DxvkDescriptorSetList> m_setLists; + + std::unordered_map< + const DxvkBindingLayoutObjects*, + DxvkDescriptorSetMap> m_setMaps; + + std::pair< + const DxvkBindingLayoutObjects*, + DxvkDescriptorSetMap*> m_cachedEntry; uint32_t m_setsAllocated = 0; uint32_t m_setsUsed = 0;