From 358d923c8b40e71738cb3a3fb0413260361bec9b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 19 Feb 2020 19:41:25 -0500 Subject: [PATCH] glthread: handle complex pointer parameters and support GL functions with strings The python changes add a local variable that computes the parameter size only once. Reviewed-by: Timothy Arceri Part-of: --- .../glapi/gen/ARB_blend_func_extended.xml | 2 +- src/mapi/glapi/gen/ARB_gl_spirv.xml | 6 ++--- src/mapi/glapi/gen/GL3x.xml | 2 +- src/mapi/glapi/gen/gl_API.xml | 2 +- src/mapi/glapi/gen/gl_marshal.py | 23 +++++++++---------- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_blend_func_extended.xml b/src/mapi/glapi/gen/ARB_blend_func_extended.xml index 10d85a76621..9b66fa2eea7 100644 --- a/src/mapi/glapi/gen/ARB_blend_func_extended.xml +++ b/src/mapi/glapi/gen/ARB_blend_func_extended.xml @@ -12,7 +12,7 @@ - + diff --git a/src/mapi/glapi/gen/ARB_gl_spirv.xml b/src/mapi/glapi/gen/ARB_gl_spirv.xml index 0dd615480f7..a963b001e61 100644 --- a/src/mapi/glapi/gen/ARB_gl_spirv.xml +++ b/src/mapi/glapi/gen/ARB_gl_spirv.xml @@ -10,10 +10,10 @@ - + - - + + diff --git a/src/mapi/glapi/gen/GL3x.xml b/src/mapi/glapi/gen/GL3x.xml index cd3987e0ceb..3ffc1667607 100644 --- a/src/mapi/glapi/gen/GL3x.xml +++ b/src/mapi/glapi/gen/GL3x.xml @@ -203,7 +203,7 @@ - + diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 2bec492f7d1..a33e82ad53d 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -5304,7 +5304,7 @@ - + diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py index a6826251ca7..f21d0f65ff8 100644 --- a/src/mapi/glapi/gen/gl_marshal.py +++ b/src/mapi/glapi/gen/gl_marshal.py @@ -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(('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): - out('variable_data += {0};'.format( - p.size_string(False))) + out('variable_data += {0}_size;'.format(p.name)) 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): - 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: @@ -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(): - 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('}') @@ -237,13 +233,16 @@ class PrintCode(gl_XML.gl_print_base): 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: - size = p.size_string() 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)) -- 2.30.2