From d510e652d46f471a93eae5a07f7e7508633d1040 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 20 Feb 2020 18:15:42 -0500 Subject: [PATCH] glthread: add marshal_call_after and remove custom glFlush and glEnable code Instead of implementing marshalling manually, this XML property allows us to insert additional code into code-generated functions. Reviewed-by: Timothy Arceri Part-of: --- src/mapi/glapi/gen/gl_API.dtd | 2 + src/mapi/glapi/gen/gl_API.xml | 13 ++---- src/mapi/glapi/gen/gl_marshal.py | 10 ++++- src/mapi/glapi/gen/marshal_XML.py | 1 + src/mesa/main/marshal.c | 68 ------------------------------- src/mesa/main/marshal.h | 16 -------- 6 files changed, 15 insertions(+), 95 deletions(-) diff --git a/src/mapi/glapi/gen/gl_API.dtd b/src/mapi/glapi/gen/gl_API.dtd index 1f10e1e012d..787fcbf2675 100644 --- a/src/mapi/glapi/gen/gl_API.dtd +++ b/src/mapi/glapi/gen/gl_API.dtd @@ -42,6 +42,7 @@ marshal NMTOKEN #IMPLIED marshal_fail CDATA #IMPLIED> marshal_count CDATA #IMPLIED> + marshal_call_after CDATA #IMPLIED> @@ -137,6 +138,7 @@ param: want to track state for. marshal_count - same as count, but variable_param is ignored. Used by glthread. + marshal_call_after - insert the string at the end of the marshal function glx: rop - Opcode value for "render" commands diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index e9f2713ac9d..256d0f3aa15 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -2377,7 +2377,8 @@ - + @@ -2386,14 +2387,8 @@ - - + diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py index 8e918a095ec..19deba7b3c1 100644 --- a/src/mapi/glapi/gen/gl_marshal.py +++ b/src/mapi/glapi/gen/gl_marshal.py @@ -78,13 +78,16 @@ class PrintCode(gl_XML.gl_print_base): def printRealFooter(self): pass - def print_sync_call(self, func): + def print_sync_call(self, func, unmarshal = 0): call = 'CALL_{0}(ctx->CurrentServerDispatch, ({1}))'.format( func.name, func.get_called_parameter_string()) if func.return_type == 'void': out('{0};'.format(call)) + if func.marshal_call_after and not unmarshal: + out(func.marshal_call_after); else: out('return {0};'.format(call)) + assert not func.marshal_call_after def print_sync_dispatch(self, func): self.print_sync_call(func) @@ -132,6 +135,9 @@ class PrintCode(gl_XML.gl_print_base): if not func.fixed_params and not func.variable_params: out('(void) cmd;') + if func.marshal_call_after: + out(func.marshal_call_after); + # Uncomment this if you want to call _mesa_glthread_finish for debugging #out('_mesa_glthread_finish(ctx);') @@ -208,7 +214,7 @@ class PrintCode(gl_XML.gl_print_base): out('variable_data += {0};'.format(p.size_string(False, marshal = 1))) i += 1 - self.print_sync_call(func) + self.print_sync_call(func, unmarshal = 1) out('}') def validate_count_or_fallback(self, func): diff --git a/src/mapi/glapi/gen/marshal_XML.py b/src/mapi/glapi/gen/marshal_XML.py index f6103b9e8fe..b673c8535d6 100644 --- a/src/mapi/glapi/gen/marshal_XML.py +++ b/src/mapi/glapi/gen/marshal_XML.py @@ -58,6 +58,7 @@ class marshal_function(gl_XML.gl_function): # Store the "marshal" attribute, if present. self.marshal = element.get('marshal') self.marshal_fail = element.get('marshal_fail') + self.marshal_call_after = element.get('marshal_call_after') def marshal_flavor(self): """Find out how this function should be marshalled between diff --git a/src/mesa/main/marshal.c b/src/mesa/main/marshal.c index b6001d7dbed..ce9bbf8139f 100644 --- a/src/mesa/main/marshal.c +++ b/src/mesa/main/marshal.c @@ -43,74 +43,6 @@ _mesa_post_marshal_hook(struct gl_context *ctx) _mesa_glthread_finish(ctx); } -struct marshal_cmd_Flush -{ - struct marshal_cmd_base cmd_base; -}; - - -void -_mesa_unmarshal_Flush(struct gl_context *ctx, - const struct marshal_cmd_Flush *cmd) -{ - CALL_Flush(ctx->CurrentServerDispatch, ()); -} - - -void GLAPIENTRY -_mesa_marshal_Flush(void) -{ - GET_CURRENT_CONTEXT(ctx); - struct marshal_cmd_Flush *cmd = - _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_Flush, - sizeof(struct marshal_cmd_Flush)); - (void) cmd; - _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_disable(ctx, "Enable(DEBUG_OUTPUT_SYNCHRONOUS)"); - } 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 { diff --git a/src/mesa/main/marshal.h b/src/mesa/main/marshal.h index 5754d66f6e6..78f6fbc34f7 100644 --- a/src/mesa/main/marshal.h +++ b/src/mesa/main/marshal.h @@ -175,22 +175,13 @@ _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_NamedBufferData; struct marshal_cmd_NamedBufferSubData; -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); @@ -199,13 +190,6 @@ void _mesa_unmarshal_ShaderSource(struct gl_context *ctx, const struct marshal_cmd_ShaderSource *cmd); -void GLAPIENTRY -_mesa_marshal_Flush(void); - -void -_mesa_unmarshal_Flush(struct gl_context *ctx, - const struct marshal_cmd_Flush *cmd); - void GLAPIENTRY _mesa_marshal_BindBuffer(GLenum target, GLuint buffer); -- 2.30.2