From 2056e4a777bd0eed88ff2762977955b2f2bf2f1c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 27 Dec 2017 15:12:37 -0800 Subject: broadcom/vc5: Emit proper flatshading code for glShadeModel(GL_FLAT). In updating the simulator, behavior changed slightly so that our old code wasn't getting glxgears's flatshading interpolated right. Emit flat shading code just like we would for a normal flat-shaded varying, by passing a flag in the shader key for glShadeModel(GL_FLAT) state and customizing the color inputs based on that. --- src/broadcom/compiler/nir_to_vir.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/broadcom/compiler/nir_to_vir.c') diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index 77d460c1b62..394e20d2070 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -614,16 +614,22 @@ emit_fragment_varying(struct v3d_compile *c, nir_variable *var, switch (var->data.interpolation) { case INTERP_MODE_NONE: /* If a gl_FrontColor or gl_BackColor input has no interp - * qualifier, then flag it for glShadeModel() handling by the - * driver. + * qualifier, then if we're using glShadeModel(GL_FLAT) it + * needs to be flat shaded. */ switch (var->data.location) { case VARYING_SLOT_COL0: case VARYING_SLOT_COL1: case VARYING_SLOT_BFC0: case VARYING_SLOT_BFC1: - BITSET_SET(c->shade_model_flags, i); - break; + if (c->fs_key->shade_model_flat) { + BITSET_SET(c->flat_shade_flags, i); + vir_MOV_dest(c, c->undef, vary); + return vir_MOV(c, r5); + } else { + return vir_FADD(c, vir_FMUL(c, vary, + c->payload_w), r5); + } default: break; } -- cgit v1.2.3