Recognise NULL descriptors in fast lookup

* This prevents us falling back to the full fallback in most NULL descriptor
  cases.
This commit is contained in:
baldurk
2025-07-30 22:10:26 +01:00
parent 316a9bafd7
commit 203a973760
2 changed files with 33 additions and 0 deletions
+31
View File
@@ -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<VkImageLayout> 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)
+2
View File
@@ -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<DescriptorTrieNode> fallback;