On 03/22/2013 03:28 PM, srol...@vmware.com wrote:
From: Roland Scheidegger <srol...@vmware.com>

Similar to glsl-fs-main-return (and glsl-vs-main-return), this is testing
using return in main. Contrary to the these other tests, this hits both
the cases where the return path is and is NOT taken (the gallivm code
got it wrong and always did an early exit which got unnoticed by the
existing tests, see https://bugs.freedesktop.org/show_bug.cgi?id=62357).
It also needs glsl 1.30 (even though this is not specific to what's tested
here).

Are there any drivers in Mesa that don't expose GLSL 1.30 but would benefit from this test?

---
  .../glsl-fs-main-return-conditional.shader_test    |   34 ++++++++++++++++++++
  1 file changed, 34 insertions(+)
  create mode 100644 tests/shaders/glsl-fs-main-return-conditional.shader_test

diff --git a/tests/shaders/glsl-fs-main-return-conditional.shader_test 
b/tests/shaders/glsl-fs-main-return-conditional.shader_test
new file mode 100644
index 0000000..124a4cd
--- /dev/null
+++ b/tests/shaders/glsl-fs-main-return-conditional.shader_test
@@ -0,0 +1,34 @@
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+#version 130
+void main()
+{
+       gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+#version 130
+uniform vec4 v;

This could just be

const vec4 v = vec4(0., 1., 0., 1.);

and delete the uniform setting in the [test] section.

+
+void main()
+{
+       uint posintx = uint(gl_FragCoord.x);
+       uint one = uint(1);
+       gl_FragColor = v;
+       if ((posintx & one) == one) {
+               return;  // return for every second pixel
+       }
+       gl_FragColor = vec4(1.0) - v;
+}

It seems like this could be done as:

void main()
{
    floor x = floor(gl_FragCoord.x - 0.5);

    gl_FragCoord = v;
    if (mod(x, 2.0) > epsilon)
        return;

    gl_FragColor = vec4(1.0) - v;
}

+
+[test]
+uniform vec4 v 0 1 0 1
+
+draw rect -1 -1 2 2
+probe rgb 0 0 1 0 1
+probe rgb 1 0 0 1 0
+probe rgb 2 0 1 0 1
+probe rgb 3 0 0 1 0
+


_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to