From 5aa96286e7e1a5380673eb75e8653616b48751fd Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Sat, 22 Oct 2011 09:33:16 -0700 Subject: i965/gen6+: Add support for noperspective interpolation. This required the following changes: - WM setup now makes the appropriate set of barycentric coordinates (perspective vs. noperspective) available to the fragment shader, based on whether the shader requires perspective interpolation, noperspective interpolation, both, or neither. - The fragment shader backend now uses the appropriate set of barycentric coordiantes when interpolating, based on the interpolation mode returned by ir_variable::determine_interpolation_mode(). - SF setup now uses gl_fragment_program::InterpQualifier to determine which attributes are to be flat shaded (as opposed to the old logic, which only flat shaded colors). - CLIP setup now ensures that the clipper outputs non-perspective barycentric coordinates when they are needed by the fragment shader. Fixes the remaining piglit tests of interpolation qualifiers that were failing: - interpolation-flat-*-smooth-none - interpolation-flat-other-flat-none - interpolation-noperspective-* - interpolation-smooth-gl_*Color-flat-* Reviewed-by: Eric Anholt --- src/mesa/drivers/dri/i965/gen7_sf_state.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/mesa/drivers/dri/i965/gen7_sf_state.c') diff --git a/src/mesa/drivers/dri/i965/gen7_sf_state.c b/src/mesa/drivers/dri/i965/gen7_sf_state.c index e796a01..d3ffbd3 100644 --- a/src/mesa/drivers/dri/i965/gen7_sf_state.c +++ b/src/mesa/drivers/dri/i965/gen7_sf_state.c @@ -39,6 +39,8 @@ upload_sbe_state(struct brw_context *brw) GLbitfield64 vs_outputs_written = brw->vs.prog_data->outputs_written; /* BRW_NEW_FRAGMENT_PROGRAM */ uint32_t num_outputs = _mesa_bitcount_64(brw->fragment_program->Base.InputsRead); + /* _NEW_LIGHT */ + bool shade_model_flat = ctx->Light.ShadeModel == GL_FLAT; uint32_t dw1, dw10, dw11; int i; int attr = 0, input_index = 0; @@ -74,6 +76,10 @@ upload_sbe_state(struct brw_context *brw) * they source from. */ for (; attr < FRAG_ATTRIB_MAX; attr++) { + enum glsl_interp_qualifier interp_qualifier = + brw->fragment_program->InterpQualifier[attr]; + bool is_gl_Color = attr == FRAG_ATTRIB_COL0 || attr == FRAG_ATTRIB_COL1; + if (!(brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(attr))) continue; @@ -87,17 +93,10 @@ upload_sbe_state(struct brw_context *brw) dw10 |= (1 << input_index); /* flat shading */ - if (ctx->Light.ShadeModel == GL_FLAT) { - /* - * Setup the Constant Interpolation Enable bit mask for each - * corresponding attribute(currently, we only care two attrs: - * FRAG_BIT_COL0 and FRAG_BIT_COL1). - * - * FIXME: should we care other attributes? - */ - if (attr == FRAG_ATTRIB_COL0 || attr == FRAG_ATTRIB_COL1) - dw11 |= (1 << input_index); - } + if (interp_qualifier == INTERP_QUALIFIER_FLAT || + (shade_model_flat && is_gl_Color && + interp_qualifier == INTERP_QUALIFIER_NONE)) + dw11 |= (1 << input_index); /* The hardware can only do the overrides on 16 overrides at a * time, and the other up to 16 have to be lined up so that the -- cgit v1.1