mesa: Add support for NULL arguments like in glBufferData() in marshalling.
authorEric Anholt <eric@anholt.net>
Wed, 27 Feb 2013 21:37:14 +0000 (13:37 -0800)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 16 Mar 2017 03:14:19 +0000 (14:14 +1100)
This will let us support things like glBufferData() that should be
asynchronous.

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/gl_marshal.py
src/mapi/glapi/gen/marshal_XML.py

index e4137f46abe2242a842f88fa7fcdec63fe1939a5..3b9868f9a1f5e0b746bfde4e3c24ce55577362f4 100644 (file)
@@ -118,10 +118,21 @@ class PrintCode(gl_XML.gl_print_base):
         if func.variable_params:
             out('char *variable_data = (char *) (cmd + 1);')
             for p in func.variable_params:
-                out(('memcpy(variable_data, {0}, {1});').format(
+                if p.img_null_flag:
+                    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('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(
+                    out('variable_data += {0};'.format(
                         p.size_string(False)))
+
         if not func.fixed_params and not func.variable_params:
             out('(void) cmd;\n')
         out('_mesa_post_marshal_hook(ctx);')
@@ -137,6 +148,12 @@ class PrintCode(gl_XML.gl_print_base):
                             p.get_base_type_string(), p.name, p.count))
                 else:
                     out('{0} {1};'.format(p.type_string(), p.name))
+
+            for p in func.variable_params:
+                if p.img_null_flag:
+                    out('bool {0}_null; /* If set, no data follows '
+                        'for "{0}" */'.format(p.name))
+
             for p in func.variable_params:
                 if p.count_scale != 1:
                     out(('/* Next {0} bytes are '
@@ -171,7 +188,17 @@ class PrintCode(gl_XML.gl_print_base):
                 for p in func.variable_params:
                     out('{0} = (const {1} *) variable_data;'.format(
                             p.name, p.get_base_type_string()))
-                    out('variable_data += {0};'.format(p.size_string(False)))
+
+                    if p.img_null_flag:
+                        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:
+                        out('variable_data += {0};'.format(p.size_string(False)))
+
             self.print_sync_call(func)
         out('}')
 
@@ -198,7 +225,10 @@ class PrintCode(gl_XML.gl_print_base):
             struct = 'struct marshal_cmd_{0}'.format(func.name)
             size_terms = ['sizeof({0})'.format(struct)]
             for p in func.variable_params:
-                size_terms.append(p.size_string())
+                size = p.size_string()
+                if p.img_null_flag:
+                    size = '({0} ? {1} : 0)'.format(p.name, size)
+                size_terms.append(size)
             out('size_t cmd_size = {0};'.format(' + '.join(size_terms)))
             out('{0} *cmd;'.format(struct))
 
index e8ddb7ff8f685f995a02db43e1d20019a46aec48..9d5688decac186fbab901da172d6823fc52c45d7 100644 (file)
@@ -88,9 +88,4 @@ class marshal_function(gl_XML.gl_function):
                 # Parameter size is determined by enums; haven't
                 # written logic to handle this yet.  TODO: fix.
                 return 'sync'
-            if p.img_null_flag:
-                # Caller is allowed to pass NULL for this parameter;
-                # haven't written logic to handle this yet.  TODO:
-                # fix.
-                return 'sync'
         return 'async'