OSDN Git Service

braodcom/vc5: Fix incorrect early Z writes in discard shaders.
authorEric Anholt <eric@anholt.net>
Thu, 28 Sep 2017 17:39:07 +0000 (10:39 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 10 Oct 2017 18:42:05 +0000 (11:42 -0700)
Fixes glsl-fs-discard-02.

src/gallium/drivers/vc5/vc5_draw.c

index f764f41..555e822 100644 (file)
@@ -187,8 +187,13 @@ vc5_emit_gl_shader_state(struct vc5_context *vc5,
                         (info->mode == PIPE_PRIM_POINTS &&
                          vc5->rasterizer->base.point_size_per_vertex);
 
+                /* Must be set if the shader modifies Z, discards, or modifies
+                 * the sample mask.  For any of these cases, the fragment
+                 * shader needs to write the Z value (even just discards).
+                 */
                 shader.fragment_shader_does_z_writes =
-                        vc5->prog.fs->prog_data.fs->writes_z;
+                        (vc5->prog.fs->prog_data.fs->writes_z ||
+                         vc5->prog.fs->prog_data.fs->discard);
 
                 shader.number_of_varyings_in_fragment_shader =
                         vc5->prog.fs->prog_data.base->num_inputs;