summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cross-compile/unknown-image-format.slang.glsl30
-rw-r--r--tests/diagnostics/global-uniform.slang4
-rw-r--r--tests/diagnostics/global-uniform.slang.expected7
-rw-r--r--tests/language-feature/shader-params/global-uniform-params.slang28
-rw-r--r--tests/language-feature/shader-params/global-uniform-params.slang.expected.txt4
5 files changed, 52 insertions, 21 deletions
diff --git a/tests/cross-compile/unknown-image-format.slang.glsl b/tests/cross-compile/unknown-image-format.slang.glsl
index 9995bba72..329405ab6 100644
--- a/tests/cross-compile/unknown-image-format.slang.glsl
+++ b/tests/cross-compile/unknown-image-format.slang.glsl
@@ -30,36 +30,36 @@ layout(binding = 1, set = 1)
uniform image2D gBlock_explicitFormat_0;
layout(binding = 3)
-uniform image2D _S2;
+uniform image2D entryPointParams_noFormat_0;
layout(rgba16f)
layout(binding = 4)
-uniform image2D _S3;
+uniform image2D entryPointParams_explicitFormat_0;
layout(location = 0)
-out vec4 _S4;
+out vec4 _S2;
void main()
{
const vec4 result_0 = vec4(0);
- float _S5 = (imageLoad((gNoFormat_0), ivec2((C_0._data.index_0))).x);
- vec4 result_1 = result_0 + _S5;
+ float _S3 = (imageLoad((gNoFormat_0), ivec2((C_0._data.index_0))).x);
+ vec4 result_1 = result_0 + _S3;
- float _S6 = (imageLoad((gExplicitFormat_0), ivec2((C_0._data.index_0))).x);
- vec4 result_2 = result_1 + _S6;
+ float _S4 = (imageLoad((gExplicitFormat_0), ivec2((C_0._data.index_0))).x);
+ vec4 result_2 = result_1 + _S4;
- vec4 _S7 = (imageLoad((gBlock_noFormat_0), ivec2((C_0._data.index_0))));
- vec4 result_3 = result_2 + _S7;
+ vec4 _S5 = (imageLoad((gBlock_noFormat_0), ivec2((C_0._data.index_0))));
+ vec4 result_3 = result_2 + _S5;
- vec4 _S8 = (imageLoad((gBlock_explicitFormat_0), ivec2((C_0._data.index_0))));
- vec4 result_4 = result_3 + _S8;
+ vec4 _S6 = (imageLoad((gBlock_explicitFormat_0), ivec2((C_0._data.index_0))));
+ vec4 result_4 = result_3 + _S6;
- vec4 _S9 = (imageLoad((_S2), ivec2((C_0._data.index_0))));
- vec4 result_5 = result_4 + _S9;
+ vec4 _S7 = (imageLoad((entryPointParams_noFormat_0), ivec2((C_0._data.index_0))));
+ vec4 result_5 = result_4 + _S7;
- vec4 _S10 = (imageLoad((_S3), ivec2((C_0._data.index_0))));
- _S4 = result_5 + _S10;
+ vec4 _S8 = (imageLoad((entryPointParams_explicitFormat_0), ivec2((C_0._data.index_0))));
+ _S2 = result_5 + _S8;
return;
}
diff --git a/tests/diagnostics/global-uniform.slang b/tests/diagnostics/global-uniform.slang
index 6b17016f2..de4537115 100644
--- a/tests/diagnostics/global-uniform.slang
+++ b/tests/diagnostics/global-uniform.slang
@@ -2,8 +2,8 @@
//DIAGNOSTIC_TEST:SIMPLE:-target hlsl
//DIAGNOSTIC_TEST:COMMAND_LINE_SIMPLE:-target hlsl
-// Any attempt to declare a global variable that actually declares a
-// global uniform should be diagnosed as unsupported.
+// An attempt to declare a global variable that actually declares a
+// global shader parameter should be diagnosed, unless `uniform` was used.
uniform float a;
diff --git a/tests/diagnostics/global-uniform.slang.expected b/tests/diagnostics/global-uniform.slang.expected
index a77144c4f..6f69ec0c5 100644
--- a/tests/diagnostics/global-uniform.slang.expected
+++ b/tests/diagnostics/global-uniform.slang.expected
@@ -1,8 +1,7 @@
-result code = -1
+result code = 0
standard error = {
-tests/diagnostics/global-uniform.slang(8): error 39016: 'a' is implicitly a global uniform shader parameter, which is currently unsupported by Slang. If a uniform parameter is intended, use a constant buffer or parameter block. If a global is intended, use the 'static' modifier.
-tests/diagnostics/global-uniform.slang(10): error 39016: 'b' is implicitly a global uniform shader parameter, which is currently unsupported by Slang. If a uniform parameter is intended, use a constant buffer or parameter block. If a global is intended, use the 'static' modifier.
-tests/diagnostics/global-uniform.slang(13): error 39016: 'c' is implicitly a global uniform shader parameter, which is currently unsupported by Slang. If a uniform parameter is intended, use a constant buffer or parameter block. If a global is intended, use the 'static' modifier.
+tests/diagnostics/global-uniform.slang(10): warning 39016: 'b' is implicitly a global shader parameter, not a global variable. If a global variable is intended, add the 'static' modifier. If a uniform shader parameter is intended, add the 'uniform' modifier to silence this warning.
+tests/diagnostics/global-uniform.slang(13): warning 39016: 'c' is implicitly a global shader parameter, not a global variable. If a global variable is intended, add the 'static' modifier. If a uniform shader parameter is intended, add the 'uniform' modifier to silence this warning.
}
standard output = {
}
diff --git a/tests/language-feature/shader-params/global-uniform-params.slang b/tests/language-feature/shader-params/global-uniform-params.slang
new file mode 100644
index 000000000..6b4e5a834
--- /dev/null
+++ b/tests/language-feature/shader-params/global-uniform-params.slang
@@ -0,0 +1,28 @@
+// global-uniform-params.slang
+
+//TEST(compute):COMPARE_COMPUTE:
+
+// Test that code can use uniform parameters
+// of "ordinary" type declared at the global scope
+
+//TEST_INPUT:cbuffer(data=[256 1]):name=$Globals
+uniform int a;
+uniform int b;
+
+int test(int val)
+{
+ return a*(val+1) + b*(val+2);
+}
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(4, 1, 1)]
+[shader("compute")]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int inVal = tid;
+ int outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+}
diff --git a/tests/language-feature/shader-params/global-uniform-params.slang.expected.txt b/tests/language-feature/shader-params/global-uniform-params.slang.expected.txt
new file mode 100644
index 000000000..4cf6581b3
--- /dev/null
+++ b/tests/language-feature/shader-params/global-uniform-params.slang.expected.txt
@@ -0,0 +1,4 @@
+102
+203
+304
+405