On 2 September 2011 13:57, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net">eric@anholt.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Fri, 2 Sep 2011 09:07:00 -0700, Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>> wrote:<br>
> This patch changes get_attr_override() (which computes the<br>
> relationship between vertex shader outputs and fragment shader inputs)<br>
> to use the VUE map.<br>
> ---<br>
> src/mesa/drivers/dri/i965/brw_state.h | 3 +-<br>
> src/mesa/drivers/dri/i965/gen6_sf_state.c | 108 +++++++++++++++++------------<br>
> src/mesa/drivers/dri/i965/gen7_sf_state.c | 13 +++-<br>
> 3 files changed, 75 insertions(+), 49 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h<br>
> index cede4e5..167134b 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_state.h<br>
> +++ b/src/mesa/drivers/dri/i965/brw_state.h<br>
> @@ -206,7 +206,8 @@ void upload_default_color(struct brw_context *brw,<br>
><br>
> /* gen6_sf_state.c */<br>
> uint32_t<br>
> -get_attr_override(struct brw_context *brw, int fs_attr, int two_side_color);<br>
> +get_attr_override(struct brw_vue_map *vue_map, int urb_entry_read_offset,<br>
> + int fs_attr);<br>
><br>
> /* gen7_misc_state.c */<br>
> unsigned int<br>
> diff --git a/src/mesa/drivers/dri/i965/gen6_sf_state.c b/src/mesa/drivers/dri/i965/gen6_sf_state.c<br>
> index 714914a..5e121f7 100644<br>
> --- a/src/mesa/drivers/dri/i965/gen6_sf_state.c<br>
> +++ b/src/mesa/drivers/dri/i965/gen6_sf_state.c<br>
<br>
</div><div class="im">> + if (vs_attr < 0 || vs_attr == VERT_RESULT_HPOS) {<br>
> + /* These attributes will be overwritten by the fragment shader's<br>
> + * interpolation code (see emit_interp() in brw_wm_fp.c), so just let<br>
> + * them reference attribute the first available attribute.<br>
> + */<br>
> + return 0;<br>
<br>
</div>One too many attributes in that comment.<br></blockquote><div><br>Oops, I'll extra delete the extra word.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
> + /* Compute the location of the attribute relative to urb_entry_read_offset.<br>
> + * Each increment of urb_entry_read_offset represents a 256-bit value, so<br>
> + * it counts for two 128-bit VUE slots.<br>
> + */<br>
> + attr_override = slot - 2*urb_entry_read_offset;<br>
<br>
</div>I like spaces between binary operators unless you're really hurting for<br>
space.<br></blockquote><div><br>Yeah, I flip flop on whether to put spaces around "*". The programmer in me wants the spaces, the mathematician in me deplores them. I guess I was feeling like a mathematician when I wrote this line.<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
> + assert (attr_override >= 0 && attr_override < 32);<br>
><br>
> - return attr_index;<br>
> + /* If the VUE slot following this one represents a back-facing color, then<br>
> + * we need to instruct the SF unit to do back-facing swizzling.<br>
> + */<br>
> + if (vue_map->slot_to_vert_result[slot] == VERT_RESULT_COL0 &&<br>
> + vue_map->slot_to_vert_result[slot+1] == VERT_RESULT_BFC0)<br>
> + attr_override |= (ATTRIBUTE_SWIZZLE_INPUTATTR_FACING << ATTRIBUTE_SWIZZLE_SHIFT);<br>
> + else if (vue_map->slot_to_vert_result[slot] == VERT_RESULT_COL1 &&<br>
> + vue_map->slot_to_vert_result[slot+1] == VERT_RESULT_BFC1)<br>
> + attr_override |= (ATTRIBUTE_SWIZZLE_INPUTATTR_FACING << ATTRIBUTE_SWIZZLE_SHIFT);<br>
> +<br>
> + return attr_override;<br>
<br>
</div>I think that this is the wrong criteria for backface color swizzle, not<br>
that it's a new bug you're introducing. We need some tests for this.<br>