summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2016-10-20 13:02:22 +0200
committerEmil Velikov <emil.l.velikov@gmail.com>2016-10-27 10:41:13 +0100
commit074ede8d4ff6e4e94b5be550ff38628b21940b2d (patch)
treecf887d1114ec01103855c8a95c19b0b0acc207db /src/mesa
parent497cf4a9d18ed67ee695bd7077d9d6e072fe2eb1 (diff)
downloadexternal_mesa3d-074ede8d4ff6e4e94b5be550ff38628b21940b2d.zip
external_mesa3d-074ede8d4ff6e4e94b5be550ff38628b21940b2d.tar.gz
external_mesa3d-074ede8d4ff6e4e94b5be550ff38628b21940b2d.tar.bz2
st/mesa: cleanup and fix primitive restart for indirect draws
There are three intended functional changes here: 1. OpenGL 4.5 clarifies that primitive restart should only apply with index buffers, so make that change explicit in the indirect draw path. 2. Make PrimitiveRestartFixedIndex work with indirect draws. 3. The change where primitive_restart is only set when the restart index can actually have an effect (based on the size of indices) is also applied for indirect draws. Cc: 13.0 <mesa-stable@lists.freedesktop.org> Reviewed-by: Marek Olšák <marek.olsak@amd.com> (cherry picked from commit 3d6b5dee3a0c9c077d68e5567b95f22b627be07e)
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_draw.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 5dcaff0..e9f25b6 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -127,6 +127,30 @@ setup_index_buffer(struct st_context *st,
/**
+ * Set the restart index.
+ */
+static void
+setup_primitive_restart(struct gl_context *ctx,
+ const struct _mesa_index_buffer *ib,
+ struct pipe_draw_info *info)
+{
+ 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.
+ * Other hardware may also benefit from taking a faster, non-restart path
+ * when possible.
+ */
+ if ((ib->type == GL_UNSIGNED_INT) ||
+ (ib->type == GL_UNSIGNED_SHORT && info->restart_index <= 0xffff) ||
+ (ib->type == GL_UNSIGNED_BYTE && info->restart_index <= 0xff))
+ info->primitive_restart = true;
+ }
+}
+
+
+/**
* Translate OpenGL primtive type (GL_POINTS, GL_TRIANGLE_STRIP, etc) to
* the corresponding Gallium type.
*/
@@ -205,19 +229,7 @@ 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:
*/
- 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;
- }
+ setup_primitive_restart(ctx, ib, &info);
}
else {
/* Transform feedback drawing is always non-indexed. */
@@ -310,6 +322,9 @@ st_indirect_draw_vbo(struct gl_context *ctx,
}
info.indexed = TRUE;
+
+ /* Primitive restart is not handled by the VBO module in this case. */
+ setup_primitive_restart(ctx, ib, &info);
}
info.mode = translate_prim(ctx, mode);
@@ -317,10 +332,6 @@ st_indirect_draw_vbo(struct gl_context *ctx,
info.indirect = st_buffer_object(indirect_data)->buffer;
info.indirect_offset = indirect_offset;
- /* Primitive restart is not handled by the VBO module in this case. */
- info.primitive_restart = ctx->Array._PrimitiveRestart;
- info.restart_index = ctx->Array.RestartIndex;
-
if (ST_DEBUG & DEBUG_DRAW) {
debug_printf("st/draw indirect: mode %s drawcount %d indexed %d\n",
u_prim_name(info.mode),