[Piglit] [PATCH v2] shader: Test to check conditional component write access in loops

Gert Wollny gw.fossdev at gmail.com
Fri Aug 4 10:44:40 UTC 2017


This test verifies that the register merge step keeps a register alive
for the whole loop if at the beginning of this loop at least one component
is written unconditionally, and later another component is written
conditionally within the same loop, and the last read to the register also
happens withing this loop.
---
 .../glsl-partial-write-in-if-in-loop.shader_test   | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 tests/spec/glsl-1.10/execution/glsl-partial-write-in-if-in-loop.shader_test

diff --git a/tests/spec/glsl-1.10/execution/glsl-partial-write-in-if-in-loop.shader_test b/tests/spec/glsl-1.10/execution/glsl-partial-write-in-if-in-loop.shader_test
new file mode 100644
index 000000000..a3799a4d6
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/glsl-partial-write-in-if-in-loop.shader_test
@@ -0,0 +1,44 @@
+# test that a temporary that is written partially in a condition
+# within a loop is properly kept alive for the full loop. 
+# 
+# The test is specifically designed to validate the correct behaviour 
+# of the register merge algorithm, it should fail if the temporary 
+# registers are not tracked on a per-component bases. To achieve
+# this (1) one components of a temporary is written at the 
+# beginning of the loop unconditionally, (2) the other components are 
+# written conditionally and it is made sure that the condition is not met 
+# in the last pass of the loop, (3) the last read happens within the loop, 
+# and (4) the shader is complex enough to allow some register merging, 
+# especially if the registers are not tracked component wise. 
+
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+uniform int n;
+
+void main()
+{
+    vec4 u = vec4(0.1, 0.2, 0.3, 0.4);
+    vec4 v;
+    vec4 k;
+
+    int a = 1;
+
+    do {
+        k.x = float(a) * 0.1;
+        if (a == 1) {
+            k.yzw = u.yzw;
+        }
+        a = a + 1;
+        v = vec4(k.x, 2.0 * k.yzw);
+    } while (a <= n);
+
+    gl_FragColor = v;
+}
+
+[test]
+uniform int n 2
+
+draw rect -1 -1 2 2
+probe all rgba  0.2 0.4 0.6 0.8
-- 
2.13.0



More information about the Piglit mailing list