Module: Mesa Branch: main Commit: 3a74cdcd9139b048307abb17b08f56afa1e502b9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a74cdcd9139b048307abb17b08f56afa1e502b9
Author: Marek Olšák <[email protected]> Date: Thu Nov 30 18:20:57 2023 -0500 glthread: pass struct marshal_cmd_DrawElementsUserBuf into Draw directly Pass the whole structure directly instead of as separate parameters. Reviewed-by: Timothy Arceri <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26548> --- src/mapi/glapi/gen/gl_API.xml | 9 +-------- src/mesa/main/draw.c | 26 ++++++++++++++++++-------- src/mesa/main/glthread_draw.c | 36 +++--------------------------------- src/mesa/main/glthread_marshal.h | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 49 deletions(-) diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index bc59ddc759a..874ec8dd552 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -12936,14 +12936,7 @@ </function> <function name="DrawElementsUserBuf" es1="1.0" es2="2.0" marshal="custom"> - <param name="indexBuf" type="GLintptr"/> <!-- "struct gl_buffer_object *" really --> - <param name="mode" type="GLenum"/> - <param name="count" type="GLsizei"/> - <param name="type" type="GLenum"/> - <param name="indices" type="const GLvoid *"/> - <param name="instancecount" type="GLsizei"/> - <param name="basevertex" type="GLint"/> - <param name="baseinstance" type="GLuint"/> + <param name="cmd" type="const GLvoid *"/> <!-- struct marshal_cmd_DrawElementsUserBuf --> </function> <function name="MultiDrawArraysUserBuf" es1="1.0" es2="2.0" marshal="custom"> diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c index 8519bd55244..0004cff184d 100644 --- a/src/mesa/main/draw.c +++ b/src/mesa/main/draw.c @@ -42,6 +42,7 @@ #include "transformfeedback.h" #include "pipe/p_state.h" #include "api_exec_decl.h" +#include "glthread_marshal.h" #include "state_tracker/st_context.h" #include "state_tracker/st_draw.h" @@ -1983,10 +1984,7 @@ _mesa_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode, * GL_ELEMENT_ARRAY_BUFFER if indexBuf != NULL. */ void GLAPIENTRY -_mesa_DrawElementsUserBuf(GLintptr indexBuf, GLenum mode, - GLsizei count, GLenum type, - const GLvoid *indices, GLsizei numInstances, - GLint basevertex, GLuint baseInstance) +_mesa_DrawElementsUserBuf(const GLvoid *ptr) { GET_CURRENT_CONTEXT(ctx); FLUSH_FOR_DRAW(ctx); @@ -1996,19 +1994,31 @@ _mesa_DrawElementsUserBuf(GLintptr indexBuf, GLenum mode, if (ctx->NewState) _mesa_update_state(ctx); + const struct marshal_cmd_DrawElementsUserBuf *cmd = + (const struct marshal_cmd_DrawElementsUserBuf *)ptr; + const GLenum mode = cmd->mode; + const GLsizei count = cmd->count; + const GLenum type = cmd->type; + const GLsizei instance_count = cmd->instance_count; + if (!_mesa_is_no_error_enabled(ctx) && !_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, - numInstances)) + instance_count)) return; struct gl_buffer_object *index_bo = - indexBuf ? (struct gl_buffer_object*)indexBuf : - ctx->Array.VAO->IndexBufferObj; + cmd->index_buffer ? cmd->index_buffer : ctx->Array.VAO->IndexBufferObj; + + const GLvoid *indices = cmd->indices; + const GLint basevertex = cmd->basevertex; + const GLuint baseinstance = cmd->baseinstance; + ctx->DrawID = cmd->drawid; _mesa_validated_drawrangeelements(ctx, index_bo, mode, false, 0, ~0, count, type, indices, basevertex, - numInstances, baseInstance); + instance_count, baseinstance); + ctx->DrawID = 0; } diff --git a/src/mesa/main/glthread_draw.c b/src/mesa/main/glthread_draw.c index 746aa6860d9..e362b428745 100644 --- a/src/mesa/main/glthread_draw.c +++ b/src/mesa/main/glthread_draw.c @@ -707,21 +707,6 @@ _mesa_unmarshal_DrawElementsInstancedBaseVertexBaseInstanceDrawID(struct gl_cont return cmd_size; } -struct marshal_cmd_DrawElementsUserBuf -{ - struct marshal_cmd_base cmd_base; - GLenum16 mode; - GLenum16 type; - GLsizei count; - GLsizei instance_count; - GLint basevertex; - GLuint baseinstance; - GLuint drawid; - GLuint user_buffer_mask; - const GLvoid *indices; - struct gl_buffer_object *index_buffer; -}; - uint32_t _mesa_unmarshal_DrawElementsUserBuf(struct gl_context *ctx, const struct marshal_cmd_DrawElementsUserBuf *restrict cmd) @@ -735,21 +720,9 @@ _mesa_unmarshal_DrawElementsUserBuf(struct gl_context *ctx, _mesa_InternalBindVertexBuffers(ctx, buffers, user_buffer_mask); /* Draw. */ - const GLenum mode = cmd->mode; - const GLsizei count = cmd->count; - const GLenum type = cmd->type; - const GLvoid *indices = cmd->indices; - const GLsizei instance_count = cmd->instance_count; - const GLint basevertex = cmd->basevertex; - const GLuint baseinstance = cmd->baseinstance; - struct gl_buffer_object *index_buffer = cmd->index_buffer; + CALL_DrawElementsUserBuf(ctx->Dispatch.Current, (cmd)); - ctx->DrawID = cmd->drawid; - CALL_DrawElementsUserBuf(ctx->Dispatch.Current, - ((GLintptr)index_buffer, mode, count, type, - indices, instance_count, basevertex, - baseinstance)); - ctx->DrawID = 0; + struct gl_buffer_object *index_buffer = cmd->index_buffer; _mesa_reference_buffer_object(ctx, &index_buffer, NULL); return cmd->cmd_base.cmd_size; } @@ -1803,10 +1776,7 @@ _mesa_marshal_DrawArraysUserBuf(void) } void GLAPIENTRY -_mesa_marshal_DrawElementsUserBuf(GLintptr indexBuf, GLenum mode, - GLsizei count, GLenum type, - const GLvoid *indices, GLsizei numInstances, - GLint basevertex, GLuint baseInstance) +_mesa_marshal_DrawElementsUserBuf(const GLvoid *cmd) { unreachable("should never end up here"); } diff --git a/src/mesa/main/glthread_marshal.h b/src/mesa/main/glthread_marshal.h index 512800020f6..3560754d39d 100644 --- a/src/mesa/main/glthread_marshal.h +++ b/src/mesa/main/glthread_marshal.h @@ -55,6 +55,21 @@ typedef uint32_t (*_mesa_unmarshal_func)(struct gl_context *ctx, const void *restrict cmd); extern const _mesa_unmarshal_func _mesa_unmarshal_dispatch[NUM_DISPATCH_CMD]; +struct marshal_cmd_DrawElementsUserBuf +{ + struct marshal_cmd_base cmd_base; + GLenum16 mode; + GLenum16 type; + GLsizei count; + GLsizei instance_count; + GLint basevertex; + GLuint baseinstance; + GLuint drawid; + GLuint user_buffer_mask; + const GLvoid *indices; + struct gl_buffer_object *index_buffer; +}; + static inline void * _mesa_glthread_allocate_command(struct gl_context *ctx, uint16_t cmd_id,
