diff options
author | Paul Berry <[email protected]> | 2011-10-22 09:33:16 -0700 |
---|---|---|
committer | Paul Berry <[email protected]> | 2011-10-27 15:32:20 -0700 |
commit | 5aa96286e7e1a5380673eb75e8653616b48751fd (patch) | |
tree | 9022be2d7baf88cd63f7502f378d5db216e2c742 /src/mesa/drivers/dri/i965/gen6_clip_state.c | |
parent | 4d563ec1cc912e4b3f02e71ad72d7b08f001d4d7 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/gen6_clip_state.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/gen6_clip_state.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c b/src/mesa/drivers/dri/i965/gen6_clip_state.c index 9b36af47dde..b3bb8aee3ec 100644 --- a/src/mesa/drivers/dri/i965/gen6_clip_state.c +++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c @@ -31,6 +31,26 @@ #include "brw_util.h" #include "intel_batchbuffer.h" +/** + * Return true if at least one of the inputs used by the given fragment + * program has the GLSL "noperspective" interpolation qualifier. + */ +bool +brw_fprog_uses_noperspective(const struct gl_fragment_program *fprog) +{ + int attr; + for (attr = 0; attr < FRAG_ATTRIB_MAX; ++attr) { + /* Ignore unused inputs. */ + if (!(fprog->Base.InputsRead & BITFIELD64_BIT(attr))) + continue; + + if (fprog->InterpQualifier[attr] == INTERP_QUALIFIER_NOPERSPECTIVE) + return true; + } + return false; +} + + static void upload_clip_state(struct brw_context *brw) { @@ -38,6 +58,14 @@ upload_clip_state(struct brw_context *brw) struct gl_context *ctx = &intel->ctx; uint32_t depth_clamp = 0; uint32_t provoking, userclip; + uint32_t nonperspective_barycentric_enable_flag = 0; + /* BRW_NEW_FRAGMENT_PROGRAM */ + const struct gl_fragment_program *fprog = brw->fragment_program; + + if (brw_fprog_uses_noperspective(fprog)) { + nonperspective_barycentric_enable_flag = + GEN6_CLIP_NON_PERSPECTIVE_BARYCENTRIC_ENABLE; + } if (!ctx->Transform.DepthClamp) depth_clamp = GEN6_CLIP_Z_TEST; @@ -64,6 +92,7 @@ upload_clip_state(struct brw_context *brw) OUT_BATCH(GEN6_CLIP_ENABLE | GEN6_CLIP_API_OGL | GEN6_CLIP_MODE_NORMAL | + nonperspective_barycentric_enable_flag | GEN6_CLIP_XY_TEST | userclip << GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT | depth_clamp | @@ -77,7 +106,8 @@ upload_clip_state(struct brw_context *brw) const struct brw_tracked_state gen6_clip_state = { .dirty = { .mesa = _NEW_TRANSFORM | _NEW_LIGHT, - .brw = BRW_NEW_CONTEXT, + .brw = (BRW_NEW_CONTEXT | + BRW_NEW_FRAGMENT_PROGRAM), .cache = 0 }, .emit = upload_clip_state, |