glapi: Annotate functions with "marshal" attribute.
authorPaul Berry <stereotype441@gmail.com>
Wed, 7 Nov 2012 21:04:40 +0000 (13:04 -0800)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 16 Mar 2017 03:14:18 +0000 (14:14 +1100)
Several API functions require special treatment in order to be marshalled
to a background thread.  Others can't be safely executed in a background
thread and need to be executed synchronously (e.g. since they return data
through a pointer argument).

This annotation will be used when code generating thread marshalling code,
to ensure that each function is marshalled in the correct way.

Note that PixelMap functions are marked as synchronous for now since
their pointer may be relative to buffer on the GPU, so we'll need
special logic to marshal them properly.

v2: Move description of attribute types to a comment in the dtd file.

Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Acked-by: Marek Olšák <maraeo@gmail.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
src/mapi/glapi/gen/ARB_base_instance.xml
src/mapi/glapi/gen/ARB_draw_elements_base_vertex.xml
src/mapi/glapi/gen/ARB_draw_instanced.xml
src/mapi/glapi/gen/EXT_transform_feedback.xml
src/mapi/glapi/gen/gl_API.dtd
src/mapi/glapi/gen/gl_API.xml

index 56de639e907e25d436d8ddfc3b720a447fe6f298..5bd6cabf9c147355c783115c99ca382a37ec9484 100644 (file)
@@ -8,7 +8,7 @@
 
 <category name="GL_ARB_base_instance" number="107">
 
-  <function name="DrawArraysInstancedBaseInstance" exec="dynamic">
+  <function name="DrawArraysInstancedBaseInstance" exec="dynamic" marshal="draw">
     <param name="mode" type="GLenum"/>
     <param name="first" type="GLint"/>
     <param name="count" type="GLsizei"/>
@@ -16,7 +16,7 @@
     <param name="baseinstance" type="GLuint"/>
   </function>
 
-  <function name="DrawElementsInstancedBaseInstance" exec="dynamic">
+  <function name="DrawElementsInstancedBaseInstance" exec="dynamic" marshal="draw">
     <param name="mode" type="GLenum"/>
     <param name="count" type="GLsizei"/>
     <param name="type" type="GLenum"/>
@@ -25,7 +25,7 @@
     <param name="baseinstance" type="GLuint"/>
   </function>
 
-  <function name="DrawElementsInstancedBaseVertexBaseInstance" exec="dynamic">
+  <function name="DrawElementsInstancedBaseVertexBaseInstance" exec="dynamic" marshal="draw">
     <param name="mode" type="GLenum"/>
     <param name="count" type="GLsizei"/>
     <param name="type" type="GLenum"/>
index 72aa62c775184190c3c8e65da836df6e7fd99b32..7c7a6a4958875f3db3272f134338a474d2a40393 100644 (file)
@@ -8,7 +8,7 @@
 
 <category name="GL_ARB_draw_elements_base_vertex" number="62">
 
-    <function name="DrawElementsBaseVertex" es2="3.2" exec="dynamic">
+    <function name="DrawElementsBaseVertex" es2="3.2" exec="dynamic" marshal="draw">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
@@ -16,7 +16,7 @@
         <param name="basevertex" type="GLint"/>
     </function>
 
-    <function name="DrawRangeElementsBaseVertex" es2="3.2" exec="dynamic">
+    <function name="DrawRangeElementsBaseVertex" es2="3.2" exec="dynamic" marshal="draw">
         <param name="mode" type="GLenum"/>
         <param name="start" type="GLuint"/>
         <param name="end" type="GLuint"/>
@@ -26,7 +26,7 @@
         <param name="basevertex" type="GLint"/>
     </function>
 
-    <function name="MultiDrawElementsBaseVertex" exec="dynamic">
+    <function name="MultiDrawElementsBaseVertex" exec="dynamic" marshal="draw">
         <param name="mode" type="GLenum"/>
         <param name="count" type="const GLsizei *"/>
         <param name="type" type="GLenum"/>
@@ -35,7 +35,7 @@
         <param name="basevertex" type="const GLint *"/>
     </function>
 
-    <function name="DrawElementsInstancedBaseVertex" es2="3.2" exec="dynamic">
+    <function name="DrawElementsInstancedBaseVertex" es2="3.2" exec="dynamic" marshal="draw">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
index b1c8221444a48514e7d56e57915d2ed2ae9004a4..52dba3cf3c3e9fc49100866bea84cfa475c94a9b 100644 (file)
@@ -8,14 +8,14 @@
 
 <category name="GL_ARB_draw_instanced" number="44">
 
-  <function name="DrawArraysInstancedARB" exec="dynamic">
+  <function name="DrawArraysInstancedARB" exec="dynamic" marshal="draw">
     <param name="mode" type="GLenum"/>
     <param name="first" type="GLint"/>
     <param name="count" type="GLsizei"/>
     <param name="primcount" type="GLsizei"/>
   </function>
 
-  <function name="DrawElementsInstancedARB" exec="dynamic">
+  <function name="DrawElementsInstancedARB" exec="dynamic" marshal="draw">
     <param name="mode" type="GLenum"/>
     <param name="count" type="GLsizei"/>
     <param name="type" type="GLenum"/>
index 2aa26ad72514115c01faa0469406e797a0bf4e8e..bbb44866f91ccf97c2657f53a40b1afdff9bcfaf 100644 (file)
   <function name="ResumeTransformFeedback" es2="3.0">
   </function>
 
-  <function name="DrawTransformFeedback" exec="dynamic">
+  <function name="DrawTransformFeedback" exec="dynamic" marshal="draw">
     <param name="mode" type="GLenum"/>
     <param name="id" type="GLuint"/>
   </function>
index 78226513c460fef1f9343a7810b597dfdd4b813e..133bc042aa9ea441afee484b06ff8ab45092621d 100644 (file)
@@ -38,7 +38,8 @@
                    es2                 CDATA   "none"
                    deprecated          CDATA   "none"
                    exec                NMTOKEN #IMPLIED
-                   desktop             (true | false) "true">
+                   desktop             (true | false) "true"
+                   marshal             NMTOKEN #IMPLIED>
 <!ATTLIST size     name                NMTOKEN #REQUIRED
                    count               NMTOKEN #IMPLIED
                    mode                (get | set) "set">
@@ -120,6 +121,14 @@ param:
         offset data should be padded to the next even number of dimensions.
         For example, this will insert an empty "height" field after the
         "width" field in the protocol for TexImage1D.
+     marshal - One of "sync", "async", "draw", or "custom", defaulting to
+        async unless one of the arguments is something we know we can't
+        codegen for.  If "sync", we finish any queued glthread work and call
+        the Mesa implementation directly.  If "async", we queue the function
+        call to be performed by glthread.  If "custom", the prototype will be
+        generated but a custom implementation will be present in marshal.c.
+        If "draw", it will follow the "async" rules except that "indices" are
+        ignored (since they may come from a VBO).
 
 glx:
      rop - Opcode value for "render" commands
index 2c5444475f9492347855a03c269db91ceb1872d3..ce9ad172dc4c6d31bcc7b31512f04086598ca461 100644 (file)
         <glx rop="139" handcode="client"/>
     </function>
 
-    <function name="Finish" es1="1.0" es2="2.0">
+    <function name="Finish" es1="1.0" es2="2.0" marshal="sync">
         <glx sop="108" handcode="true"/>
     </function>
 
-    <function name="Flush" es1="1.0" es2="2.0">
+    <!-- TODO: Flush is marshalled synchronously as a temporary hack
+    since we don't yet have a hook into SwapBuffers.
+
+    NOTE: when we remove this hack, we'll still have to handle Flush
+    specially to ensure that it causes all previous commands to get
+    delivered to the server thread.
+    -->
+
+    <function name="Flush" es1="1.0" es2="2.0" marshal="sync">
         <glx sop="142" handcode="true"/>
     </function>
 
         <glx sop="110" handcode="client"/>
     </function>
 
-    <function name="PixelMapfv" deprecated="3.1">
+    <function name="PixelMapfv" deprecated="3.1" marshal="sync">
         <param name="map" type="GLenum"/>
         <param name="mapsize" type="GLsizei" counter="true"/>
         <param name="values" type="const GLfloat *" count="mapsize"/>
         <glx rop="168" large="true"/>
     </function>
 
-    <function name="PixelMapuiv" deprecated="3.1">
+    <function name="PixelMapuiv" deprecated="3.1" marshal="sync">
         <param name="map" type="GLenum"/>
         <param name="mapsize" type="GLsizei" counter="true"/>
         <param name="values" type="const GLuint *" count="mapsize"/>
         <glx rop="169" large="true"/>
     </function>
 
-    <function name="PixelMapusv" deprecated="3.1">
+    <function name="PixelMapusv" deprecated="3.1" marshal="sync">
         <param name="map" type="GLenum"/>
         <param name="mapsize" type="GLsizei" counter="true"/>
         <param name="values" type="const GLushort *" count="mapsize"/>
     <enum name="CLIENT_VERTEX_ARRAY_BIT"                  value="0x00000002"/>
     <enum name="CLIENT_ALL_ATTRIB_BITS"                   value="0xFFFFFFFF"/>
 
-    <function name="ArrayElement" deprecated="3.1" exec="dynamic">
+    <function name="ArrayElement" deprecated="3.1" exec="dynamic" marshal="draw">
         <param name="i" type="GLint"/>
         <glx handcode="true"/>
     </function>
         <glx handcode="true"/>
     </function>
 
-    <function name="DrawArrays" es1="1.0" es2="2.0" exec="dynamic">
+    <function name="DrawArrays" es1="1.0" es2="2.0" exec="dynamic" marshal="draw">
         <param name="mode" type="GLenum"/>
         <param name="first" type="GLint"/>
         <param name="count" type="GLsizei"/>
         <glx rop="193" handcode="true"/>
     </function>
 
-    <function name="DrawElements" es1="1.0" es2="2.0" exec="dynamic">
+    <function name="DrawElements" es1="1.0" es2="2.0" exec="dynamic" marshal="draw">
         <param name="mode" type="GLenum"/>
         <param name="count" type="GLsizei"/>
         <param name="type" type="GLenum"/>
         <glx rop="4097"/>
     </function>
 
-    <function name="DrawRangeElements" es2="3.0" exec="dynamic">
+    <function name="DrawRangeElements" es2="3.0" exec="dynamic" marshal="draw">
         <param name="mode" type="GLenum"/>
         <param name="start" type="GLuint"/>
         <param name="end" type="GLuint"/>
         <glx handcode="true"/>
     </function>
 
-    <function name="MultiDrawArrays">
+    <function name="MultiDrawArrays" marshal="draw">
         <param name="mode" type="GLenum"/>
         <param name="first" type="const GLint *"/>
         <param name="count" type="const GLsizei *"/>
   <enum name="MAX_TRANSFORM_FEEDBACK_BUFFERS" value="0x8E70"/>
   <enum name="MAX_VERTEX_STREAMS"             value="0x8E71"/>
 
-  <function name="DrawTransformFeedbackStream" exec="dynamic">
+  <function name="DrawTransformFeedbackStream" exec="dynamic" marshal="draw">
     <param name="mode" type="GLenum"/>
     <param name="id" type="GLuint"/>
     <param name="stream" type="GLuint"/>
 <xi:include href="ARB_base_instance.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
 <category name="GL_ARB_transform_feedback_instanced" number="109">
-  <function name="DrawTransformFeedbackInstanced" exec="dynamic">
+  <function name="DrawTransformFeedbackInstanced" exec="dynamic" marshal="draw">
     <param name="mode" type="GLenum"/>
     <param name="id" type="GLuint"/>
     <param name="primcount" type="GLsizei"/>
   </function>
 
-  <function name="DrawTransformFeedbackStreamInstanced" exec="dynamic">
+  <function name="DrawTransformFeedbackStreamInstanced" exec="dynamic" marshal="draw">
     <param name="mode" type="GLenum"/>
     <param name="id" type="GLuint"/>
     <param name="stream" type="GLuint"/>
         <param name="primcount" type="GLsizei"/>
     </function>
 
-    <function name="MultiDrawElementsEXT" es1="1.0" es2="2.0" exec="dynamic">
+    <function name="MultiDrawElementsEXT" es1="1.0" es2="2.0" exec="dynamic" marshal="draw">
         <param name="mode" type="GLenum"/>
         <param name="count" type="const GLsizei *"/>
         <param name="type" type="GLenum"/>
 </category>
 
 <category name="GL_IBM_multimode_draw_arrays" number="200">
-    <function name="MultiModeDrawArraysIBM">
+    <function name="MultiModeDrawArraysIBM" marshal="draw">
         <param name="mode" type="const GLenum *"/>
         <param name="first" type="const GLint *"/>
         <param name="count" type="const GLsizei *"/>
         <glx handcode="true" ignore="true"/>
     </function>
 
-    <function name="MultiModeDrawElementsIBM">
+    <function name="MultiModeDrawElementsIBM" marshal="draw">
         <param name="mode" type="const GLenum *"/>
         <param name="count" type="const GLsizei *"/>
         <param name="type" type="GLenum"/>