summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2020-02-12 17:49:45 -0500
committerMarge Bot <eric+marge@anholt.net>2020-03-11 18:45:28 +0000
commitfb477cc42186d4809b955072a1c2336d64f07944 (patch)
tree8f5f80ee7086e18a46fedd17275538d463b14275
parent70298ec4c0e43a9dcda828e74d65d87dc6e3b9d4 (diff)
mesa: don't unroll glMultiDrawElements with user indices for gallium
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3591> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3591>
-rw-r--r--src/mesa/main/draw.c18
-rw-r--r--src/mesa/main/mtypes.h3
-rw-r--r--src/mesa/state_tracker/st_extensions.c3
3 files changed, 18 insertions, 6 deletions
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index c77bbade008..e856d9c5ef3 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -1216,12 +1216,18 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
}
}
- /* If the index buffer isn't in a VBO, then treating the application's
- * subranges of the index buffer as one large index buffer may lead to
- * us reading unmapped memory.
- */
- if (!_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj))
- fallback = GL_TRUE;
+ if (ctx->Const.MultiDrawWithUserIndices) {
+ /* Check whether prim[i].start would overflow. */
+ if (((max_index_ptr - min_index_ptr) >> ib.index_size_shift) > UINT_MAX)
+ fallback = GL_TRUE;
+ } else {
+ /* If the index buffer isn't in a VBO, then treating the application's
+ * subranges of the index buffer as one large index buffer may lead to
+ * us reading unmapped memory.
+ */
+ if (!_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj))
+ fallback = GL_TRUE;
+ }
if (!fallback) {
struct _mesa_prim *prim;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7396de5b5d0..c7889668f58 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4172,6 +4172,9 @@ struct gl_constants
/** Whether the vertex buffer offset is a signed 32-bit integer. */
bool VertexBufferOffsetIsInt32;
+ /** Whether the driver can handle MultiDrawElements with non-VBO indices. */
+ bool MultiDrawWithUserIndices;
+
/** GL_ARB_gl_spirv */
struct spirv_supported_capabilities SpirVCapabilities;
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 7b44c1b4b50..b26d3904b8f 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -569,6 +569,9 @@ void st_init_limits(struct pipe_screen *screen,
c->VertexBufferOffsetIsInt32 =
screen->get_param(screen, PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET);
+
+ c->MultiDrawWithUserIndices =
+ screen->get_param(screen, PIPE_CAP_DRAW_INFO_START_WITH_USER_INDICES);
}