summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDarren Wihandi <65404740+fairywreath@users.noreply.github.com>2025-05-16 15:01:24 -0400
committerGitHub <noreply@github.com>2025-05-16 12:01:24 -0700
commitda951e06e7eb8ad1b9c91d6176be8165ea4f2b45 (patch)
tree84df8551021ad8806531fc2ed59058f65fbfa256 /tests
parent0244c96d637f47fa264d441a82d3dca78889373b (diff)
Address structured buffer `GetDimensions` issues for WGSL, GLSL and SPIRV (#7010)
* Fix structured buffer get dimensions * Further fixes and added tests * Remove unnecessary include * Fix test issues * attempt to fix wgpu crash * test remove half usage in test * attempt to fix WGPU test issue * Another attempt to fix WGSL test - make test similar to the existing GetDimensions test --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/cross-compile/get-dimensions-stride-struct.slang31
-rw-r--r--tests/cross-compile/get-dimensions-stride.slang50
2 files changed, 81 insertions, 0 deletions
diff --git a/tests/cross-compile/get-dimensions-stride-struct.slang b/tests/cross-compile/get-dimensions-stride-struct.slang
new file mode 100644
index 000000000..3af888589
--- /dev/null
+++ b/tests/cross-compile/get-dimensions-stride-struct.slang
@@ -0,0 +1,31 @@
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -emit-spirv-directly
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -emit-spirv-via-glsl
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-d3d12 -compute -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-d3d11 -compute -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-wgpu -compute -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+struct MS
+{
+ uint a;
+ uint b;
+}
+
+//TEST_INPUT:ubuffer(data=[7 2 9 53], stride=8):name buffer0
+RWStructuredBuffer<MS> buffer0;
+
+[shader("compute")]
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = int(dispatchThreadID.x);
+ uint count = 0;
+ uint stride = 0;
+
+ // CHECK: 8
+ buffer0.GetDimensions(count, stride);
+
+ outputBuffer[index] = int(stride);
+}
diff --git a/tests/cross-compile/get-dimensions-stride.slang b/tests/cross-compile/get-dimensions-stride.slang
new file mode 100644
index 000000000..4aa57a325
--- /dev/null
+++ b/tests/cross-compile/get-dimensions-stride.slang
@@ -0,0 +1,50 @@
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-d3d12 -compute -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-wgpu -compute -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+//TEST_INPUT:ubuffer(data=[7 2 9 53], stride=4):name buffer0
+RWStructuredBuffer<int> buffer0;
+
+//TEST_INPUT:ubuffer(data=[23 2], stride=4):name buffer1
+RWStructuredBuffer<int> buffer1;
+
+//TEST_INPUT:ubuffer(data=[-10 17 9 4 2 0], stride=4):name buffer2
+RWStructuredBuffer<float> buffer2;
+
+//TEST_INPUT:ubuffer(data=[-10 17 9 4 2 0], stride=4):name buffer3
+RWStructuredBuffer<float> buffer3;
+
+[shader("compute")]
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = int(dispatchThreadID.x);
+ uint count = 0;
+ uint stride = 0;
+
+ if (index == 0)
+ {
+ // CHECK: 4
+ buffer0.GetDimensions(count, stride);
+ }
+ else if (index == 1)
+ {
+ // CHECK: 4
+ buffer1.GetDimensions(count, stride);
+ }
+ else if (index == 2)
+ {
+ // CHECK: 4
+ buffer2.GetDimensions(count, stride);
+ }
+ else if (index == 3)
+ {
+ // CHECK: 4
+ buffer3.GetDimensions(count, stride);
+ }
+
+ outputBuffer[index] = int(stride);
+}