<div dir="ltr">On 23 May 2013 15:46, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">According to the documentation: "The Cut Index is compared to the<br>
fetched (and possibly-sign-extended) vertex index, and if these values<br>
are equal, the current primitive topology is terminated. Note that,<br>
for index buffers <32bpp, it is possible to set the Cut Index to a<br>
(large) value that will never match a sign-extended vertex index."<br>
<br>
This suggests that we should not set the value to 0xFFFFFFFF for<br>
unsigned byte or short index buffers, but rather 0xFF or 0xFFFF.<br>
<br>
Fixes sporadic failures in the ES 3 instanced_arrays_primitive_restart<br>
conformance test when run in combination with other tests. No Piglit<br>
regressions.<br>
<br>
Cc: Ian Romanick <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a><br>
Cc: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@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/brw_primitive_restart.c | 27 ++++++++++++++++-------<br>
1 file changed, 19 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_primitive_restart.c b/src/mesa/drivers/dri/i965/brw_primitive_restart.c<br>
index f824915..cf4a1ea 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_primitive_restart.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_primitive_restart.c<br>
@@ -183,19 +183,30 @@ haswell_upload_cut_index(struct brw_context *brw)<br>
if (!intel->is_haswell)<br>
return;<br>
<br>
- const unsigned cut_index_setting =<br>
- ctx->Array._PrimitiveRestart ? HSW_CUT_INDEX_ENABLE : 0;<br>
-<br>
- BEGIN_BATCH(2);<br>
- OUT_BATCH(_3DSTATE_VF << 16 | cut_index_setting | (2 - 2));<br>
- OUT_BATCH(ctx->Array._RestartIndex);<br>
- ADVANCE_BATCH();<br>
+ if (ctx->Array._PrimitiveRestart) {<br>
+ int cut_index = ctx->Array._RestartIndex;<br>
+<br>
+ if (brw->ib.type == GL_UNSIGNED_BYTE)<br></blockquote><div><br></div><div>Can we put a "/* BRW_NEW_INDEX_BUFFER */" comment above this line? With that, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ cut_index &= 0xff;<br>
+ else if (brw->ib.type == GL_UNSIGNED_SHORT)<br>
+ cut_index &= 0xffff;<br>
+<br>
+ BEGIN_BATCH(2);<br>
+ OUT_BATCH(_3DSTATE_VF << 16 | HSW_CUT_INDEX_ENABLE | (2 - 2));<br>
+ OUT_BATCH(cut_index);<br>
+ ADVANCE_BATCH();<br>
+ } else {<br>
+ BEGIN_BATCH(2);<br>
+ OUT_BATCH(_3DSTATE_VF << 16 | (2 - 2));<br>
+ OUT_BATCH(0);<br>
+ ADVANCE_BATCH();<br>
+ }<br>
}<br>
<br>
const struct brw_tracked_state haswell_cut_index = {<br>
.dirty = {<br>
.mesa = _NEW_TRANSFORM,<br>
- .brw = 0,<br>
+ .brw = BRW_NEW_INDEX_BUFFER,<br>
.cache = 0,<br>
},<br>
.emit = haswell_upload_cut_index,<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.2.2<br>
<br>
</font></span></blockquote></div><br></div></div>