summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Arceri <tarceri@itsqueeze.com>2024-11-28 15:08:55 +1100
committerTimothy Arceri <tarceri@itsqueeze.com>2024-11-28 15:08:55 +1100
commit6b3deddabb61b61b28fed0cbc3aaa9cd0c11d312 (patch)
tree776fd5f3e48597f1bff795a7ff1e73a223661d00
parent468221c722481c470e6a23760b914c33143c2af6 (diff)
glsl: test loop unroll with uint overflowHEADmain
Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/975>
-rw-r--r--tests/spec/glsl-1.30/execution/vs-loop-uint-induction-overflow.shader_test67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.30/execution/vs-loop-uint-induction-overflow.shader_test b/tests/spec/glsl-1.30/execution/vs-loop-uint-induction-overflow.shader_test
new file mode 100644
index 000000000..48a43c5b0
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/vs-loop-uint-induction-overflow.shader_test
@@ -0,0 +1,67 @@
+# This tests that we do not unroll a loop in error thinking we know the max
+# trip count due to the induction variable being uint.
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+#version 130
+
+uniform uint induction_init;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+
+ vec4 colour = vec4(1.0, 1.0, 1.0, 1.0);
+ vec4 colour2 = vec4(0.0, 0.0, 0.0, 1.0);
+
+ uint j = 0u;
+ uint i = induction_init;
+ while (true) {
+
+ if (j >= 3u) {
+ colour = vec4(1.0, 0.0, 0.0, 1.0);
+ }
+
+ if (j == 2u)
+ colour = vec4(0.0, 1.0, 0.0, 1.0);
+
+ if (i >= 2147483650u) {
+ break;
+ }
+
+ i = i + 2147483647u;
+ j++;
+ }
+
+ gl_FrontColor = colour + colour2;
+}
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+
+# unit_max 4294967295
+
+# if induction_init is 0x80000001, then the induction variable is
+# [0x80000001,0x00000000,0x7fffffff] until it's larger than the limit,
+# so loop iterates 3 times.
+uniform uint induction_init 2147483649
+draw rect -1 -1 2 2
+probe all rgba 1.0 0.0 0.0 1.0
+
+# if induction_init is 0x00000000, then the induction variable is
+# [0x00000000,0x7fffffff] until it's larger than the limit,
+# so loop iterates 2 times
+uniform uint induction_init 0
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+uniform uint induction_init 2147483651
+draw rect -1 -1 2 2
+probe all rgba 1.0 1.0 1.0 1.0