glthread: sync instead of disabling glthread for non-VBO pointers
authorMarek Olšák <marek.olsak@amd.com>
Fri, 21 Feb 2020 01:40:31 +0000 (20:40 -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/ARB_base_instance.xml
src/mapi/glapi/gen/ARB_draw_elements_base_vertex.xml
src/mapi/glapi/gen/ARB_draw_indirect.xml
src/mapi/glapi/gen/ARB_draw_instanced.xml
src/mapi/glapi/gen/ARB_indirect_parameters.xml
src/mapi/glapi/gen/gl_API.dtd
src/mapi/glapi/gen/gl_API.xml
src/mapi/glapi/gen/gl_marshal.py
src/mapi/glapi/gen/marshal_XML.py

index 22c57167fd570cba398ce8bc0208ace31b947754..2846e913c06e569b3f1cb9a64e31a273a6c738dd 100644 (file)
@@ -9,7 +9,7 @@
 <category name="GL_ARB_base_instance" number="107">
 
   <function name="DrawArraysInstancedBaseInstance" exec="dynamic" marshal="draw"
-            marshal_fail="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
+            marshal_sync="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
     <param name="mode" type="GLenum"/>
     <param name="first" type="GLint"/>
     <param name="count" type="GLsizei"/>
@@ -18,7 +18,7 @@
   </function>
 
   <function name="DrawElementsInstancedBaseInstance" exec="dynamic" marshal="draw"
-            marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+            marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
     <param name="mode" type="GLenum"/>
     <param name="count" type="GLsizei"/>
     <param name="type" type="GLenum"/>
@@ -28,7 +28,7 @@
   </function>
 
   <function name="DrawElementsInstancedBaseVertexBaseInstance" exec="dynamic" marshal="draw"
-            marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+            marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
     <param name="mode" type="GLenum"/>
     <param name="count" type="GLsizei"/>
     <param name="type" type="GLenum"/>
index 9f18cacd1e65692a7e648eb35b17612a72912416..28d478394336a8b4d930d27a1e8352dab8c5a6d4 100644 (file)
@@ -9,7 +9,7 @@
 <category name="GL_ARB_draw_elements_base_vertex" number="62">
 
     <function name="DrawElementsBaseVertex" es2="3.2" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
@@ -18,7 +18,7 @@
     </function>
 
     <function name="DrawRangeElementsBaseVertex" es2="3.2" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="start" type="GLuint"/>
         <param name="end" type="GLuint"/>
@@ -29,7 +29,7 @@
     </function>
 
     <function name="MultiDrawElementsBaseVertex" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="count" type="const GLsizei *" count="primcount"/>
         <param name="type" type="GLenum"/>
@@ -39,7 +39,7 @@
     </function>
 
     <function name="DrawElementsInstancedBaseVertex" es2="3.2" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
index c17b4337baa2cf3de3863a7b7e22f060232f20b6..af342eb868319465d8412e86b90dc2f4a8c28cf8 100644 (file)
 
     <function name="DrawArraysIndirect" exec="dynamic" es2="3.1"
               marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_arrays_indirect(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_arrays_indirect(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="indirect" type="const GLvoid *"/>
     </function>
 
     <function name="DrawElementsIndirect" exec="dynamic" es2="3.1"
               marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements_indirect(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements_indirect(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="type" type="GLenum"/>
         <param name="indirect" type="const GLvoid *"/>
@@ -29,7 +29,7 @@
 <category name="GL_ARB_multi_draw_indirect" number="133">
 
     <function name="MultiDrawArraysIndirect" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_arrays_indirect(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_arrays_indirect(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="indirect" type="const GLvoid *"/>
         <param name="primcount" type="GLsizei"/>
@@ -37,7 +37,7 @@
     </function>
 
     <function name="MultiDrawElementsIndirect" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements_indirect(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements_indirect(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="type" type="GLenum"/>
         <param name="indirect" type="const GLvoid *"/>
index e450f04a8e1447236149e6a870049f656fde5320..bf24fc5709f8e270b9476704ea34bf8ce3d22704 100644 (file)
@@ -9,7 +9,7 @@
 <category name="GL_ARB_draw_instanced" number="44">
 
   <function name="DrawArraysInstancedARB" exec="dynamic" marshal="draw"
-            marshal_fail="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
+            marshal_sync="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
     <param name="mode" type="GLenum"/>
     <param name="first" type="GLint"/>
     <param name="count" type="GLsizei"/>
@@ -17,7 +17,7 @@
   </function>
 
   <function name="DrawElementsInstancedARB" exec="dynamic" marshal="draw"
-            marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+            marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
     <param name="mode" type="GLenum"/>
     <param name="count" type="GLsizei"/>
     <param name="type" type="GLenum"/>
index 3938bd643bb18725d84aaccbf383b1e56a75b171..89d117466548b916f8b38da6c01d007a2e9b79e5 100644 (file)
@@ -9,7 +9,7 @@
     <enum name="PARAMETER_BUFFER_BINDING_ARB"           value="0x80EF"/>
 
     <function name="MultiDrawArraysIndirectCountARB" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="indirect" type="GLintptr"/>
         <param name="drawcount" type="GLintptr"/>
@@ -19,7 +19,7 @@
 
     <!-- Use "...vbo_draw_arrays", because indices always come from a buffer object. -->
     <function name="MultiDrawElementsIndirectCountARB" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="type" type="GLenum"/>
         <param name="indirect" type="GLintptr"/>
index 787fcbf267520433551b5deeff9c85f2c5493916..96d70982c837745c52be04bc62f63d084e3809c9 100644 (file)
@@ -41,6 +41,7 @@
                    desktop             (true | false) "true"
                    marshal             NMTOKEN #IMPLIED
                    marshal_fail        CDATA #IMPLIED>
+                   marshal_sync        CDATA #IMPLIED>
                    marshal_count       CDATA #IMPLIED>
                    marshal_call_after  CDATA #IMPLIED>
 <!ATTLIST size     name                NMTOKEN #REQUIRED
@@ -136,6 +137,8 @@ param:
         to switch back to the Mesa implementation and call it directly.  Used
         to disable glthread for GL compatibility interactions that we don't
         want to track state for.
+     marshal_sync - an expression that, if it evaluates true, causes glthread
+        to sync and execute the call directly.
      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
index 6de88c6d7fe97ab7b46fd6208f8c5c75e7eb7ea0..fd21297d7210c5740680402e728c4f76b208a3e8 100644 (file)
     </function>
 
     <function name="DrawArrays" es1="1.0" es2="2.0" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="first" type="GLint"/>
         <param name="count" type="GLsizei"/>
     </function>
 
     <function name="DrawElements" es1="1.0" es2="2.0" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
     </function>
 
     <function name="DrawRangeElements" es2="3.0" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="start" type="GLuint"/>
         <param name="end" type="GLuint"/>
     </function>
 
     <function name="MultiDrawArrays" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="first" type="const GLint *" count="primcount"/>
         <param name="count" type="const GLsizei *" count="primcount"/>
     </function>
 
     <function name="MultiDrawElementsEXT" es1="1.0" es2="2.0" exec="dynamic" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
         <param name="mode" type="GLenum"/>
         <param name="count" type="const GLsizei *" count="primcount"/>
         <param name="type" type="GLenum"/>
 
 <category name="GL_IBM_multimode_draw_arrays" number="200">
     <function name="MultiModeDrawArraysIBM" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_arrays(ctx)">
         <param name="mode" type="const GLenum *" count="primcount"/>
         <param name="first" type="const GLint *" count="primcount"/>
         <param name="count" type="const GLsizei *" count="primcount"/>
     </function>
 
     <function name="MultiModeDrawElementsIBM" marshal="draw"
-              marshal_fail="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
+              marshal_sync="_mesa_glthread_is_non_vbo_draw_elements(ctx)">
         <param name="mode" type="const GLenum *" count="primcount"/>
         <param name="count" type="const GLsizei *" count="primcount"/>
         <param name="type" type="GLenum"/>
index 19deba7b3c13decad6c39247ff605fb5d966f1d4..3147b702c702e9721c8201c598a55ad30efbea5e 100644 (file)
@@ -270,6 +270,14 @@ class PrintCode(gl_XML.gl_print_base):
                     out('return;')
                 out('}')
 
+            if func.marshal_sync:
+                out('if ({0}) {{'.format(func.marshal_sync))
+                with indent():
+                    out('_mesa_glthread_finish_before(ctx, "{0}");'.format(func.name))
+                    self.print_sync_dispatch(func)
+                    out('return;')
+                out('}')
+
         with indent():
             self.print_async_dispatch(func)
         out('}')
index b673c8535d69bd3331c6139a81ab41a13379c569..f0be4f8780af0144e4ae4d13875a84cb26bbe7de 100644 (file)
@@ -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_sync = element.get('marshal_sync')
         self.marshal_call_after = element.get('marshal_call_after')
 
     def marshal_flavor(self):