Add descriptor type descriptor uniqueness key.

Avoids problem when storage image and sampled image are extracted from
the same view object.
This commit is contained in:
Hans-Kristian Arntzen
2025-08-30 16:32:01 +02:00
committed by Baldur Karlsson
parent 6f0cbfa242
commit d64eeba25c
2 changed files with 13 additions and 9 deletions
+8 -5
View File
@@ -1028,23 +1028,25 @@ DECLARE_REFLECTION_STRUCT(AspectSparseTable);
struct DescriptorUniquenessKey
{
DescriptorUniquenessKey(VkImageLayout layout)
: layout(layout), offset(0), size(0), fmt(VK_FORMAT_UNDEFINED)
DescriptorUniquenessKey(VkImageLayout layout, VkDescriptorType type)
: layout(layout), offset(0), size(0), fmt(VK_FORMAT_UNDEFINED), type(type)
{
}
DescriptorUniquenessKey(uint64_t offset, uint64_t size, VkFormat fmt)
: layout(VK_IMAGE_LAYOUT_UNDEFINED), offset(offset), size(size), fmt(fmt)
DescriptorUniquenessKey(uint64_t offset, uint64_t size, VkFormat fmt, VkDescriptorType type)
: layout(VK_IMAGE_LAYOUT_UNDEFINED), offset(offset), size(size), fmt(fmt), type(type)
{
}
bool operator==(const DescriptorUniquenessKey &key) const
{
return layout == key.layout && offset == key.offset && size == key.size && fmt == key.fmt;
return layout == key.layout && offset == key.offset && size == key.size && fmt == key.fmt &&
type == key.type;
}
VkImageLayout layout;
uint64_t offset, size;
VkFormat fmt;
VkDescriptorType type;
};
namespace std
@@ -1058,6 +1060,7 @@ struct hash<DescriptorUniquenessKey>
hash ^= std::hash<uint64_t>()(key.offset) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
hash ^= std::hash<uint64_t>()(key.size) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
hash ^= std::hash<uint32_t>()(key.fmt) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
hash ^= std::hash<uint32_t>()(key.type) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
return hash;
}
};
@@ -3452,9 +3452,9 @@ void WrappedVulkan::vkGetDescriptorEXT(VkDevice device, const VkDescriptorGetInf
dstRecord = GetRecord(pDescriptorInfo->data.pSampledImage->imageView);
DescriptorUniquenessKey descKey(
m_IgnoreLayoutForDescriptors
? VK_IMAGE_LAYOUT_UNDEFINED
: pDescriptorInfo->data.pCombinedImageSampler->imageLayout);
m_IgnoreLayoutForDescriptors ? VK_IMAGE_LAYOUT_UNDEFINED
: pDescriptorInfo->data.pCombinedImageSampler->imageLayout,
pDescriptorInfo->type);
// this is internally locked
if(!dstRecord->resInfo->AddDescriptor(descKey))
@@ -3523,7 +3523,8 @@ void WrappedVulkan::vkGetDescriptorEXT(VkDevice device, const VkDescriptorGetInf
dstRecord = GetResourceManager()->GetResourceRecord(id);
DescriptorUniquenessKey descKey(offs, pDescriptorInfo->data.pUniformBuffer->range, fmt);
DescriptorUniquenessKey descKey(offs, pDescriptorInfo->data.pUniformBuffer->range, fmt,
pDescriptorInfo->type);
// this is internally locked
if(!dstRecord->resInfo->AddDescriptor(descKey))