[llvm] [DirectX] Fix resource binding analysis incorrectly removing duplicates (PR #152253)
Helena Kotas via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 7 11:13:11 PDT 2025
================
@@ -273,3 +273,21 @@ TEST(HLSLBindingTest, TestFindAvailable) {
// In an empty space we find the slot at the beginning.
EXPECT_THAT(V, HasSpecificValue(0u));
}
+
+// Test that add duplicate bindings are correctly de-duplicated
+TEST(HLSLBindingTest, TestNoOverlapWithDuplicates) {
+ hlsl::BindingInfoBuilder Builder;
+
+ // We add the same binding three times, and just use `nullptr` for the cookie
+ // so that they should all be uniqued away.
+ Builder.trackBinding(ResourceClass::SRV, /*Space=*/0, /*LowerBound=*/5,
+ /*UpperBound=*/5, /*Cookie=*/nullptr);
+ Builder.trackBinding(ResourceClass::SRV, /*Space=*/0, /*LowerBound=*/5,
+ /*UpperBound=*/5, /*Cookie=*/nullptr);
+ Builder.trackBinding(ResourceClass::SRV, /*Space=*/0, /*LowerBound=*/5,
+ /*UpperBound=*/5, /*Cookie=*/nullptr);
+ bool HasOverlap;
+ hlsl::BindingInfo Info = Builder.calculateBindingInfo(HasOverlap);
----------------
hekota wrote:
There is currently no way to check that - the `BindingInfoBuilder` does not expose the `Bindings` or their count. The only way to really check that there are duplicates that were not removed is by using the `HasOverlap`.
https://github.com/llvm/llvm-project/pull/152253
More information about the llvm-commits
mailing list