glthread: add no_error variants of glDrawArrays*

The main motivation is that no_error allows us to drop count==0 draws
at the beginning of the marshal function, instead of forwarding them
to the frontend thread. Such draws are plentiful with Viewperf.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27350>
This commit is contained in:
Marek Olšák
2024-01-07 13:43:26 -05:00
committed by Marge Bot
parent 138804fdfc
commit acfefc1f14
4 changed files with 42 additions and 13 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
<category name="GL_ARB_base_instance" number="107">
<function name="DrawArraysInstancedBaseInstance" marshal="custom" exec="dlist"
marshal_struct="public">
marshal_struct="public" marshal_no_error="true">
<param name="mode" type="GLenum"/>
<param name="first" type="GLint"/>
<param name="count" type="GLsizei"/>
+2 -1
View File
@@ -8,7 +8,8 @@
<category name="GL_ARB_draw_instanced" number="44">
<function name="DrawArraysInstanced" marshal="custom" exec="dlist" es2="2.0">
<function name="DrawArraysInstanced" marshal="custom" exec="dlist" es2="2.0"
marshal_no_error="true">
<param name="mode" type="GLenum"/>
<param name="first" type="GLint"/>
<param name="count" type="GLsizei"/>
+1 -1
View File
@@ -3211,7 +3211,7 @@
</function>
<function name="DrawArrays" es1="1.0" es2="2.0" marshal="custom" exec="dlist"
marshal_struct="public">
marshal_struct="public" marshal_no_error="true">
<param name="mode" type="GLenum"/>
<param name="first" type="GLint"/>
<param name="count" type="GLsizei"/>
+38 -10
View File
@@ -406,10 +406,16 @@ get_user_buffer_mask(struct gl_context *ctx)
static ALWAYS_INLINE void
draw_arrays(GLuint drawid, GLenum mode, GLint first, GLsizei count,
GLsizei instance_count, GLuint baseinstance,
bool compiled_into_dlist)
bool compiled_into_dlist, bool no_error)
{
GET_CURRENT_CONTEXT(ctx);
/* The main benefit of no_error is that we can discard no-op draws
* immediately.
*/
if (no_error && (count <= 0 || instance_count <= 0))
return;
if (unlikely(compiled_into_dlist && ctx->GLThread.ListMode)) {
_mesa_glthread_finish_before(ctx, "DrawArrays");
/* Use the function that's compiled into a display list. */
@@ -425,11 +431,12 @@ draw_arrays(GLuint drawid, GLenum mode, GLint first, GLsizei count,
* This is also an error path. Zero counts should still call the driver
* for possible GL errors.
*/
if (!user_buffer_mask || count <= 0 || instance_count <= 0 ||
/* This will just generate GL_INVALID_OPERATION, as it should. */
ctx->GLThread.inside_begin_end ||
ctx->Dispatch.Current == ctx->Dispatch.ContextLost ||
ctx->GLThread.ListMode) {
if (!user_buffer_mask ||
(!no_error &&
(count <= 0 || instance_count <= 0 || /* GL_INVALID_VALUE / no-op */
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 =
@@ -1269,7 +1276,7 @@ lower_draw_arrays_indirect(struct gl_context *ctx, GLenum mode,
params[i * stride / 4 + 2],
params[i * stride / 4 + 0],
params[i * stride / 4 + 1],
params[i * stride / 4 + 3], false);
params[i * stride / 4 + 3], false, false);
}
unmap_draw_indirect_params(ctx);
@@ -1600,14 +1607,27 @@ _mesa_marshal_MultiDrawElementsIndirectCountARB(GLenum mode, GLenum type,
void GLAPIENTRY
_mesa_marshal_DrawArrays(GLenum mode, GLint first, GLsizei count)
{
draw_arrays(0, mode, first, count, 1, 0, true);
draw_arrays(0, mode, first, count, 1, 0, true, false);
}
void GLAPIENTRY
_mesa_marshal_DrawArrays_no_error(GLenum mode, GLint first, GLsizei count)
{
draw_arrays(0, mode, first, count, 1, 0, true, true);
}
void GLAPIENTRY
_mesa_marshal_DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
GLsizei instance_count)
{
draw_arrays(0, mode, first, count, instance_count, 0, false);
draw_arrays(0, mode, first, count, instance_count, 0, false, false);
}
void GLAPIENTRY
_mesa_marshal_DrawArraysInstanced_no_error(GLenum mode, GLint first, GLsizei count,
GLsizei instance_count)
{
draw_arrays(0, mode, first, count, instance_count, 0, false, true);
}
void GLAPIENTRY
@@ -1615,7 +1635,15 @@ _mesa_marshal_DrawArraysInstancedBaseInstance(GLenum mode, GLint first,
GLsizei count, GLsizei instance_count,
GLuint baseinstance)
{
draw_arrays(0, mode, first, count, instance_count, baseinstance, false);
draw_arrays(0, mode, first, count, instance_count, baseinstance, false, false);
}
void GLAPIENTRY
_mesa_marshal_DrawArraysInstancedBaseInstance_no_error(GLenum mode, GLint first,
GLsizei count, GLsizei instance_count,
GLuint baseinstance)
{
draw_arrays(0, mode, first, count, instance_count, baseinstance, false, true);
}
void GLAPIENTRY