mesa: don't unroll glMultiDrawElements with user indices for gallium
authorMarek Olšák <marek.olsak@amd.com>
Wed, 12 Feb 2020 22:49:45 +0000 (17:49 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 11 Mar 2020 18:45:28 +0000 (18:45 +0000)
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>

src/mesa/main/draw.c
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_extensions.c

index c77bbade008678846a321dce2c3fb4543c568d9c..e856d9c5ef36f30ae1ac81440b011d733b5f0805 100644 (file)
@@ -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;
index 7396de5b5d003e606152f5ca31284d2f6a251e2f..c7889668f585f736e4419de0c10db4874f7ced75 100644 (file)
@@ -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;
 
index 7b44c1b4b50446ea2ec1ad8829bb157c102fd8f3..b26d3904b8ff08147511af8d0b15643fa2a83528 100644 (file)
@@ -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);
 }