summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-08-01 10:55:48 -0700
committerGitHub <noreply@github.com>2024-08-01 10:55:48 -0700
commit32b843215b2e80c23c1fbcf02150c52a6304a447 (patch)
tree5892ef28f2e603781af4c6dde5b2a1dc1112c125 /tests
parent4c6b0a2831a7edd1419bd0b2e6edd089080e07be (diff)
Allow implicit 'uniform' entrypoint parameters. (#4765)
* Allow impliocit 'uniform' entrypoint parameters. * Fix. * Fix. * Fix. * Fix.
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/invalid-entrypoint-param.slang17
-rw-r--r--tests/language-feature/shader-params/entry-point-uniform-params-implicit.slang42
-rw-r--r--tests/reflection/attribute.slang.expected6
3 files changed, 44 insertions, 21 deletions
diff --git a/tests/bugs/invalid-entrypoint-param.slang b/tests/bugs/invalid-entrypoint-param.slang
deleted file mode 100644
index bafb0fb88..000000000
--- a/tests/bugs/invalid-entrypoint-param.slang
+++ /dev/null
@@ -1,17 +0,0 @@
-//TEST:SIMPLE(filecheck=CHECK): -target spirv
-
-// `TT` is not valid for defining a varying entrypoint parameter,
-// and we should diagnose an error.
-
-// CHECK: error 39028
-
-struct TT
-{
- Texture2D tex;
-}
-
-[numthreads(1, 1, 1)]
-void f(TT t)
-{
- return;
-} \ No newline at end of file
diff --git a/tests/language-feature/shader-params/entry-point-uniform-params-implicit.slang b/tests/language-feature/shader-params/entry-point-uniform-params-implicit.slang
new file mode 100644
index 000000000..5f8ac7edd
--- /dev/null
+++ b/tests/language-feature/shader-params/entry-point-uniform-params-implicit.slang
@@ -0,0 +1,42 @@
+// entry-point-uniform-params-implicit.slang
+
+// Test that slang can treat a compute shader parameter as `uniform` without explicit `uniform` keyword.
+
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -xslang -Wno-38040
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -xslang -Wno-38040
+//TEST:SIMPLE(filecheck=WARNING): -target spirv
+
+struct Data
+{
+ int a;
+ int b;
+}
+
+int test(int val, int a, int b)
+{
+ return a*(val+1) + b*(val+2);
+}
+
+[numthreads(4, 1, 1)]
+[shader("compute")]
+void computeMain(
+
+//TEST_INPUT:uniform(data=[256 1]):name=d
+// WARNING: ([[# @LINE+1]]): warning 38040
+ Data d,
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+ uniform RWStructuredBuffer<int> outputBuffer,
+
+ int3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int tid = dispatchThreadID.x;
+ int inVal = tid;
+ int outVal = test(inVal, d.a, d.b);
+ outputBuffer[tid] = outVal;
+
+ // CHECK: 102
+ // CHECK: 203
+ // CHECK: 304
+ // CHECK: 405
+}
diff --git a/tests/reflection/attribute.slang.expected b/tests/reflection/attribute.slang.expected
index 9b51aae32..a5bce747b 100644
--- a/tests/reflection/attribute.slang.expected
+++ b/tests/reflection/attribute.slang.expected
@@ -288,8 +288,7 @@ standard output = {
]
}
],
- "stage": "compute",
- "binding": {"kind": "varyingInput", "index": 0},
+ "binding": {"kind": "uniform", "offset": 0, "size": 4},
"type": {
"kind": "scalar",
"scalarType": "float32"
@@ -304,8 +303,7 @@ standard output = {
]
}
],
- "stage": "compute",
- "binding": {"kind": "varyingInput", "index": 1},
+ "binding": {"kind": "uniform", "offset": 4, "size": 4},
"type": {
"kind": "scalar",
"scalarType": "float32"