<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Dec 19, 2016 13:27, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">BaseVertex, BaseInstance, DrawID, and some edge flag conditions need<br>
vertex buffer and elements structs. We can't bail early in this case.<br>
<br>
Gen4-7 already do this properly. Gen8+ did not.<br>
<br>
Thanks to Ilia Mirkin for helping track this down.<br>
<br>
Cc: <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.<wbr>org</a><br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=99144
Reported-by" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=99144<br>
Reported-by</a>: Pierre-Eric Pelloux-Prayer <<a href="mailto:pelloux@gmail.com">pelloux@gmail.com</a>><br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/<wbr>gen8_draw_upload.c | 34 ++++++++++++++--------------<br>
1 file changed, 17 insertions(+), 17 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>gen8_draw_upload.c b/src/mesa/drivers/dri/i965/<wbr>gen8_draw_upload.c<br>
index 69ba8e9..3177f9a 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>gen8_draw_upload.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>gen8_draw_upload.c<br>
@@ -110,6 +110,22 @@ gen8_emit_vertices(struct brw_context *brw)<br>
ADVANCE_BATCH();<br>
}<br>
<br>
+ /* Normally we don't need an element for the SGVS attribute because the<br>
+ * 3DSTATE_VF_SGVS instruction lets you store the generated attribute in an<br>
+ * element that is past the list in 3DSTATE_VERTEX_ELEMENTS. However if<br>
+ * we're using draw parameters then we need an element for the those<br>
+ * values. Additionally if there is an edge flag element then the SGVS<br>
+ * can't be inserted past that so we need a dummy element to ensure that<br>
+ * the edge flag is the last one.<br>
+ */<br>
+ const bool needs_sgvs_element = (vs_prog_data->uses_basevertex ||<br>
+ vs_prog_data->uses_<wbr>baseinstance ||<br>
+ ((vs_prog_data->uses_<wbr>instanceid ||<br>
+ vs_prog_data->uses_vertexid) &&<br>
+ uses_edge_flag));<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Out of curiosity, why are we trying so hard to avoid an extra element?</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ const unsigned nr_elements =<br>
+ brw->vb.nr_enabled + needs_sgvs_element + vs_prog_data->uses_drawid;<br>
+<br>
/* If the VS doesn't read any inputs (calculating vertex position from<br>
* a state variable for some reason, for example), emit a single pad<br>
* VERTEX_ELEMENT struct and bail.<br>
@@ -117,7 +133,7 @@ gen8_emit_vertices(struct brw_context *brw)<br>
* The stale VB state stays in place, but they don't do anything unless<br>
* a VE loads from them.<br>
*/<br>
- if (brw->vb.nr_enabled == 0) {<br>
+ if (nr_elements == 0) {<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Seems reasonable.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
BEGIN_BATCH(3);<br>
OUT_BATCH((_3DSTATE_VERTEX_<wbr>ELEMENTS << 16) | (3 - 2));<br>
OUT_BATCH((0 << GEN6_VE0_INDEX_SHIFT) |<br>
@@ -172,22 +188,6 @@ gen8_emit_vertices(struct brw_context *brw)<br>
ADVANCE_BATCH();<br>
}<br>
<br>
- /* Normally we don't need an element for the SGVS attribute because the<br>
- * 3DSTATE_VF_SGVS instruction lets you store the generated attribute in an<br>
- * element that is past the list in 3DSTATE_VERTEX_ELEMENTS. However if<br>
- * we're using draw parameters then we need an element for the those<br>
- * values. Additionally if there is an edge flag element then the SGVS<br>
- * can't be inserted past that so we need a dummy element to ensure that<br>
- * the edge flag is the last one.<br>
- */<br>
- const bool needs_sgvs_element = (vs_prog_data->uses_basevertex ||<br>
- vs_prog_data->uses_<wbr>baseinstance ||<br>
- ((vs_prog_data->uses_<wbr>instanceid ||<br>
- vs_prog_data->uses_vertexid) &&<br>
- uses_edge_flag));<br>
- const unsigned nr_elements =<br>
- brw->vb.nr_enabled + needs_sgvs_element + vs_prog_data->uses_drawid;<br>
-<br>
/* The hardware allows one more VERTEX_ELEMENTS than VERTEX_BUFFERS,<br>
* presumably for VertexID/InstanceID.<br>
*/<br>
<font color="#888888">--<br>
2.10.2<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></blockquote></div><br></div></div></div>