summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2024-10-30 22:58:07 -0700
committerGitHub <noreply@github.com>2024-10-30 22:58:07 -0700
commit1487a1f98d8916985b243f4a0113d216c42e4ba3 (patch)
treef19e0f9c346ed4759830d135a79247947bb0d3dd /tests
parenta98fb6cbb4a846fc63266466a143690037e29c44 (diff)
Constant-fold for the type-casting in switch-case labels (#5436)
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/gh-5372.slang45
-rw-r--r--tests/diagnostics/attribute-error.slang6
2 files changed, 49 insertions, 2 deletions
diff --git a/tests/bugs/gh-5372.slang b/tests/bugs/gh-5372.slang
new file mode 100644
index 000000000..1cd778ab3
--- /dev/null
+++ b/tests/bugs/gh-5372.slang
@@ -0,0 +1,45 @@
+//TEST:SIMPLE(filecheck=SPV): -allow-glsl -target spirv-asm -entry vertexMain -stage vertex
+
+// This test is to make sure the constant-folding works for the switch-case label.
+// The shader code is from VK-CTS but modified,
+// dEQP-VK.glsl.switch.const_expr_in_label_dynamic_fragment
+
+layout(location = 0) in highp vec4 a_position;
+layout(location = 1) in highp vec4 a_coords;
+
+layout(location = 0) out mediump vec4 v_color;
+layout (std140, set=0, binding=0) uniform buffer0 { highp int ui_two; };
+
+void vertexMain(void)
+{
+ gl_Position = a_position;
+ highp vec4 coords = a_coords;
+ mediump vec3 res = vec3(0.0);
+
+ const int t = 2;
+ switch (ui_two)
+ {
+ //SPV-NOT:([[# @LINE+1]]): error
+ case int(0.0):
+ res = coords.xyz;
+ break;
+
+ //SPV-NOT:([[# @LINE+1]]): error
+ case 2-1:
+ res = coords.wzy;
+ break;
+
+ //SPV-NOT:([[# @LINE+1]]): error
+ case 3&(1<<1):
+ res = coords.yzw;
+ break;
+
+ //SPV-NOT:([[# @LINE+1]]): error
+ case t+1:
+ res = coords.zyx;
+ break;
+ }
+
+ v_color = vec4(res, 1.0);
+}
+
diff --git a/tests/diagnostics/attribute-error.slang b/tests/diagnostics/attribute-error.slang
index 9cc24437a..d3f202e26 100644
--- a/tests/diagnostics/attribute-error.slang
+++ b/tests/diagnostics/attribute-error.slang
@@ -2,7 +2,7 @@
// Tests reflection of user defined attributes.
-//DIAGNOSTIC_TEST:REFLECTION:-stage compute -entry main -target hlsl
+//TEST:SIMPLE(filecheck=REFLECTION):-stage compute -entry main -target hlsl
[__AttributeUsage(_AttributeTargets.Struct)]
struct MyStructAttribute
@@ -16,9 +16,11 @@ struct DefaultValueAttribute
int iParam;
};
+//REFLECTION:([[# @LINE+1]]): error 30019: expected an expression of type 'float', got 'String'
[MyStruct(0, "stringVal")] // attribute arg type mismatch
struct A
{
+ //REFLECTION:([[# @LINE+1]]): error 31002: attribute 'MyStruct' is not valid here
[MyStruct(0, 10.0)] // attribute does not apply to this construct
float x;
[DefaultValue(2.0)] // attribute arg type mismatch
@@ -31,4 +33,4 @@ ParameterBlock<A> param;
void main(
uint3 dispatchThreadID : SV_DispatchThreadID)
{
-} \ No newline at end of file
+}