Module: Mesa Branch: main Commit: aca09e4f71937f602b52c3ad42f2afc7fa91a8b2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aca09e4f71937f602b52c3ad42f2afc7fa91a8b2
Author: Marek Olšák <[email protected]> Date: Sun Dec 18 15:56:50 2022 -0500 glthread: do vertex uploads if an index buffer is present for MultiDrawElements Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20824> --- src/mesa/main/glthread_draw.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/mesa/main/glthread_draw.c b/src/mesa/main/glthread_draw.c index 93053175ed0..006663a9ca6 100644 --- a/src/mesa/main/glthread_draw.c +++ b/src/mesa/main/glthread_draw.c @@ -1178,14 +1178,8 @@ _mesa_marshal_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, bool need_index_bounds = user_buffer_mask & ~vao->NonZeroDivisorMask; - /* If the draw count is negative, the queue can't be used. - * - * Sync if indices come from a buffer and vertices come from memory - * and index bounds are not valid. We would have to map the indices - * to compute the index bounds, and for that we would have to sync anyway. - */ - if (!ctx->GLThread.SupportsBufferUploads || draw_count < 0 || - (need_index_bounds && !has_user_indices)) + /* If the draw count is negative, the queue can't be used. */ + if (!ctx->GLThread.SupportsBufferUploads || draw_count < 0) goto sync; unsigned index_size = get_index_size(type); @@ -1198,6 +1192,8 @@ _mesa_marshal_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, * uploaded. */ if (need_index_bounds) { + bool synced = false; + /* Compute the index bounds. */ for (unsigned i = 0; i < draw_count; i++) { GLsizei vertex_count = count[i]; @@ -1212,10 +1208,23 @@ _mesa_marshal_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, continue; unsigned min = ~0, max = 0; - vbo_get_minmax_index_mapped(vertex_count, index_size, - ctx->GLThread._RestartIndex[index_size - 1], - ctx->GLThread._PrimitiveRestart, indices[i], - &min, &max); + if (has_user_indices) { + vbo_get_minmax_index_mapped(vertex_count, index_size, + ctx->GLThread._RestartIndex[index_size - 1], + ctx->GLThread._PrimitiveRestart, indices[i], + &min, &max); + } else { + if (!synced) { + _mesa_glthread_finish_before(ctx, "MultiDrawElements - need index bounds"); + synced = true; + } + vbo_get_minmax_index(ctx, ctx->Array.VAO->IndexBufferObj, + NULL, (intptr_t)indices[i], vertex_count, + index_size, ctx->GLThread._PrimitiveRestart, + ctx->GLThread._RestartIndex[index_size - 1], + &min, &max); + } + if (basevertex) { min += basevertex[i]; max += basevertex[i]; @@ -1287,7 +1296,7 @@ _mesa_marshal_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, return; sync: - _mesa_glthread_finish_before(ctx, "DrawElements"); + _mesa_glthread_finish_before(ctx, "MultiDrawElements"); if (basevertex) { CALL_MultiDrawElementsBaseVertex(ctx->CurrentServerDispatch,
