glthread: handle complex pointer parameters and support GL functions with strings
authorMarek Olšák <marek.olsak@amd.com>
Thu, 20 Feb 2020 00:41:25 +0000 (19:41 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 6 Mar 2020 01:06:14 +0000 (01:06 +0000)
The python changes add a local variable that computes the parameter size
only once.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3948>

src/mapi/glapi/gen/ARB_blend_func_extended.xml
src/mapi/glapi/gen/ARB_gl_spirv.xml
src/mapi/glapi/gen/GL3x.xml
src/mapi/glapi/gen/gl_API.xml
src/mapi/glapi/gen/gl_marshal.py

index 10d85a766211895064e9cfa533df0c7f87276a46..9b66fa2eea750c77235bd343f12b317b5005718d 100644 (file)
@@ -12,7 +12,7 @@
         <param name="program" type="GLuint"/>
         <param name="colorNumber" type="GLuint"/>
         <param name="index" type="GLuint"/>
         <param name="program" type="GLuint"/>
         <param name="colorNumber" type="GLuint"/>
         <param name="index" type="GLuint"/>
-        <param name="name" type="const GLchar *"/>
+        <param name="name" type="const GLchar *" count="(strlen(name) + 1)"/>
     </function>
 
     <function name="GetFragDataIndex">
     </function>
 
     <function name="GetFragDataIndex">
index 0dd615480f7f3c8045ec4d017fde435c993842a9..a963b001e61223c99bb02dc04c2ceeb4d2377f93 100644 (file)
 
     <function name="SpecializeShaderARB">
         <param name="shader" type="GLuint"/>
 
     <function name="SpecializeShaderARB">
         <param name="shader" type="GLuint"/>
-        <param name="pEntryPoint" type="const GLchar *"/>
+        <param name="pEntryPoint" type="const GLchar *" count="(strlen(pEntryPoint) + 1)"/>
         <param name="numSpecializationConstants" type="GLuint"/>
         <param name="numSpecializationConstants" type="GLuint"/>
-        <param name="pConstantIndex" type="const GLuint *"/>
-        <param name="pConstantValue" type="const GLuint *"/>
+        <param name="pConstantIndex" type="const GLuint *" count="numSpecializationConstants"/>
+        <param name="pConstantValue" type="const GLuint *" count="numSpecializationConstants"/>
     </function>
 
 </category>
     </function>
 
 </category>
index cd3987e0cebb77a27e0276770733516c464581d5..3ffc1667607048ef3403a794a3352735f8c30251 100644 (file)
   <function name="BindFragDataLocation" no_error="true">
     <param name="program" type="GLuint"/>
     <param name="colorNumber" type="GLuint"/>
   <function name="BindFragDataLocation" no_error="true">
     <param name="program" type="GLuint"/>
     <param name="colorNumber" type="GLuint"/>
-    <param name="name" type="const GLchar *"/>
+    <param name="name" type="const GLchar *" count="(strlen(name) + 1)"/>
   </function>
 
   <function name="BeginTransformFeedback" es2="3.0" no_error="true">
   </function>
 
   <function name="BeginTransformFeedback" es2="3.0" no_error="true">
index 2bec492f7d1a5034384e51be9ce11aacdf0fa714..a33e82ad53d171a7a62a49a7b425b284f97f2aff 100644 (file)
     <function name="BindAttribLocation" es2="2.0" no_error="true">
         <param name="program" type="GLuint"/>
         <param name="index" type="GLuint"/>
     <function name="BindAttribLocation" es2="2.0" no_error="true">
         <param name="program" type="GLuint"/>
         <param name="index" type="GLuint"/>
-        <param name="name" type="const GLchar *"/>
+        <param name="name" type="const GLchar *" count="(strlen(name) + 1)"/>
         <glx ignore="true"/>
     </function>
 
         <glx ignore="true"/>
     </function>
 
index a6826251ca77b3e83843971e27ef13ca4919f00f..f21d0f65ff877f79253facb4ca32fe2b979dae6d 100644 (file)
@@ -119,18 +119,14 @@ class PrintCode(gl_XML.gl_print_base):
                     out('cmd->{0}_null = !{0};'.format(p.name))
                     out('if (!cmd->{0}_null) {{'.format(p.name))
                     with indent():
                     out('cmd->{0}_null = !{0};'.format(p.name))
                     out('if (!cmd->{0}_null) {{'.format(p.name))
                     with indent():
-                        out(('memcpy(variable_data, {0}, {1});').format(
-                            p.name, p.size_string(False)))
+                        out(('memcpy(variable_data, {0}, {0}_size);').format(p.name))
                         if i < len(func.variable_params):
                         if i < len(func.variable_params):
-                            out('variable_data += {0};'.format(
-                                p.size_string(False)))
+                            out('variable_data += {0}_size;'.format(p.name))
                     out('}')
                 else:
                     out('}')
                 else:
-                    out(('memcpy(variable_data, {0}, {1});').format(
-                        p.name, p.size_string(False)))
+                    out(('memcpy(variable_data, {0}, {0}_size);').format(p.name))
                     if i < len(func.variable_params):
                     if i < len(func.variable_params):
-                        out('variable_data += {0};'.format(
-                            p.size_string(False)))
+                        out('variable_data += {0}_size;'.format(p.name))
                 i += 1
 
         if not func.fixed_params and not func.variable_params:
                 i += 1
 
         if not func.fixed_params and not func.variable_params:
@@ -221,7 +217,7 @@ class PrintCode(gl_XML.gl_print_base):
         # get to the validation in Mesa core.
         for p in func.parameters:
             if p.is_variable_length():
         # get to the validation in Mesa core.
         for p in func.parameters:
             if p.is_variable_length():
-                out('if (unlikely({0} < 0)) {{'.format(p.size_string()))
+                out('if (unlikely({0}_size < 0)) {{'.format(p.name))
                 with indent():
                     out('goto fallback_to_sync;')
                 out('}')
                 with indent():
                     out('goto fallback_to_sync;')
                 out('}')
@@ -237,13 +233,16 @@ class PrintCode(gl_XML.gl_print_base):
         out('{')
         with indent():
             out('GET_CURRENT_CONTEXT(ctx);')
         out('{')
         with indent():
             out('GET_CURRENT_CONTEXT(ctx);')
+            for p in func.variable_params:
+                out('int {0}_size = {1};'.format(p.name, p.size_string()))
+
             struct = 'struct marshal_cmd_{0}'.format(func.name)
             size_terms = ['sizeof({0})'.format(struct)]
             for p in func.variable_params:
             struct = 'struct marshal_cmd_{0}'.format(func.name)
             size_terms = ['sizeof({0})'.format(struct)]
             for p in func.variable_params:
-                size = p.size_string()
                 if p.img_null_flag:
                 if p.img_null_flag:
-                    size = '({0} ? {1} : 0)'.format(p.name, size)
-                size_terms.append(size)
+                    size_terms.append('({0} ? {0}_size : 0)'.format(p.name))
+                else:
+                    size_terms.append('{0}_size'.format(p.name))
             out('int cmd_size = {0};'.format(' + '.join(size_terms)))
             out('{0} *cmd;'.format(struct))
 
             out('int cmd_size = {0};'.format(' + '.join(size_terms)))
             out('{0} *cmd;'.format(struct))