summaryrefslogtreecommitdiff
path: root/tests/language-feature
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-12 13:19:35 -0800
committerGitHub <noreply@github.com>2024-02-12 13:19:35 -0800
commit0c15582efcec6c7b163ae3a20c04e1aee958d24a (patch)
treedcc3ed41eb993cf5202cc4d995383cd14cbba9f7 /tests/language-feature
parent4f7d1f44a4b2a5eab2e2dec1edf3a156da78aae3 (diff)
Fix lowering of static consts in a generic function. (#3573)
* Fix lowering of static consts in a generic function. * Fix. * Fix. * Fix lowering of shading rate builtin.
Diffstat (limited to 'tests/language-feature')
-rw-r--r--tests/language-feature/generics/generic-static-const.slang41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/language-feature/generics/generic-static-const.slang b/tests/language-feature/generics/generic-static-const.slang
new file mode 100644
index 000000000..57c82a687
--- /dev/null
+++ b/tests/language-feature/generics/generic-static-const.slang
@@ -0,0 +1,41 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d12 -shaderobj -output-using-type -use-dxil
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type
+
+//TEST_INPUT:set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4)
+RWStructuredBuffer<uint> outputBuffer;
+
+interface ITestB
+{
+ static void eval<let N : uint>(uint val[N], out uint res[N]);
+};
+
+struct TestB : ITestB
+{
+ static void eval<let N : uint>(uint val[N], out uint res[N])
+ {
+ static const uint scale = 3 * N;
+ for (uint i = 0; i < N; i++)
+ res[i] = scale * val[i];
+ }
+};
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 threadID: SV_DispatchThreadID)
+{
+ const uint i = threadID.x;
+
+ uint val[4] = { i, i + 1, i + 2, i + 3 };
+ uint res[4];
+
+ TestB test;
+ test.eval<4>(val, res);
+
+ // CHECK: 0
+ outputBuffer[0] = res[0];
+ // CHECK: 12
+ outputBuffer[1] = res[1];
+ // CHECK: 24
+ outputBuffer[2] = res[2];
+ // CHECK: 36
+ outputBuffer[3] = res[3];
+} \ No newline at end of file