glthread: don't increment variable_data if it's the last variable-size param
authorMarek Olšák <marek.olsak@amd.com>
Wed, 19 Feb 2020 23:45:56 +0000 (18:45 -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

index 261213b7442856551f50aae5890a5b5781edcb73..a6826251ca77b3e83843971e27ef13ca4919f00f 100644 (file)
@@ -113,6 +113,7 @@ class PrintCode(gl_XML.gl_print_base):
                 out('cmd->{0} = {0};'.format(p.name))
         if func.variable_params:
             out('char *variable_data = (char *) (cmd + 1);')
+            i = 1
             for p in func.variable_params:
                 if p.img_null_flag:
                     out('cmd->{0}_null = !{0};'.format(p.name))
@@ -120,14 +121,17 @@ class PrintCode(gl_XML.gl_print_base):
                     with indent():
                         out(('memcpy(variable_data, {0}, {1});').format(
                             p.name, p.size_string(False)))
-                        out('variable_data += {0};'.format(
-                            p.size_string(False)))
+                        if i < len(func.variable_params):
+                            out('variable_data += {0};'.format(
+                                p.size_string(False)))
                     out('}')
                 else:
                     out(('memcpy(variable_data, {0}, {1});').format(
                         p.name, p.size_string(False)))
-                    out('variable_data += {0};'.format(
-                        p.size_string(False)))
+                    if i < len(func.variable_params):
+                        out('variable_data += {0};'.format(
+                            p.size_string(False)))
+                i += 1
 
         if not func.fixed_params and not func.variable_params:
             out('(void) cmd;\n')
@@ -191,6 +195,7 @@ class PrintCode(gl_XML.gl_print_base):
                     out('{0} * {1};'.format(
                             p.get_base_type_string(), p.name))
                 out('const char *variable_data = (const char *) (cmd + 1);')
+                i = 1
                 for p in func.variable_params:
                     out('{0} = ({1} *) variable_data;'.format(
                             p.name, p.get_base_type_string()))
@@ -199,11 +204,13 @@ class PrintCode(gl_XML.gl_print_base):
                         out('if (cmd->{0}_null)'.format(p.name))
                         with indent():
                             out('{0} = NULL;'.format(p.name))
-                        out('else')
-                        with indent():
-                            out('variable_data += {0};'.format(p.size_string(False)))
-                    else:
+                        if i < len(func.variable_params):
+                            out('else')
+                            with indent():
+                                out('variable_data += {0};'.format(p.size_string(False)))
+                    elif i < len(func.variable_params):
                         out('variable_data += {0};'.format(p.size_string(False)))
+                    i += 1
 
             self.print_sync_call(func)
         out('}')