<div dir="ltr">On 24 May 2013 12:23, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.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">
<div class="im">On 05/23/2013 03:46 PM, Kenneth Graunke wrote:<br>
<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>
</blockquote>
<br></div>
Which documentation is this? The only types that are valid for index buffers are unsigned, so what does "possibly-sign-extended" even mean?<div class="im"><br></div></blockquote><div><br></div><div>This is from the Haswell bspec. I have never understood what they mean by "possibly-sign-extended" either.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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>
</blockquote>
<br></div>
For GL_PRIMITIVE_RESTART_FIXED_<u></u>INDEX (ES and desktop 4.something), where the setting of the restart value is out of application control, this is absolutely correct. The OpenGL 4.3 spec says:<br>
<br>
"Primitive restart can also be enabled or disabled with a target<br>
of PRIMITIVE_RESTART_FIXED_INDEX. In this case, the primitive<br>
restart index is equal to 2^N − 1, where N is 8, 16 or 32 if the<br>
type is UNSIGNED_BYTE, UNSIGNED_SHORT, or UNSIGNED_INT,<br>
respectively, and the index value specified by<br>
PrimitiveRestartIndex is ignored."<br>
<br>
For GL_PRIMITIVE_RESTART, I'm not so sure. I couldn't find anything conclusive any of the specs. The only thing I found was a hint in the NV_primitive_restart extension spec:<br>
<br>
* What should the default primitive restart index be?<br>
<br>
RESOLVED: Zero. It's tough to pick another number that is<br>
meaningful for all three element data types. In practice, apps<br>
are likely to set it to 0xFFFF or 0xFFFFFFFF.<br>
<br>
You can infer from this that applications are expected to set 0xFFFF for GL_UNSIGNED_SHORT and 0xFFFFFFFF for GL_UNSIGNED_LONG. Experimentation is the only way to know for sure. :(<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Fixes sporadic failures in the ES 3 instanced_arrays_primitive_<u></u>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" target="_blank">idr@freedesktop.org</a><br>
Cc: Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>><br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_<u></u>primitive_restart.c | 27 ++++++++++++++++-------<br>
1 file changed, 19 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_primitive_restart.c b/src/mesa/drivers/dri/i965/<u></u>brw_primitive_restart.c<br>
index f824915..cf4a1ea 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_primitive_restart.c<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_primitive_restart.c<br>
@@ -183,19 +183,30 @@ haswell_upload_cut_index(<u></u>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._<u></u>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>
+ 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>
<br>
</blockquote>
<br></div></div><div class="HOEnZb"><div class="h5">
______________________________<u></u>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>