Module: Mesa
Branch: 13.0
Commit: ba6efd48c3ab36ea532d0b1b2f5493b6d9b1937b
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ba6efd48c3ab36ea532d0b1b2f5493b6d9b1937b

Author: Nicolai Hähnle <nicolai.haeh...@amd.com>
Date:   Wed Oct 19 18:14:48 2016 +0200

st/mesa: only set primitive_restart when the restart index is in range

Even when enabled, primitive restart has no effect when the restart index
is larger than the representable values in the index buffer.

Fixes GL45-CTS.gtf31.GL3Tests.primitive_restart.primitive_restart_upconvert
for radeonsi VI.

v2: add an explanatory comment

Cc: "12.0 13.0" <mesa-sta...@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.ol...@amd.com> (v1)
(cherry picked from commit bfa50f88cea2ba9f4dc4b825828d2c8f02866fc3)

---

 src/mesa/state_tracker/st_draw.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index f4af23d..5dcaff0 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -205,8 +205,19 @@ st_draw_vbo(struct gl_context *ctx,
       /* The VBO module handles restart for the non-indexed GLDrawArrays
        * so we only set these fields for indexed drawing:
        */
-      info.primitive_restart = ctx->Array._PrimitiveRestart;
-      info.restart_index = _mesa_primitive_restart_index(ctx, ib->type);
+      if (ctx->Array._PrimitiveRestart) {
+         info.restart_index = _mesa_primitive_restart_index(ctx, ib->type);
+
+         /* Enable primitive restart only when the restart index can have an
+          * effect. This is required for correctness in radeonsi VI support,
+          * though other hardware may also benefit from taking a faster,
+          * non-restart path when possible.
+          */
+         if ((ibuffer.index_size >= 4) ||
+             (ibuffer.index_size >= 2 && info.restart_index <= 0xffff) ||
+             (info.restart_index <= 0xff))
+            info.primitive_restart = true;
+      }
    }
    else {
       /* Transform feedback drawing is always non-indexed. */

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to