From c920572f603b5e0ac062501593a4ed6b53bc8f40 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 19 Feb 2020 17:20:21 -0500 Subject: [PATCH] glthread: simplify repeated function sequences in marshal_generated.c Reviewed-by: Timothy Arceri Part-of: --- src/mapi/glapi/gen/gl_marshal.py | 9 +++------ src/mesa/main/glthread.c | 14 ++++++++++++++ src/mesa/main/glthread.h | 2 ++ src/mesa/main/marshal.c | 3 +-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py index c12a086942b..5f4787cc3cc 100644 --- a/src/mapi/glapi/gen/gl_marshal.py +++ b/src/mapi/glapi/gen/gl_marshal.py @@ -87,7 +87,6 @@ class PrintCode(gl_XML.gl_print_base): out('return {0};'.format(call)) def print_sync_dispatch(self, func): - out('debug_print_sync_fallback("{0}");'.format(func.name)) self.print_sync_call(func) def print_sync_body(self, func): @@ -97,8 +96,7 @@ class PrintCode(gl_XML.gl_print_base): out('{') with indent(): out('GET_CURRENT_CONTEXT(ctx);') - out('_mesa_glthread_finish(ctx);') - out('debug_print_sync("{0}");'.format(func.name)) + out('_mesa_glthread_finish_before(ctx, "{0}");'.format(func.name)) self.print_sync_call(func) out('}') out('') @@ -247,8 +245,7 @@ class PrintCode(gl_XML.gl_print_base): if func.marshal_fail: out('if ({0}) {{'.format(func.marshal_fail)) with indent(): - out('_mesa_glthread_finish(ctx);') - out('_mesa_glthread_restore_dispatch(ctx, __func__);') + out('_mesa_glthread_disable(ctx, "{0}");'.format(func.name)) self.print_sync_dispatch(func) out('return;') out('}') @@ -264,7 +261,7 @@ class PrintCode(gl_XML.gl_print_base): if need_fallback_sync: out('fallback_to_sync:') with indent(): - out('_mesa_glthread_finish(ctx);') + out('_mesa_glthread_finish_before(ctx, "{0}");'.format(func.name)) self.print_sync_dispatch(func) else: with indent(): diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c index eae468e211c..af4eb15cb4d 100644 --- a/src/mesa/main/glthread.c +++ b/src/mesa/main/glthread.c @@ -148,6 +148,13 @@ _mesa_glthread_restore_dispatch(struct gl_context *ctx, const char *func) } } +void +_mesa_glthread_disable(struct gl_context *ctx, const char *func) +{ + _mesa_glthread_finish_before(ctx, func); + _mesa_glthread_restore_dispatch(ctx, func); +} + void _mesa_glthread_flush_batch(struct gl_context *ctx) { @@ -227,3 +234,10 @@ _mesa_glthread_finish(struct gl_context *ctx) if (synced) p_atomic_inc(&glthread->stats.num_syncs); } + +void +_mesa_glthread_finish_before(struct gl_context *ctx, const char *func) +{ + _mesa_glthread_finish(ctx); + debug_print_sync_fallback(func); +} diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index 3d1c3ef1983..021d5213084 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -100,7 +100,9 @@ void _mesa_glthread_init(struct gl_context *ctx); void _mesa_glthread_destroy(struct gl_context *ctx); void _mesa_glthread_restore_dispatch(struct gl_context *ctx, const char *func); +void _mesa_glthread_disable(struct gl_context *ctx, const char *func); void _mesa_glthread_flush_batch(struct gl_context *ctx); void _mesa_glthread_finish(struct gl_context *ctx); +void _mesa_glthread_finish_before(struct gl_context *ctx, const char *func); #endif /* _GLTHREAD_H*/ diff --git a/src/mesa/main/marshal.c b/src/mesa/main/marshal.c index b2428e5e7cd..e0d423a4aae 100644 --- a/src/mesa/main/marshal.c +++ b/src/mesa/main/marshal.c @@ -87,8 +87,7 @@ _mesa_marshal_Enable(GLenum cap) debug_print_marshal("Enable"); if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) { - _mesa_glthread_finish(ctx); - _mesa_glthread_restore_dispatch(ctx, "Enable(DEBUG_OUTPUT_SYNCHRONOUS)"); + _mesa_glthread_disable(ctx, "Enable(DEBUG_OUTPUT_SYNCHRONOUS)"); } else { cmd = _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_Enable, sizeof(*cmd)); -- 2.30.2