[Piglit] [PATCH] Test some corner cases of loop analysis.
Paul Berry
stereotype441 at gmail.com
Thu Nov 28 11:37:18 PST 2013
As of Mesa d7fa9eb, two of these tests are known to fail:
- vs-call-in-nested-loop.shader_test
- vs-inner-loop-modifies-outer-loop-var.shader_test
---
.../execution/vs-call-in-nested-loop.shader_test | 45 ++++++++++++++++++++++
...vs-inner-loop-counts-outer-loop-var.shader_test | 39 +++++++++++++++++++
...-inner-loop-modifies-outer-loop-var.shader_test | 38 ++++++++++++++++++
3 files changed, 122 insertions(+)
create mode 100644 tests/spec/glsl-1.10/execution/vs-call-in-nested-loop.shader_test
create mode 100644 tests/spec/glsl-1.10/execution/vs-inner-loop-counts-outer-loop-var.shader_test
create mode 100644 tests/spec/glsl-1.10/execution/vs-inner-loop-modifies-outer-loop-var.shader_test
diff --git a/tests/spec/glsl-1.10/execution/vs-call-in-nested-loop.shader_test b/tests/spec/glsl-1.10/execution/vs-call-in-nested-loop.shader_test
new file mode 100644
index 0000000..1fc7acf
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-call-in-nested-loop.shader_test
@@ -0,0 +1,45 @@
+# Check that loop analysis properly accounts for the side effects of a
+# function call, even if that function call appears inside a nested
+# loop.
+
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+int i;
+int num_calls_to_foo;
+attribute vec4 piglit_vertex;
+varying vec4 color;
+
+void foo()
+{
+ num_calls_to_foo++;
+ i = 2;
+}
+
+void main()
+{
+ num_calls_to_foo = 0;
+ for (i = 0; i < 3; i++) { // Executes once, since foo() sets i to 2
+ for (int j = 0; j < 3; j++) { // Executes 3 times
+ foo();
+ }
+ }
+ gl_Position = piglit_vertex;
+ if (num_calls_to_foo == 3)
+ color = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ color = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[fragment shader]
+varying vec4 color;
+
+void main()
+{
+ gl_FragColor = color;
+}
+
+[test]
+draw rect -1 -1 2 2
+probe all rgba 0 1 0 1
diff --git a/tests/spec/glsl-1.10/execution/vs-inner-loop-counts-outer-loop-var.shader_test b/tests/spec/glsl-1.10/execution/vs-inner-loop-counts-outer-loop-var.shader_test
new file mode 100644
index 0000000..e2e00e7
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-inner-loop-counts-outer-loop-var.shader_test
@@ -0,0 +1,39 @@
+# Check that when computing the number of iterations executed by
+# nested loops, loop analysis doesn't assume that an increment in the
+# inner loop executes once per invocation of the outer loop.
+
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+attribute vec4 piglit_vertex;
+varying vec4 color;
+
+void main()
+{
+ int num_total_iterations = 0;
+ int i = 0;
+ while (i < 6) { // Executes twice, since inner loop increments i each time through
+ for (int j = 0; j < 3; j++) { // Executes 3 times
+ num_total_iterations++;
+ i++;
+ }
+ }
+ gl_Position = piglit_vertex;
+ if (num_total_iterations == 6)
+ color = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ color = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[fragment shader]
+varying vec4 color;
+
+void main()
+{
+ gl_FragColor = color;
+}
+
+[test]
+draw rect -1 -1 2 2
+probe all rgba 0 1 0 1
diff --git a/tests/spec/glsl-1.10/execution/vs-inner-loop-modifies-outer-loop-var.shader_test b/tests/spec/glsl-1.10/execution/vs-inner-loop-modifies-outer-loop-var.shader_test
new file mode 100644
index 0000000..e0a31fb
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-inner-loop-modifies-outer-loop-var.shader_test
@@ -0,0 +1,38 @@
+# Check that when computing the number of iterations executed by
+# nested loops, loop analysis sees that assignments in the inner loop
+# may have an effect on the outer loop's induction variable.
+
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+attribute vec4 piglit_vertex;
+varying vec4 color;
+
+void main()
+{
+ int num_total_iterations = 0;
+ for (int i = 0; i < 3; i++) { // Executes once, since inner loop sets i to 2
+ for (int j = 0; j < 3; j++) { // Executes 3 times
+ num_total_iterations++;
+ i = 2;
+ }
+ }
+ gl_Position = piglit_vertex;
+ if (num_total_iterations == 3)
+ color = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ color = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[fragment shader]
+varying vec4 color;
+
+void main()
+{
+ gl_FragColor = color;
+}
+
+[test]
+draw rect -1 -1 2 2
+probe all rgba 0 1 0 1
--
1.8.4.2
More information about the Piglit
mailing list