summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2025-07-01 23:36:02 +0800
committerGitHub <noreply@github.com>2025-07-01 23:36:02 +0800
commitc94ca1692e101df87215232e87fa7edadc1a7b05 (patch)
treed84c5b27af4d88cd5bdd71358bc2434e8f47a1ce /tests
parentd50c3f34a2eda5bf5e278c78d32cc9923fd83b82 (diff)
Allow Link time constant array length sizing, warn on unsupported functionality (#7067)
* Add link time array layout test * Add link time constant array size compilation test * Link time constant array size test * Allow getting link time array size Closes https://github.com/shader-slang/slang/issues/6753 * format * Switch to SIMPLE test and check output * Implement without binary api changes * diagnose on link time constant sized array * fix test --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/link-time-constant-array-size-lib.slang1
-rw-r--r--tests/bugs/link-time-constant-array-size-main.slang22
-rw-r--r--tests/library/ambiguous-extern-export-entry.slang.expected17
3 files changed, 40 insertions, 0 deletions
diff --git a/tests/bugs/link-time-constant-array-size-lib.slang b/tests/bugs/link-time-constant-array-size-lib.slang
new file mode 100644
index 000000000..cc83c30fa
--- /dev/null
+++ b/tests/bugs/link-time-constant-array-size-lib.slang
@@ -0,0 +1 @@
+export static const int N = 1597463007;
diff --git a/tests/bugs/link-time-constant-array-size-main.slang b/tests/bugs/link-time-constant-array-size-main.slang
new file mode 100644
index 000000000..da58decaf
--- /dev/null
+++ b/tests/bugs/link-time-constant-array-size-main.slang
@@ -0,0 +1,22 @@
+//TEST:COMPILE: tests/bugs/link-time-constant-array-size-lib.slang -o tests/bugs/link-time-constant-array-size-lib.slang-module
+//TEST:COMPILE: tests/bugs/link-time-constant-array-size-main.slang -o tests/bugs/link-time-constant-array-size-main.slang-module
+//TEST:SIMPLE(filecheck=SPIRV): -r tests/bugs/link-time-constant-array-size-main.slang-module -r tests/bugs/link-time-constant-array-size-lib.slang-module -target spirv -o out.spv -stage compute -entry computeMain
+
+extern static const int N;
+
+// SPIRV: ([[# @LINE+1]]): warning 31000
+struct S { int xs[N]; }
+
+RWStructuredBuffer<S> b;
+
+ParameterBlock<S> p;
+
+[numthreads(1, 1, 1)]
+void computeMain()
+{
+ // check that we multiply by our special number
+ // SPIRV: [[fisqr:%[a-zA-Z0-9_]+]] = OpConstant %int 1597463007
+ // SPIRV: {{%[0-9]+}} = OpIMul %int {{%[0-9]+}} [[fisqr]]
+ for(int i = 0; i < N; ++i)
+ b[0].xs[i] = p.xs[i] * N;
+}
diff --git a/tests/library/ambiguous-extern-export-entry.slang.expected b/tests/library/ambiguous-extern-export-entry.slang.expected
new file mode 100644
index 000000000..4ee9ac6c5
--- /dev/null
+++ b/tests/library/ambiguous-extern-export-entry.slang.expected
@@ -0,0 +1,17 @@
+result code = 0
+standard error = {
+tests/library/ambiguous-extern-export-lib1.slang(4): warning 31000: Link-time constant sized arrays are a work in progress feature, some aspects of the reflection API may not work
+public extern static const int[call_data_len] call_group_vector;
+ ^~~~~~~~~~~~~~~~~
+tests/library/ambiguous-extern-export-lib1.slang(5): warning 31000: Link-time constant sized arrays are a work in progress feature, some aspects of the reflection API may not work
+public static int[call_data_len] call_id_1 = {};
+ ^~~~~~~~~
+tests/library/ambiguous-extern-export-lib2.slang(5): warning 31000: Link-time constant sized arrays are a work in progress feature, some aspects of the reflection API may not work
+public extern static const int[call_data_len] call_group_vector;
+ ^~~~~~~~~~~~~~~~~
+tests/library/ambiguous-extern-export-lib2.slang(7): warning 31000: Link-time constant sized arrays are a work in progress feature, some aspects of the reflection API may not work
+public static int[call_data_len] call_id_2 = {};
+ ^~~~~~~~~
+}
+standard output = {
+}