Allow aliasing between different descriptor types silently

* Also make the error about duplicate keys less severe - this can happen in
  practice as different views boil down to the same descriptor bytes and
  applications don't use only one view.
This commit is contained in:
baldurk
2025-09-03 17:17:26 +01:00
parent 5eaac6c03f
commit c25161a759
3 changed files with 41 additions and 5 deletions
+14 -3
View File
@@ -99,9 +99,17 @@ struct rdcbytetrie
return true;
// used only so the tests can EXPECT_ERROR()
RDResult err;
SET_ERROR_RESULT(err, ResultCode::InternalError, "Duplicate key with differing value located");
(void)err;
if(m_StrictErrorChecking)
{
RDResult err;
SET_ERROR_RESULT(err, ResultCode::InternalError,
"Duplicate key with differing value located");
(void)err;
}
else
{
RDCWARN("Duplicate key with differing value located");
}
return false;
}
@@ -110,6 +118,8 @@ struct rdcbytetrie
return true;
}
void SetStrictErrorChecking(bool check) { m_StrictErrorChecking = check; }
private:
///////////////////////////////
// nodes
@@ -615,4 +625,5 @@ private:
///////////////////////////////
NodeOrLeaf *m_Root = NULL;
bool m_StrictErrorChecking = false;
};
+25 -2
View File
@@ -123,7 +123,7 @@ bool DescriptorTrieNode::operator==(const DescriptorTrieNode &o) const
return true;
}
if(type != o.type || resource != o.resource || sampler != o.sampler || offset != o.offset)
if(resource != o.resource || sampler != o.sampler || offset != o.offset)
return false;
// deliberately allow imageLayout differences to be considered equal still - some drivers are
@@ -132,7 +132,30 @@ bool DescriptorTrieNode::operator==(const DescriptorTrieNode &o) const
if((range & rangeToleranceMask) != (o.range & rangeToleranceMask))
return false;
return true;
if(type == o.type)
return true;
// allow similar types alias based on usage if they're otherwise identical since not all descriptors
// vary this way and the type is provided on lookup so this won't cause any problems in practice
DescriptorSlotType aType = RDCMIN(type, o.type);
DescriptorSlotType bType = RDCMAX(type, o.type);
if(aType == DescriptorSlotType::SampledImage && bType == DescriptorSlotType::StorageImage)
return true;
if(aType == DescriptorSlotType::SampledImage && bType == DescriptorSlotType::InputAttachment)
return true;
if(aType == DescriptorSlotType::StorageImage && bType == DescriptorSlotType::InputAttachment)
return true;
if(aType == DescriptorSlotType::UniformBuffer && bType == DescriptorSlotType::StorageBuffer)
return true;
if(aType == DescriptorSlotType::UniformTexelBuffer &&
bType == DescriptorSlotType::StorageTexelBuffer)
return true;
// could maybe allow all buffer types to alias but we'll stick to this for now
return false;
}
uint64_t DescriptorTrieNode::rangeToleranceMask = ~0ULL;
+2
View File
@@ -2585,6 +2585,8 @@ TEST_CASE("Test rdcbytetrie type", "[basictypes][rdcbytetrie]")
{
rdcbytetrie<TrieValue> trie;
trie.SetStrictErrorChecking(true);
SECTION("Simple lookups")
{
KV keyVals[] = {