summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2024-01-07 23:34:07 -0500
committerMarge Bot <emma+marge@anholt.net>2024-02-23 18:03:58 +0000
commit12754aec1a2a6b5a99075b2c37159d62a6b7260f (patch)
treeb72625ad260dd5a7e74dfa73d35c2e1ca91cb480
parent5e5d91671e03bcf14133dcd4ff79b376eb70ecc9 (diff)
glthread: rewrite glDrawArrays call packing
Since changing 1 field to 8 bits and the removal of cmd_size, call sizes have decreased, so we have 4 unused bytes in 2 DrawArrays structures So far we use: - DrawArrays - DrawArraysInstancedBaseInstance - DrawArraysInstancedBaseInstanceDrawID Change them to these by either removing 4 more bytes or adding 4 bytes, so that we don't waste space, which drops the number of used calls by 1: - DrawArraysInstanced - DrawArraysInstancedBaseInstanceDrawID Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27350>
-rw-r--r--src/mapi/glapi/gen/ARB_base_instance.xml2
-rw-r--r--src/mapi/glapi/gen/ARB_draw_instanced.xml2
-rw-r--r--src/mapi/glapi/gen/gl_API.xml2
-rw-r--r--src/mesa/main/glthread_draw.c57
4 files changed, 23 insertions, 40 deletions
diff --git a/src/mapi/glapi/gen/ARB_base_instance.xml b/src/mapi/glapi/gen/ARB_base_instance.xml
index 7e8ec3b2ecf..53774731daf 100644
--- a/src/mapi/glapi/gen/ARB_base_instance.xml
+++ b/src/mapi/glapi/gen/ARB_base_instance.xml
@@ -9,7 +9,7 @@
<category name="GL_ARB_base_instance" number="107">
<function name="DrawArraysInstancedBaseInstance" marshal="custom" exec="dlist"
- marshal_struct="public" marshal_no_error="true">
+ marshal_no_error="true">
<param name="mode" type="GLenum"/>
<param name="first" type="GLint"/>
<param name="count" type="GLsizei"/>
diff --git a/src/mapi/glapi/gen/ARB_draw_instanced.xml b/src/mapi/glapi/gen/ARB_draw_instanced.xml
index d43f1039798..0d52295d378 100644
--- a/src/mapi/glapi/gen/ARB_draw_instanced.xml
+++ b/src/mapi/glapi/gen/ARB_draw_instanced.xml
@@ -9,7 +9,7 @@
<category name="GL_ARB_draw_instanced" number="44">
<function name="DrawArraysInstanced" marshal="custom" exec="dlist" es2="2.0"
- marshal_no_error="true">
+ marshal_no_error="true" marshal_struct="public">
<param name="mode" type="GLenum"/>
<param name="first" type="GLint"/>
<param name="count" type="GLsizei"/>
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 73b3240be7a..b2e91ff7b7f 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -3211,7 +3211,7 @@
</function>
<function name="DrawArrays" es1="1.0" es2="2.0" marshal="custom" exec="dlist"
- marshal_struct="public" marshal_no_error="true">
+ marshal_no_error="true">
<param name="mode" type="GLenum"/>
<param name="first" type="GLint"/>
<param name="count" type="GLsizei"/>
diff --git a/src/mesa/main/glthread_draw.c b/src/mesa/main/glthread_draw.c
index 2bbbeec5774..7c5a48d6f9a 100644
--- a/src/mesa/main/glthread_draw.c
+++ b/src/mesa/main/glthread_draw.c
@@ -280,33 +280,17 @@ upload_vertices(struct gl_context *ctx, unsigned user_buffer_mask,
return true;
}
-/* DrawArrays without user buffers. */
+/* DrawArraysInstanced without user buffers. */
uint32_t
-_mesa_unmarshal_DrawArrays(struct gl_context *ctx,
- const struct marshal_cmd_DrawArrays *restrict cmd)
-{
- const GLenum mode = cmd->mode;
- const GLint first = cmd->first;
- const GLsizei count = cmd->count;
-
- CALL_DrawArrays(ctx->Dispatch.Current, (mode, first, count));
- return align(sizeof(*cmd), 8) / 8;
-}
-
-/* DrawArraysInstancedBaseInstance without user buffers. */
-uint32_t
-_mesa_unmarshal_DrawArraysInstancedBaseInstance(struct gl_context *ctx,
- const struct marshal_cmd_DrawArraysInstancedBaseInstance *restrict cmd)
+_mesa_unmarshal_DrawArraysInstanced(struct gl_context *ctx,
+ const struct marshal_cmd_DrawArraysInstanced *restrict cmd)
{
const GLenum mode = cmd->mode;
const GLint first = cmd->first;
const GLsizei count = cmd->count;
- const GLsizei instance_count = cmd->instance_count;
- const GLuint baseinstance = cmd->baseinstance;
+ const GLsizei instance_count = cmd->primcount;
- CALL_DrawArraysInstancedBaseInstance(ctx->Dispatch.Current,
- (mode, first, count, instance_count,
- baseinstance));
+ CALL_DrawArraysInstanced(ctx->Dispatch.Current, (mode, first, count, instance_count));
return align(sizeof(*cmd), 8) / 8;
}
@@ -430,24 +414,15 @@ draw_arrays(GLuint drawid, GLenum mode, GLint first, GLsizei count,
ctx->GLThread.inside_begin_end || /* GL_INVALID_OPERATION */
ctx->Dispatch.Current == ctx->Dispatch.ContextLost || /* GL_INVALID_OPERATION */
ctx->GLThread.ListMode))) { /* GL_INVALID_OPERATION */
- if (instance_count == 1 && baseinstance == 0 && drawid == 0) {
- int cmd_size = sizeof(struct marshal_cmd_DrawArrays);
- struct marshal_cmd_DrawArrays *cmd =
- _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_DrawArrays, cmd_size);
-
- cmd->mode = MIN2(mode, 0xff); /* clamped to 0xff (invalid enum) */
- cmd->first = first;
- cmd->count = count;
- } else if (drawid == 0) {
- int cmd_size = sizeof(struct marshal_cmd_DrawArraysInstancedBaseInstance);
- struct marshal_cmd_DrawArraysInstancedBaseInstance *cmd =
- _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_DrawArraysInstancedBaseInstance, cmd_size);
+ if (baseinstance == 0 && drawid == 0) {
+ int cmd_size = sizeof(struct marshal_cmd_DrawArraysInstanced);
+ struct marshal_cmd_DrawArraysInstanced *cmd =
+ _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_DrawArraysInstanced, cmd_size);
cmd->mode = MIN2(mode, 0xff); /* clamped to 0xff (invalid enum) */
cmd->first = first;
cmd->count = count;
- cmd->instance_count = instance_count;
- cmd->baseinstance = baseinstance;
+ cmd->primcount = instance_count;
} else {
int cmd_size = sizeof(struct marshal_cmd_DrawArraysInstancedBaseInstanceDrawID);
struct marshal_cmd_DrawArraysInstancedBaseInstanceDrawID *cmd =
@@ -1749,8 +1724,16 @@ _mesa_marshal_MultiDrawElements(GLenum mode, const GLsizei *count,
}
uint32_t
-_mesa_unmarshal_DrawArraysInstanced(struct gl_context *ctx,
- const struct marshal_cmd_DrawArraysInstanced *restrict cmd)
+_mesa_unmarshal_DrawArrays(struct gl_context *ctx,
+ const struct marshal_cmd_DrawArrays *restrict cmd)
+{
+ unreachable("should never end up here");
+ return 0;
+}
+
+uint32_t
+_mesa_unmarshal_DrawArraysInstancedBaseInstance(struct gl_context *ctx,
+ const struct marshal_cmd_DrawArraysInstancedBaseInstance *restrict cmd)
{
unreachable("should never end up here");
return 0;