[Mesa-dev] [PATCH V3] mesa: disable glthread when DEBUG_OUTPUT_SYNCHRONOUS is enabled
Nicolai Hähnle
nhaehnle at gmail.com
Sat Apr 1 07:07:03 UTC 2017
On 31.03.2017 10:28, Timothy Arceri wrote:
> We could re-enable it also but I haven't tested that yet, and I'm
> not sure we care much anyway.
>
> V2: don't disable it from with the call itself. We need a custom
> marshalling function or we get stuck waiting for thread to
> finish.
>
> V3: tidy up redundant code copied from generated verion.
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
> ---
> src/mapi/glapi/gen/gl_API.xml | 2 +-
> src/mesa/main/marshal.c | 37 +++++++++++++++++++++++++++++++++++++
> src/mesa/main/marshal.h | 8 ++++++++
> 3 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
> index dfaeaaf..148387e 100644
> --- a/src/mapi/glapi/gen/gl_API.xml
> +++ b/src/mapi/glapi/gen/gl_API.xml
> @@ -2354,21 +2354,21 @@
> <param name="op" type="GLenum"/>
> <param name="value" type="GLfloat"/>
> <glx rop="137"/>
> </function>
>
> <function name="Disable" es1="1.0" es2="2.0">
> <param name="cap" type="GLenum"/>
> <glx rop="138" handcode="client"/>
> </function>
>
> - <function name="Enable" es1="1.0" es2="2.0">
> + <function name="Enable" es1="1.0" es2="2.0" marshal="custom">
> <param name="cap" type="GLenum"/>
> <glx rop="139" handcode="client"/>
> </function>
>
> <function name="Finish" es1="1.0" es2="2.0" marshal="sync">
> <glx sop="108" handcode="true"/>
> </function>
>
> <!-- TODO: Flush is marshalled synchronously as a temporary hack
> since we don't yet have a hook into SwapBuffers.
> diff --git a/src/mesa/main/marshal.c b/src/mesa/main/marshal.c
> index b01c073..ae32d25 100644
> --- a/src/mesa/main/marshal.c
> +++ b/src/mesa/main/marshal.c
> @@ -60,20 +60,57 @@ _mesa_marshal_Flush(void)
> _mesa_post_marshal_hook(ctx);
>
> /* Flush() needs to be handled specially. In addition to telling the
> * background thread to flush, we need to ensure that our own buffer is
> * submitted to the background thread so that it will complete in a finite
> * amount of time.
> */
> _mesa_glthread_flush_batch(ctx);
> }
>
> +/* Enable: marshalled asynchronously */
> +struct marshal_cmd_Enable
> +{
> + struct marshal_cmd_base cmd_base;
> + GLenum cap;
> +};
> +
> +void
> +_mesa_unmarshal_Enable(struct gl_context *ctx,
> + const struct marshal_cmd_Enable *cmd)
> +{
> + const GLenum cap = cmd->cap;
> + CALL_Enable(ctx->CurrentServerDispatch, (cap));
> +}
> +
> +void GLAPIENTRY
> +_mesa_marshal_Enable(GLenum cap)
> +{
> + GET_CURRENT_CONTEXT(ctx);
> + struct marshal_cmd_Enable *cmd;
> + debug_print_marshal("Enable");
> +
> + if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) {
> + _mesa_glthread_finish(ctx);
> + _mesa_glthread_restore_dispatch(ctx);
> + } else {
> + cmd = _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_Enable,
> + sizeof(*cmd));
> + cmd->cap = cap;
> + _mesa_post_marshal_hook(ctx);
> + return;
> + }
> +
> + _mesa_glthread_finish(ctx);
> + debug_print_sync_fallback("Enable");
> + CALL_Enable(ctx->CurrentServerDispatch, (cap));
> +}
>
> struct marshal_cmd_ShaderSource
> {
> struct marshal_cmd_base cmd_base;
> GLuint shader;
> GLsizei count;
> /* Followed by GLint length[count], then the contents of all strings,
> * concatenated.
> */
> };
> diff --git a/src/mesa/main/marshal.h b/src/mesa/main/marshal.h
> index 3ef5591..2d9ec83 100644
> --- a/src/mesa/main/marshal.h
> +++ b/src/mesa/main/marshal.h
> @@ -191,27 +191,35 @@ _mesa_post_marshal_hook(struct gl_context *ctx)
> * Instead, just punt for now and disable threading on apps using vertex
> * arrays and compat contexts. Apps using vertex arrays can probably use a
> * core context.
> */
> static inline bool
> _mesa_glthread_is_compat_bind_vertex_array(const struct gl_context *ctx)
> {
> return ctx->API != API_OPENGL_CORE;
> }
>
> +struct marshal_cmd_Enable;
> struct marshal_cmd_ShaderSource;
> struct marshal_cmd_Flush;
> struct marshal_cmd_BindBuffer;
> struct marshal_cmd_BufferData;
> struct marshal_cmd_BufferSubData;
> struct marshal_cmd_ClearBufferfv;
>
> +void
> +_mesa_unmarshal_Enable(struct gl_context *ctx,
> + const struct marshal_cmd_Enable *cmd);
> +
> +void GLAPIENTRY
> +_mesa_marshal_Enable(GLenum cap);
> +
> void GLAPIENTRY
> _mesa_marshal_ShaderSource(GLuint shader, GLsizei count,
> const GLchar * const *string, const GLint *length);
>
> void
> _mesa_unmarshal_ShaderSource(struct gl_context *ctx,
> const struct marshal_cmd_ShaderSource *cmd);
>
> void GLAPIENTRY
> _mesa_marshal_Flush(void);
>
--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
More information about the mesa-dev
mailing list