summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-04-10 11:18:58 -0700
committerGitHub <noreply@github.com>2024-04-10 11:18:58 -0700
commit33b4fa725f6410eee5013de465c14a4cb523b057 (patch)
tree6a20231d9585b5c8261cbe1edc8d168c3bdce6be
parent42764b76bb788c3859031bda780d63cef4c783e0 (diff)
Fix typelayout for append/consume structured buffers. (#3924)
-rw-r--r--source/slang/slang-type-layout.cpp6
-rw-r--r--tests/hlsl/append-structured-buffer.slang6
2 files changed, 7 insertions, 5 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index 195e14d79..e791efadb 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -2843,14 +2843,10 @@ createStructuredBufferWithCounterTypeLayout(
for(auto& typeResourceInfo : typeLayout->resourceInfos)
{
- const auto counterResourceInfo
+ auto counterResourceInfo
= counterVarLayout->findOrAddResourceInfo(typeResourceInfo.kind);
- const auto counterTypeResourceInfo
- = counterVarLayout->getTypeLayout()->FindResourceInfo(typeResourceInfo.kind);
// We expect this index to be 1
counterResourceInfo->index = typeResourceInfo.count.getFiniteValue();
- // likewise
- typeResourceInfo.count += counterTypeResourceInfo->count;
}
typeLayout->counterVarLayout = counterVarLayout;
diff --git a/tests/hlsl/append-structured-buffer.slang b/tests/hlsl/append-structured-buffer.slang
index 5ec7f844a..8886a97e8 100644
--- a/tests/hlsl/append-structured-buffer.slang
+++ b/tests/hlsl/append-structured-buffer.slang
@@ -2,6 +2,8 @@
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type -emit-spirv-directly
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly
+
// To check that our counter-initialization works correctly, set the initial
// counter to 1 instead of 0
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4, counter=1):out,name=outputBuffer
@@ -10,6 +12,10 @@ AppendStructuredBuffer<int> outputBuffer;
//TEST_INPUT:set inBuffer = ubuffer(data=[1 2 3 4], stride=4)
RWStructuredBuffer<int> inBuffer;
+// Make sure the bindings are correct. outputBuffer should take two slots, and inBuffer
+// should be at binding 2.
+// CHECK: OpDecorate %inBuffer Binding 2
+
[numthreads(4, 1, 1)]
void computeMain(uint i : SV_GroupIndex)
{