glthread: simplify repeated function sequences in marshal_generated.c
authorMarek Olšák <marek.olsak@amd.com>
Wed, 19 Feb 2020 22:20:21 +0000 (17:20 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 6 Mar 2020 01:06:14 +0000 (01:06 +0000)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3948>

src/mapi/glapi/gen/gl_marshal.py
src/mesa/main/glthread.c
src/mesa/main/glthread.h
src/mesa/main/marshal.c

index c12a086942bb93405a3fbf8a80f6b6be609d14ec..5f4787cc3cc54138a025260f5e2d022ec2914ed3 100644 (file)
@@ -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():
index eae468e211cb039846427a22b5b280fb1851d800..af4eb15cb4de01e9d14164d2daf972a024b3bd1f 100644 (file)
@@ -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);
+}
index 3d1c3ef198308e6e10cf7c419133471638c1979a..021d52130841732d85e1d9f9d5a01b91148899f0 100644 (file)
@@ -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*/
index b2428e5e7cdab99fa27c567c2c527788f4bf26ea..e0d423a4aae207f6dd01a690edb14344cc604671 100644 (file)
@@ -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));