From 203a973760687ae49308e5b68c422f4e041e2cd0 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 10 Jul 2025 17:26:23 +0100 Subject: [PATCH] Recognise NULL descriptors in fast lookup * This prevents us falling back to the full fallback in most NULL descriptor cases. --- renderdoc/driver/vulkan/vk_core.cpp | 31 +++++++++++++++++++++++++++++ renderdoc/driver/vulkan/vk_core.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index f3bfe2787..65ac03bf6 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -6206,7 +6206,19 @@ void WrappedVulkan::LookupDescriptor(byte *descriptorBytes, size_t descriptorSiz // exit silently, may be unknown descriptor format which would spam if(view == ResourceId()) + { + // check if this is a NULL descriptor, in which case we've identified correctly! + // only works if we don't need to care about the layout + if(m_IgnoreLayoutForDescriptors && + m_DescriptorLookup.nullPatterns[(uint32_t)convert(info.type)] == + bytebuf(descriptorBytes, descriptorSize)) + { + data = {}; + data.SetImageSampler(info.type, ResourceId(), ResourceId(), VK_IMAGE_LAYOUT_GENERAL); + return; + } break; + } rdcarray layouts; @@ -6267,6 +6279,20 @@ void WrappedVulkan::LookupDescriptor(byte *descriptorBytes, size_t descriptorSiz if(address == 0) { // exit silently, may be unknown descriptor format which would spam + // check if this is a NULL descriptor, in which case we've identified correctly! + // can't work for texel buffers that may have a format encoded + if(type != DescriptorType::TypedBuffer && type != DescriptorType::ReadWriteTypedBuffer && + m_DescriptorLookup.nullPatterns[(uint32_t)convert(info.type)] == + bytebuf(descriptorBytes, descriptorSize)) + { + data = {}; + if(type == DescriptorType::AccelerationStructure) + data.SetAccelerationStructure(VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, + VK_NULL_HANDLE); + else + data.SetBuffer(info.type, ResourceId(), 0, 0, VK_FORMAT_UNDEFINED); + return; + } break; } else @@ -6755,6 +6781,11 @@ void WrappedVulkan::RegisterDescriptor(const bytebuf &key, const DescriptorSetSl { m_DescriptorLookup.fallback.insert(key, data); + // only register NULL patterns for non-sampler types + if(data.type != DescriptorSlotType::Sampler && + data.type != DescriptorSlotType::CombinedImageSampler && data.resource == ResourceId()) + m_DescriptorLookup.nullPatterns[(uint32_t)data.type] = key; + // store unique texel buffer formats used, expecting this to be small and it will help descriptor lookups if(data.type == DescriptorSlotType::UniformTexelBuffer || data.type == DescriptorSlotType::StorageTexelBuffer) diff --git a/renderdoc/driver/vulkan/vk_core.h b/renderdoc/driver/vulkan/vk_core.h index 7306fbe2f..d16ce197f 100644 --- a/renderdoc/driver/vulkan/vk_core.h +++ b/renderdoc/driver/vulkan/vk_core.h @@ -494,6 +494,8 @@ private: uint32_t combinedSamplerOffset = 0; + bytebuf nullPatterns[size_t(DescriptorSlotType::Count)]; + // overall lookup of all descriptors by bytes, fallback in case any others don't work - we // expect this to always hit rdcbytetrie fallback;