Mesa (master): i965/fs: Stop wasting input attribute space on gl_FragCoord and gl_FrontFacing.

Paul Berry stereotype441 at kemper.freedesktop.org
Mon Sep 16 20:07:16 UTC 2013


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Mon Sep  2 22:18:27 2013 -0700

i965/fs: Stop wasting input attribute space on gl_FragCoord and gl_FrontFacing.

Previously, if a fragment shader accessed gl_FragCoord or
gl_FrontFacing, we would assign them their own slots in the fragment
shader input attribute array, using up space that could be made
available to real varyings.  This was not strictly necessary (since
these values are not true varyings, and are instead computed from
other data available in the FS payload).  But we had to do it anyway
because the SF/SBE setup code assumed that every 1 bit in the
gl_program::InputsRead bitfield corresponded to a genuine varying
variable.

Now that the SF/SBE code consults brw_wm_prog_data and only sets up
the attributes that the fragment shader actually needs, we don't have
to do this anymore.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/brw_context.h   |    9 +++++++++
 src/mesa/drivers/dri/i965/brw_fs.cpp      |    3 ++-
 src/mesa/drivers/dri/i965/gen6_sf_state.c |    8 --------
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 4c6bedc..040a8d3 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -439,6 +439,15 @@ void brw_compute_vue_map(struct brw_context *brw, struct brw_vue_map *vue_map,
                          GLbitfield64 slots_valid, bool userclip_active);
 
 
+/**
+ * Bitmask indicating which fragment shader inputs represent varyings (and
+ * hence have to be delivered to the fragment shader by the SF/SBE stage).
+ */
+#define BRW_FS_VARYING_INPUT_MASK \
+   (BITFIELD64_RANGE(0, VARYING_SLOT_MAX) & \
+    ~VARYING_BIT_POS & ~VARYING_BIT_FACE)
+
+
 /*
  * Mapping of VUE map slots to interpolation modes.
  */
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 2967665..9cb7950 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1238,7 +1238,8 @@ fs_visitor::calculate_urb_setup()
    /* Figure out where each of the incoming setup attributes lands. */
    if (brw->gen >= 6) {
       for (unsigned int i = 0; i < VARYING_SLOT_MAX; i++) {
-	 if (fp->Base.InputsRead & BITFIELD64_BIT(i)) {
+	 if (fp->Base.InputsRead & BRW_FS_VARYING_INPUT_MASK &
+             BITFIELD64_BIT(i)) {
 	    c->prog_data.urb_setup[i] = urb_next++;
 	 }
       }
diff --git a/src/mesa/drivers/dri/i965/gen6_sf_state.c b/src/mesa/drivers/dri/i965/gen6_sf_state.c
index 8bac559..6a9fa60 100644
--- a/src/mesa/drivers/dri/i965/gen6_sf_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_sf_state.c
@@ -56,14 +56,6 @@ static uint32_t
 get_attr_override(const struct brw_vue_map *vue_map, int urb_entry_read_offset,
                   int fs_attr, bool two_side_color, uint32_t *max_source_attr)
 {
-   if (fs_attr == VARYING_SLOT_POS) {
-      /* This attribute will be overwritten by the fragment shader's
-       * interpolation code (see emit_interp() in brw_wm_fp.c), so just let it
-       * reference the first available attribute.
-       */
-      return 0;
-   }
-
    /* Find the VUE slot for this attribute. */
    int slot = vue_map->varying_to_slot[fs_attr];
 




More information about the mesa-commit mailing list