On 2 September 2011 12:47, 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:06:41 -0700, Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>> wrote:<br>
> Several places in the i965 code make implicit assumptions about the<br>
> structure of data in the VUE (vertex URB entry). This patch adds a<br>
> function, brw_compute_vue_map(), which computes the structure of the<br>
> VUE explicitly. Future patches will modify the rest of the driver to<br>
> use the explicitly computed map rather than rely on implicit<br>
> assumptions about it.<br>
> ---<br>
</div><div class="im">> + if (two_side_color) {<br>
> + /* front and back colors need to be consecutive */<br>
> + if ((outputs_written & BITFIELD64_BIT(VERT_RESULT_COL1)) &&<br>
> + (outputs_written & BITFIELD64_BIT(VERT_RESULT_BFC1))) {<br>
> + assert(outputs_written & BITFIELD64_BIT(VERT_RESULT_COL0));<br>
> + assert(outputs_written & BITFIELD64_BIT(VERT_RESULT_BFC0));<br>
> + assign_vue_slot(vue_map, VERT_RESULT_COL0);<br>
> + assign_vue_slot(vue_map, VERT_RESULT_BFC0);<br>
> + assign_vue_slot(vue_map, VERT_RESULT_COL1);<br>
> + assign_vue_slot(vue_map, VERT_RESULT_BFC1);<br>
> + } else if ((outputs_written & BITFIELD64_BIT(VERT_RESULT_COL0)) &&<br>
> + (outputs_written & BITFIELD64_BIT(VERT_RESULT_BFC0))) {<br>
> + assign_vue_slot(vue_map, VERT_RESULT_COL0);<br>
> + assign_vue_slot(vue_map, VERT_RESULT_BFC0);<br>
> + }<br>
<br>
</div>This looks like you could move the else if () up above and drop the<br>
COL0/BFC0 concerns from the COL1/BFC1 path. (and then I don't have to<br>
think about what can generates COL1/BFC1 and whether the asserts are<br>
valid).<br>
</blockquote></div><br>Yeah, I suspect that some of these asserts are incorrect. I remember thinking they were suspicious when I copied them from brw_vs_alloc_regs() and get_attr_override()--for example, what happens if the client code turns on two-sided color and writes to gl_FrontColorSecondary and gl_BackColorSecondary but not gl_FrontColor and gl_BackColor? Then these assertions would fire. That would be kind of weird, but it shouldn't be illegal.<br>
<br>Thinking about it further, what I would actually prefer to do is to always put front and back colors next to each other in the VUE (at least for GEN6+), regardless of whether we are doing two-sided color. Then the code would look something like this:<br>
<br>if (outputs_written & BITFIELD64_BIT(VERT_RESULT_COL0)<br> assign_vue_slot(vue_map, VERT_RESULT_COL0);<br>if (outputs_written & BITFIELD64_BIT(VERT_RESULT_BFC0)<br> assign_vue_slot(vue_map, VERT_RESULT_BFC0);<br>
if (outputs_written & BITFIELD64_BIT(VERT_RESULT_COL1)<br> assign_vue_slot(vue_map, VERT_RESULT_COL1);<br>if (outputs_written & BITFIELD64_BIT(VERT_RESULT_BFC1)<br> assign_vue_slot(vue_map, VERT_RESULT_BFC1);<br>
<br>Then we would let get_attr_override() decide whether or not to swizzle the colors based on the setting of two_side_color. I think that would address your comment (since it would remove the assertions). It would also have the advantage of making the layout of the VUE easier for humans to comprehend. I'll try doing that as a follow-up patch. (I don't want to do it by altering this patch because in future patches, where I switch the driver over to using the VUE map, I don't want to cause behavioral changes).<br>