[Piglit] [PATCH] Add GLSL tests for loops with function calls that have side-effects.

Kenneth Graunke kenneth at whitecape.org
Thu Mar 22 16:52:18 PDT 2012


Mesa's loop unroller incorrectly unrolls these loops 7 times, when the
function call within the body clearly makes the loop only execute once.

Cc: Ian Romanick <idr at freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 tests/shaders/glsl-fs-unroll-out-param.shader_test |   27 ++++++++++++++++++
 .../shaders/glsl-fs-unroll-side-effect.shader_test |   29 ++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)
 create mode 100644 tests/shaders/glsl-fs-unroll-out-param.shader_test
 create mode 100644 tests/shaders/glsl-fs-unroll-side-effect.shader_test

Ian,

The loop analysis code currently doesn't take calls into account
whatsoever, which is clearly wrong.  Any ideas on the best way to fix it?

diff --git a/tests/shaders/glsl-fs-unroll-out-param.shader_test b/tests/shaders/glsl-fs-unroll-out-param.shader_test
new file mode 100644
index 0000000..7cbaa23
--- /dev/null
+++ b/tests/shaders/glsl-fs-unroll-out-param.shader_test
@@ -0,0 +1,27 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader file]
+glsl-mvp.vert
+
+[fragment shader]
+void foo(out int i)
+{
+	gl_FragColor -= vec4(0.1);
+	i = 10;
+}
+
+void main()
+{
+	gl_FragColor = vec4(1.0);
+	for (int i = 0; i < 7; i++) {
+		foo(i);
+	}
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 2
+probe rgb 15 15 0.9 0.9 0.9
+
diff --git a/tests/shaders/glsl-fs-unroll-side-effect.shader_test b/tests/shaders/glsl-fs-unroll-side-effect.shader_test
new file mode 100644
index 0000000..af9c1b7
--- /dev/null
+++ b/tests/shaders/glsl-fs-unroll-side-effect.shader_test
@@ -0,0 +1,29 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader file]
+glsl-mvp.vert
+
+[fragment shader]
+int i = 0;
+
+void foo()
+{
+	gl_FragColor -= vec4(0.1);
+	i = 10;
+}
+
+void main()
+{
+	gl_FragColor = vec4(1.0);
+	for (i = 0; i < 7; i++) {
+		foo();
+	}
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 2
+probe rgb 15 15 0.9 0.9 0.9
+
-- 
1.7.7.6



More information about the Piglit mailing list