On 2 September 2011 12:47, Eric Anholt <span dir="ltr">&lt;<a href="mailto:eric@anholt.net">eric@anholt.net</a>&gt;</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 &lt;<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>&gt; wrote:<br>
&gt; Several places in the i965 code make implicit assumptions about the<br>
&gt; structure of data in the VUE (vertex URB entry).  This patch adds a<br>
&gt; function, brw_compute_vue_map(), which computes the structure of the<br>
&gt; VUE explicitly.  Future patches will modify the rest of the driver to<br>
&gt; use the explicitly computed map rather than rely on implicit<br>
&gt; assumptions about it.<br>
&gt; ---<br>
</div><div class="im">&gt; +      if (two_side_color) {<br>
&gt; +         /* front and back colors need to be consecutive */<br>
&gt; +         if ((outputs_written &amp; BITFIELD64_BIT(VERT_RESULT_COL1)) &amp;&amp;<br>
&gt; +             (outputs_written &amp; BITFIELD64_BIT(VERT_RESULT_BFC1))) {<br>
&gt; +            assert(outputs_written &amp; BITFIELD64_BIT(VERT_RESULT_COL0));<br>
&gt; +            assert(outputs_written &amp; BITFIELD64_BIT(VERT_RESULT_BFC0));<br>
&gt; +            assign_vue_slot(vue_map, VERT_RESULT_COL0);<br>
&gt; +            assign_vue_slot(vue_map, VERT_RESULT_BFC0);<br>
&gt; +            assign_vue_slot(vue_map, VERT_RESULT_COL1);<br>
&gt; +            assign_vue_slot(vue_map, VERT_RESULT_BFC1);<br>
&gt; +         } else if ((outputs_written &amp; BITFIELD64_BIT(VERT_RESULT_COL0)) &amp;&amp;<br>
&gt; +                    (outputs_written &amp; BITFIELD64_BIT(VERT_RESULT_BFC0))) {<br>
&gt; +            assign_vue_slot(vue_map, VERT_RESULT_COL0);<br>
&gt; +            assign_vue_slot(vue_map, VERT_RESULT_BFC0);<br>
&gt; +         }<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&#39;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&#39;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 &amp; BITFIELD64_BIT(VERT_RESULT_COL0)<br>    assign_vue_slot(vue_map, VERT_RESULT_COL0);<br>if (outputs_written &amp; BITFIELD64_BIT(VERT_RESULT_BFC0)<br>    assign_vue_slot(vue_map, VERT_RESULT_BFC0);<br>
if (outputs_written &amp; BITFIELD64_BIT(VERT_RESULT_COL1)<br>    assign_vue_slot(vue_map, VERT_RESULT_COL1);<br>if (outputs_written &amp; 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&#39;ll try doing that as a follow-up patch.  (I don&#39;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&#39;t want to cause behavioral changes).<br>