summaryrefslogtreecommitdiff
path: root/tests/bugs
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-02-25 20:49:31 -0800
committerGitHub <noreply@github.com>2022-02-25 20:49:31 -0800
commitc31577953d5041c82375c22d847c2eba06106c58 (patch)
treebc685a8b63fc13cb85d160ae13df950056ca6e91 /tests/bugs
parent8990d270e3a0c01b1f7abbf4f79556c5ef82a096 (diff)
Improved SCCP, inlining and resource specialization passes, legalize `ImageSubscript` for GLSL (#2146)
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/sccp-switch-case-removal.slang25
-rw-r--r--tests/bugs/sccp-switch-case-removal.slang.expected.txt4
-rw-r--r--tests/bugs/vk-image-write.slang16
-rw-r--r--tests/bugs/vk-image-write.slang.glsl40
-rw-r--r--tests/bugs/vk-structured-buffer-load.hlsl.glsl9
5 files changed, 89 insertions, 5 deletions
diff --git a/tests/bugs/sccp-switch-case-removal.slang b/tests/bugs/sccp-switch-case-removal.slang
new file mode 100644
index 000000000..cf8d36ef7
--- /dev/null
+++ b/tests/bugs/sccp-switch-case-removal.slang
@@ -0,0 +1,25 @@
+//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj
+
+//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+static const uint kConstant = 5;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ float x = 1.0;
+ switch(kConstant)
+ {
+ case 5:
+ int tid = int(dispatchThreadID.x);
+ outputBuffer[tid] = 0;
+ break;
+ case 1:
+ ddx(x); // this should trigger glslang error if it doesn't get eliminated by sccp.
+ break;
+ default:
+ ddy(x); // this should trigger glslang error if it doesn't get eliminated by sccp.
+ break;
+ }
+} \ No newline at end of file
diff --git a/tests/bugs/sccp-switch-case-removal.slang.expected.txt b/tests/bugs/sccp-switch-case-removal.slang.expected.txt
new file mode 100644
index 000000000..ae25f7400
--- /dev/null
+++ b/tests/bugs/sccp-switch-case-removal.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+0
+0
+0 \ No newline at end of file
diff --git a/tests/bugs/vk-image-write.slang b/tests/bugs/vk-image-write.slang
new file mode 100644
index 000000000..10141384c
--- /dev/null
+++ b/tests/bugs/vk-image-write.slang
@@ -0,0 +1,16 @@
+//TEST:CROSS_COMPILE: -profile ps_5_0 -entry main -target spirv-assembly
+
+// Ensure that we can lower to `imageStore` correctly.
+
+RWTexture2D<float4> t;
+
+void writeColor(float3 v)
+{
+ t[uint2(0,0)].xyz += v;
+}
+
+float4 main() : SV_Target
+{
+ writeColor(float3(1.0));
+ return float4(0);
+}
diff --git a/tests/bugs/vk-image-write.slang.glsl b/tests/bugs/vk-image-write.slang.glsl
new file mode 100644
index 000000000..7b9bcebf9
--- /dev/null
+++ b/tests/bugs/vk-image-write.slang.glsl
@@ -0,0 +1,40 @@
+//TEST_IGNORE_FILE:
+
+#version 450
+layout(row_major) uniform;
+layout(row_major) buffer;
+
+layout(rgba32f)
+layout(binding = 0)
+uniform image2D t_0;
+
+void writeColor_0(vec3 v_0)
+{
+ const uvec2 _S1 = uvec2(0U, 0U);
+
+ vec4 _S2 = (imageLoad((t_0), ivec2((_S1))));
+
+ vec3 _S3 = _S2.xyz + v_0;
+
+ ivec2 _S4 = ivec2(_S1);
+
+ vec4 _S5 = imageLoad(t_0,_S4);
+
+ vec4 _S6 = _S5;
+ _S6.xyz = _S3;
+
+ imageStore(t_0,_S4,_S6);
+ return;
+}
+
+
+layout(location = 0)
+out vec4 _S7;
+
+void main()
+{
+ writeColor_0(vec3(1.00000000000000000000));
+ _S7 = vec4(0);
+ return;
+}
+
diff --git a/tests/bugs/vk-structured-buffer-load.hlsl.glsl b/tests/bugs/vk-structured-buffer-load.hlsl.glsl
index 1c7ec8043..05c8de193 100644
--- a/tests/bugs/vk-structured-buffer-load.hlsl.glsl
+++ b/tests/bugs/vk-structured-buffer-load.hlsl.glsl
@@ -43,13 +43,12 @@ void main()
float HitT_0 = (gl_RayTmaxNV);
RayData.PackedHitInfoA_0.x = HitT_0;
- const uint use_rcp_0 = uint(0);
- float offsfloat_0 = ((gParamBlock_sbuf_0)._data[(int(uint(0)))]);
+ float offsfloat_0 = ((gParamBlock_sbuf_0)._data[(0)]);
- uint use_rcp_1 = use_rcp_0|uint(HitT_0 > 0.00000000000000000000);
+ uint use_rcp_0 = 0U | uint(HitT_0 > 0.00000000000000000000);
- if(bool(use_rcp_1))
+ if(bool(use_rcp_0))
{
float tmpA = rcp_0(offsfloat_0);
@@ -60,7 +59,7 @@ void main()
else
{
- if(use_rcp_1 > uint(0)&&offsfloat_0 == 0.00000000000000000000)
+ if(use_rcp_0 > 0U&&offsfloat_0 == 0.00000000000000000000)
{
float tmpB = (inversesqrt((offsfloat_0 + 1.00000000000000000000)));