etnaviv: nir: fix gl_FrontFacing
authorJonathan Marek <jonathan@marek.ca>
Wed, 11 Sep 2019 17:42:43 +0000 (13:42 -0400)
committerJonathan Marek <jonathan@marek.ca>
Sat, 28 Sep 2019 04:33:33 +0000 (00:33 -0400)
Only invert front facing when glFrontFace is GL_CW.

Fixes following deqp test:
dEQP-GLES2.functional.shaders.builtin_variable.frontfacing

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
src/gallium/drivers/etnaviv/etnaviv_context.c
src/gallium/drivers/etnaviv/etnaviv_shader.h

index c2bfec14ed21deacbfaa67781a4107760a8838ee..a00f89b4e214f6b7b11cc88e6b755bac7f506d15 100644 (file)
@@ -98,6 +98,9 @@ etna_lower_io(nir_shader *shader, struct etna_shader_variant *v)
 
                switch (intr->intrinsic) {
                case nir_intrinsic_load_front_face: {
+                  if (!v->key.front_ccw)
+                     break;
+
                   /* front face inverted (run after int_to_float, so invert as float) */
                   b.cursor = nir_after_instr(instr);
 
index b3ced5ea2460f8566f7fcb69d01dc878cf1bcea5..82254f9c1c18a097fa51646e6b025425418f7e6b 100644 (file)
@@ -214,7 +214,10 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
    }
    ctx->dirty |= ETNA_DIRTY_INDEX_BUFFER;
 
-   struct etna_shader_key key = {};
+   struct etna_shader_key key = {
+      .front_ccw = ctx->rasterizer->front_ccw,
+   };
+
    if (pfb->cbufs[0])
       key.frag_rb_swap = !!translate_rs_format_rb_swap(pfb->cbufs[0]->format);
 
index 3c5b6e65d94ad4275fd7707207a587661e1a53da..528603a55a99652a1de3620e12b4e681ee18a962 100644 (file)
@@ -43,6 +43,8 @@ struct etna_shader_key
 
          /* do we need to swap rb in frag color? */
          unsigned frag_rb_swap : 1;
+         /* do we need to invert front facing value? */
+         unsigned front_ccw : 1;
       };
       uint32_t global;
    };