[Mesa-dev] [PATCH] st/mesa: only set primitive_restart when the restart index is in range

Nicolai Hähnle nhaehnle at gmail.com
Wed Oct 19 18:39:28 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

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.

Cc: mesa-stable at lists.freedesktop.org
---
 src/mesa/state_tracker/st_draw.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index f4af23d..ac00a21 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -198,22 +198,28 @@ st_draw_vbo(struct gl_context *ctx,
 
       info.indexed = TRUE;
       if (min_index != ~0U && max_index != ~0U) {
          info.min_index = min_index;
          info.max_index = max_index;
       }
 
       /* 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);
+
+         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. */
       /* Set info.count_from_stream_output. */
       if (tfb_vertcount) {
          if (!st_transform_feedback_draw_init(tfb_vertcount, stream, &info))
             return;
       }
    }
 
-- 
2.7.4



More information about the mesa-dev mailing list