From: Paul Berry Date: Tue, 3 Sep 2013 05:18:27 +0000 (-0700) Subject: i965/fs: Stop wasting input attribute space on gl_FragCoord and gl_FrontFacing. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a83b20dcccf21ec184e35bcfa9bc577379dfd51;p=mesa.git 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 --- diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 4c6bedc0629..040a8d30613 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 29676658e64..9cb79506326 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 8bac5597094..6a9fa602c6a 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];