Mesa (master): i965: Allow clip distances to be read back in fragment shaders.

Paul Berry stereotype441 at kemper.freedesktop.org
Fri Sep 23 22:43:48 UTC 2011


Module: Mesa
Branch: master
Commit: 2a6d43204024bc47df9bf5f7803d62d4d9580ab5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a6d43204024bc47df9bf5f7803d62d4d9580ab5

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Sun Sep  4 12:18:06 2011 -0700

i965: Allow clip distances to be read back in fragment shaders.

Previously, we conditionally set up the SF pipline stage with a
urb_entry_read_offset of 2 when clipping was in use, and 1 otherwise,
causing the clip distance VUE slots to be skipped if present.  This
was an extremely minor savings (it saved the SF unit from reading 2
vec4s out of the URB, but it didn't affect any computation, since we
only instruct the SF unit to perform interpolation on VUE slots that
are actually used by the fragment shader).

GLSL 1.30 requires an interpolated version of gl_ClipDistance to be
available for reading in the fragment shader, so we need the SF's
urb_entry_read_offset to be 1 when the fragment shader reads from
gl_ClipDistance.

This patch just unconditionally sets the urb_entry_read_offset to 1 in
all cases; this is sufficient to make gl_ClipDistance available to the
fragment shader when it is needed, and the performance loss should be
negligible when it isn't.

Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/drivers/dri/i965/gen6_sf_state.c |    6 +-----
 src/mesa/drivers/dri/i965/gen7_sf_state.c |    2 +-
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_sf_state.c b/src/mesa/drivers/dri/i965/gen6_sf_state.c
index 5cbfe78..3eca786 100644
--- a/src/mesa/drivers/dri/i965/gen6_sf_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_sf_state.c
@@ -123,16 +123,12 @@ upload_sf_state(struct brw_context *brw)
    /* _NEW_BUFFER */
    GLboolean render_to_fbo = brw->intel.ctx.DrawBuffer->Name != 0;
    int attr = 0, input_index = 0;
-   int urb_entry_read_offset;
+   int urb_entry_read_offset = 1;
    float point_size;
    uint16_t attr_overrides[FRAG_ATTRIB_MAX];
    int nr_userclip;
 
    /* _NEW_TRANSFORM */
-   if (ctx->Transform.ClipPlanesEnabled)
-      urb_entry_read_offset = 2;
-   else
-      urb_entry_read_offset = 1;
    nr_userclip = brw_count_bits(ctx->Transform.ClipPlanesEnabled);
 
    brw_compute_vue_map(&vue_map, intel, nr_userclip, vs_outputs_written);
diff --git a/src/mesa/drivers/dri/i965/gen7_sf_state.c b/src/mesa/drivers/dri/i965/gen7_sf_state.c
index b1bec1a..75dc6da 100644
--- a/src/mesa/drivers/dri/i965/gen7_sf_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sf_state.c
@@ -43,7 +43,7 @@ upload_sbe_state(struct brw_context *brw)
    int i;
    int attr = 0, input_index = 0;
    /* _NEW_TRANSFORM */
-   int urb_entry_read_offset = ctx->Transform.ClipPlanesEnabled ? 2 : 1;
+   int urb_entry_read_offset = 1;
    int nr_userclip = brw_count_bits(ctx->Transform.ClipPlanesEnabled);
    uint16_t attr_overrides[FRAG_ATTRIB_MAX];
 




More information about the mesa-commit mailing list