[Piglit] [PATCH] Revert "fs-discard-exit-3: New test for another bug in handling 1.30's discard rule."
currojerez at riseup.net
Mon Feb 2 10:22:04 PST 2015
This reverts commit 3fad0868f023f1d726e230968a4df3327de38823.
This test doesn't make any sense to me, it begins quoting the GLSL
1.30 spec on the interaction of the discard keyword with control flow:
"[...] Control flow exits the shader, and subsequent implicit or
explicit derivatives are undefined when this control flow is
non-uniform (meaning different fragments within the primitive take
different control paths)."
IOW the discard keyword is a control flow statement that can
potentially make subsequent derivatives undefined if only some subset
of the fragments execute it. The test then goes on and does the exact
opposite: It samples a texture after a non-uniform discard expecting
that implicit derivatives will be calculated correctly, while
according to the spec quotation they have undefined results.
If the quoted text doesn't seem clear enough, see section 6.4 "Jumps"
of the same specification:
"These are the jumps:
discard; // in the fragment shader language only"
and section 8.7 "Texture Lookup Functions":
"Implicit derivatives are undefined within non-uniform control flow
and for vertex shader texture fetches."
More recent spec versions have made the meaning of non-uniform control
clearer. From the GLSL spec version 4.4, section 3.8.2 "Uniform and
Non-Uniform Control Flow":
"Control flow becomes non-uniform when different fragments take
different paths through control-flow statements (selection,
iteration, and jumps). [...] Other examples of non-uniform flow
control can occur within switch statements and after conditional
breaks, continues, early returns, and after fragment discards, when
the condition is true for some fragments but not others."
There was some discussion about this topic in Khronos bug 5449, which
motivated the inclusion of the first sentence quoted above in the GLSL
1.30 spec. The rationale was that continuing the execution of
discarded fragments after a non-uniform discard would be ill-defined
because it could easily lead to infinite loops and break invariants of
.../execution/fs-discard-exit-3.shader_test | 76 ----------------------
1 file changed, 76 deletions(-)
delete mode 100644 tests/spec/glsl-1.30/execution/fs-discard-exit-3.shader_test
diff --git a/tests/spec/glsl-1.30/execution/fs-discard-exit-3.shader_test b/tests/spec/glsl-1.30/execution/fs-discard-exit-3.shader_test
deleted file mode 100644
@@ -1,76 +0,0 @@
-# This is a test for derivatives behavior after a discard.
-# From the GLSL 1.30 spec:
-# "The discard keyword is only allowed within fragment shaders. It
-# can be used within a fragment shader to abandon the operation
-# on the current fragment. This keyword causes the fragment to be
-# discarded and no updates to any buffers will occur. Control
-# flow exits the shader, and subsequent implicit or explicit
-# derivatives are undefined when this control flow is non-uniform
-# (meaning different fragments within the primitive take
-# different control paths)."
-GLSL >= 1.30
-in vec4 vertex;
-out vec2 texcoords;
- gl_Position = vertex;
- /* Turn the texcoords into a 1:1 mapping with pixels when
- * interpolated. This means that the coords for our 2x2
- * subspan we're interested in for the FS will be:
- * +-----+-----+
- * | 0,1 | 1,1 |
- * +-----+-----+
- * | 0,0 | 0,1 |
- * +-----+-----+
- * So it would sample the 1x1 miplevel of the GL_TEXTURE_2D
- * miptree, unless some other math occurs...
- texcoords.yx = (vertex.xy + 1) / 2 * 250;
-in vec2 texcoords;
-uniform sampler2D s;
- if (gl_FragCoord.x >= 1.0 || gl_FragCoord.y >= 1.0)
- /* Now, we have uniform control after the discard (well,
- * except for the join after the if statement up there). The
- * derivatives on this sample should get us the same values
- * for the undiscarded pixel as if we hadn't done any discard
- * (comment out the "discard" above to see).
- gl_FragColor = texture(s, texcoords / 4);
- 1.0 -1.0
- 1.0 1.0
-clear color 0.5 0.5 0.5 0.5
-texture miptree 0
-draw arrays GL_TRIANGLE_FAN 0 4
-probe rgba 0 0 0.0 1.0 0.0 1.0
More information about the Piglit