[Mesa-dev] [PATCH 07/26] glapi: Annotate functions with "marshal" attribute.
Marek Olšák
maraeo at gmail.com
Wed Feb 8 18:03:21 UTC 2017
From: Paul Berry <stereotype441 at gmail.com>
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.
---
src/mapi/glapi/gen/ARB_base_instance.xml | 6 ++--
.../glapi/gen/ARB_draw_elements_base_vertex.xml | 8 ++---
src/mapi/glapi/gen/ARB_draw_instanced.xml | 4 +--
src/mapi/glapi/gen/EXT_transform_feedback.xml | 2 +-
src/mapi/glapi/gen/gl_API.dtd | 11 +++++-
src/mapi/glapi/gen/gl_API.xml | 40 +++++++++++++---------
6 files changed, 44 insertions(+), 27 deletions(-)
diff --git a/src/mapi/glapi/gen/ARB_base_instance.xml b/src/mapi/glapi/gen/ARB_base_instance.xml
index 56de639..5bd6cab 100644
--- a/src/mapi/glapi/gen/ARB_base_instance.xml
+++ b/src/mapi/glapi/gen/ARB_base_instance.xml
@@ -1,38 +1,38 @@
<?xml version="1.0"?>
<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
<!-- Note: no GLX protocol info yet. -->
<OpenGLAPI>
<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"/>
<param name="primcount" type="GLsizei"/>
<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"/>
<param name="indices" type="const GLvoid *"/>
<param name="primcount" type="GLsizei"/>
<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"/>
<param name="indices" type="const GLvoid *"/>
<param name="primcount" type="GLsizei"/>
<param name="basevertex" type="GLint"/>
<param name="baseinstance" type="GLuint"/>
</function>
</category>
diff --git a/src/mapi/glapi/gen/ARB_draw_elements_base_vertex.xml b/src/mapi/glapi/gen/ARB_draw_elements_base_vertex.xml
index 72aa62c..7c7a6a4 100644
--- a/src/mapi/glapi/gen/ARB_draw_elements_base_vertex.xml
+++ b/src/mapi/glapi/gen/ARB_draw_elements_base_vertex.xml
@@ -1,48 +1,48 @@
<?xml version="1.0"?>
<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
<!-- Note: no GLX protocol info yet. -->
<OpenGLAPI>
<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"/>
<param name="indices" type="const GLvoid *"/>
<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"/>
<param name="count" type="GLsizei"/>
<param name="type" type="GLenum"/>
<param name="indices" type="const GLvoid *"/>
<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"/>
<param name="indices" type="const GLvoid * const *"/>
<param name="primcount" type="GLsizei"/>
<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"/>
<param name="indices" type="const GLvoid *"/>
<param name="primcount" type="GLsizei"/>
<param name="basevertex" type="GLint"/>
</function>
</category>
diff --git a/src/mapi/glapi/gen/ARB_draw_instanced.xml b/src/mapi/glapi/gen/ARB_draw_instanced.xml
index b1c8221..52dba3c 100644
--- a/src/mapi/glapi/gen/ARB_draw_instanced.xml
+++ b/src/mapi/glapi/gen/ARB_draw_instanced.xml
@@ -1,28 +1,28 @@
<?xml version="1.0"?>
<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
<!-- Note: no GLX protocol info yet. -->
<OpenGLAPI>
<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"/>
<param name="indices" type="const GLvoid *"/>
<param name="primcount" type="GLsizei"/>
</function>
</category>
diff --git a/src/mapi/glapi/gen/EXT_transform_feedback.xml b/src/mapi/glapi/gen/EXT_transform_feedback.xml
index 2aa26ad..bbb4486 100644
--- a/src/mapi/glapi/gen/EXT_transform_feedback.xml
+++ b/src/mapi/glapi/gen/EXT_transform_feedback.xml
@@ -101,18 +101,18 @@
<param name="id" type="GLuint"/>
<return type="GLboolean"/>
</function>
<function name="PauseTransformFeedback" es2="3.0">
</function>
<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>
</category>
</OpenGLAPI>
diff --git a/src/mapi/glapi/gen/gl_API.dtd b/src/mapi/glapi/gen/gl_API.dtd
index 7822651..133bc04 100644
--- a/src/mapi/glapi/gen/gl_API.dtd
+++ b/src/mapi/glapi/gen/gl_API.dtd
@@ -31,21 +31,22 @@
<!ATTLIST enum name NMTOKEN #REQUIRED
count CDATA #IMPLIED
value NMTOKEN #REQUIRED>
<!ATTLIST function name NMTOKEN #REQUIRED
alias NMTOKEN #IMPLIED
vectorequiv NMTOKEN #IMPLIED
es1 CDATA "none"
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">
<!ATTLIST param name NMTOKEN #REQUIRED
type CDATA #REQUIRED
client_only (true | false) "false"
count NMTOKEN #IMPLIED
counter (true | false) "false"
count_scale NMTOKEN "1"
output (true | false) "false"
@@ -113,20 +114,28 @@ param:
img_send_null - boolean flag to determine if blank pixel data should
be sent when a NULL pointer is passed. This is only used by
TexImage1D and TexImage2D.
img_null_flag - boolean flag to determine if an extra flag is used to
determine if a NULL pixel pointer was passed. This is used by
TexSubImage1D, TexSubImage2D, TexImage3D and others.
img_pad_dimensions - boolean flag to determine if dimension data and
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
sop - Opcode value for "single" commands
vendorpriv - Opcode value for vendor private (or vendor private with
reply) commands
large - set to "true" of the render command can use RenderLarge protocol.
doubles_in_order - older commands always put GLdouble data at the
start of the render packet. Newer commands (e.g.,
ProgramEnvParameter4dvARB) put the in the order that they appear
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 2f421f5..493b0b0 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -2359,25 +2359,33 @@
<function name="Disable" es1="1.0" es2="2.0">
<param name="cap" type="GLenum"/>
<glx rop="138" handcode="client"/>
</function>
<function name="Enable" es1="1.0" es2="2.0">
<param name="cap" type="GLenum"/>
<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>
<function name="PopAttrib" deprecated="3.1">
<glx rop="141"/>
</function>
<function name="PushAttrib" deprecated="3.1">
<param name="mask" type="GLbitfield"/>
<glx rop="142"/>
@@ -2591,35 +2599,35 @@
<param name="param" type="GLfloat"/>
<glx sop="109" handcode="client"/>
</function>
<function name="PixelStorei" es1="1.0" es2="2.0">
<param name="pname" type="GLenum"/>
<param name="param" type="GLint"/>
<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"/>
<glx rop="170" large="true"/>
</function>
<function name="ReadBuffer" es2="3.0">
<param name="mode" type="GLenum"/>
<glx rop="171"/>
</function>
@@ -3134,46 +3142,46 @@
<enum name="VERTEX_ARRAY_POINTER" value="0x808E"/>
<enum name="NORMAL_ARRAY_POINTER" value="0x808F"/>
<enum name="COLOR_ARRAY_POINTER" value="0x8090"/>
<enum name="INDEX_ARRAY_POINTER" value="0x8091"/>
<enum name="TEXTURE_COORD_ARRAY_POINTER" value="0x8092"/>
<enum name="EDGE_FLAG_ARRAY_POINTER" value="0x8093"/>
<enum name="CLIENT_PIXEL_STORE_BIT" value="0x00000001"/>
<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>
<function name="ColorPointer" es1="1.0" deprecated="3.1">
<param name="size" type="GLint"/>
<param name="type" type="GLenum"/>
<param name="stride" type="GLsizei"/>
<param name="pointer" type="const GLvoid *"/>
<glx handcode="true"/>
</function>
<function name="DisableClientState" es1="1.0" deprecated="3.1">
<param name="array" type="GLenum"/>
<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"/>
<param name="indices" type="const GLvoid *"/>
<glx handcode="true"/>
</function>
<function name="EdgeFlagPointer" deprecated="3.1">
<param name="stride" type="GLsizei"/>
<param name="pointer" type="const GLvoid *"/>
@@ -3716,21 +3724,21 @@
<param name="blue" type="GLclampf"/>
<param name="alpha" type="GLclampf"/>
<glx rop="4096"/>
</function>
<function name="BlendEquation" es2="2.0">
<param name="mode" 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"/>
<param name="count" type="GLsizei"/>
<param name="type" type="GLenum"/>
<param name="indices" type="const GLvoid *"/>
<glx handcode="true"/>
</function>
<function name="ColorTable" deprecated="3.1">
@@ -4709,21 +4717,21 @@
<glx rop="4125"/>
</function>
<function name="FogCoordPointer" deprecated="3.1">
<param name="type" type="GLenum"/>
<param name="stride" type="GLsizei"/>
<param name="pointer" type="const GLvoid *"/>
<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 *"/>
<param name="primcount" type="GLsizei"/>
<glx handcode="true"/>
</function>
<function name="MultiDrawElements" alias="MultiDrawElementsEXT">
<param name="mode" type="GLenum"/>
<param name="count" type="const GLsizei *"/>
@@ -8082,21 +8090,21 @@
<xi:include href="ARB_draw_indirect.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="ARB_gpu_shader5.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="ARB_gpu_shader_fp64.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<category name="GL_ARB_transform_feedback3" number="94">
<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"/>
</function>
<function name="BeginQueryIndexed">
<param name="target" type="GLenum"/>
<param name="index" type="GLuint"/>
<param name="id" type="GLuint"/>
</function>
@@ -8130,27 +8138,27 @@
<xi:include href="ARB_get_program_binary.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="ARB_debug_output.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="ARB_robustness.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<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>
</category>
<xi:include href="ARB_compressed_texture_pixel_storage.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<!-- ARB extensions #111...#116 -->
@@ -10192,21 +10200,21 @@
</category>
<category name="GL_EXT_multi_draw_arrays" number="148">
<function name="MultiDrawArraysEXT" es1="1.0" es2="2.0" alias="MultiDrawArrays">
<param name="mode" type="GLenum"/>
<param name="first" type="const GLint *"/>
<param name="count" type="const GLsizei *"/>
<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"/>
<param name="indices" type="const GLvoid * const *"/>
<param name="primcount" type="GLsizei"/>
<glx handcode="true"/>
</function>
</category>
<category name="GL_EXT_fog_coord" number="149">
@@ -11202,30 +11210,30 @@
</category>
<category name="GL_EXT_texture_compression_s3tc" number="198">
<enum name="COMPRESSED_RGB_S3TC_DXT1_EXT" value="0x83F0"/>
<enum name="COMPRESSED_RGBA_S3TC_DXT1_EXT" value="0x83F1"/>
<enum name="COMPRESSED_RGBA_S3TC_DXT3_EXT" value="0x83F2"/>
<enum name="COMPRESSED_RGBA_S3TC_DXT5_EXT" value="0x83F3"/>
</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 *"/>
<param name="primcount" type="GLsizei"/>
<param name="modestride" type="GLint"/>
<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"/>
<param name="indices" type="const GLvoid * const *"/>
<param name="primcount" type="GLsizei"/>
<param name="modestride" type="GLint"/>
<glx handcode="true" ignore="true"/>
</function>
</category>
--
2.7.4
More information about the mesa-dev
mailing list