X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=blobdiff_plain;f=src%2Fmapi%2Fglapi%2Fgen%2Fgl_marshal.py;h=da71a1de787097047887167485ae33a547f35fc3;hp=a421c95dcfe2d3f63c0cb973c5c2af5e2c9b0bf5;hb=8a4114b9294c8e8f5bb977be47cc7764c9cdf490;hpb=59e96bc513be3938e2d6dc4357e4d38fa5481f6a diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py index a421c95dcfe..da71a1de787 100644 --- a/src/mapi/glapi/gen/gl_marshal.py +++ b/src/mapi/glapi/gen/gl_marshal.py @@ -31,10 +31,18 @@ import sys header = """ #include "api_exec.h" -#include "context.h" +#include "glthread_marshal.h" #include "dispatch.h" -#include "glthread.h" -#include "marshal.h" + +#define COMPAT (ctx->API != API_OPENGL_CORE) + +static inline int safe_mul(int a, int b) +{ + if (a < 0 || b < 0) return -1; + if (a == 0 || b == 0) return 0; + if (a > INT_MAX / b) return -1; + return a * b; +} """ @@ -66,25 +74,20 @@ class PrintCode(gl_XML.gl_print_base): def printRealHeader(self): print(header) - print('static inline int safe_mul(int a, int b)') - print('{') - print(' if (a < 0 || b < 0) return -1;') - print(' if (a == 0 || b == 0) return 0;') - print(' if (a > INT_MAX / b) return -1;') - print(' return a * b;') - print('}') - print() def printRealFooter(self): pass - def print_sync_call(self, func): + def print_sync_call(self, func, unmarshal = 0): call = 'CALL_{0}(ctx->CurrentServerDispatch, ({1}))'.format( func.name, func.get_called_parameter_string()) if func.return_type == 'void': out('{0};'.format(call)) + if func.marshal_call_after and not unmarshal: + out(func.marshal_call_after); else: out('return {0};'.format(call)) + assert not func.marshal_call_after def print_sync_dispatch(self, func): self.print_sync_call(func) @@ -130,7 +133,10 @@ class PrintCode(gl_XML.gl_print_base): i += 1 if not func.fixed_params and not func.variable_params: - out('(void) cmd;\n') + out('(void) cmd;') + + if func.marshal_call_after: + out(func.marshal_call_after); # Uncomment this if you want to call _mesa_glthread_finish for debugging #out('_mesa_glthread_finish(ctx);') @@ -166,7 +172,7 @@ class PrintCode(gl_XML.gl_print_base): out('};') def print_async_unmarshal(self, func): - out('static inline void') + out('static void') out(('_mesa_unmarshal_{0}(struct gl_context *ctx, ' 'const struct marshal_cmd_{0} *cmd)').format(func.name)) out('{') @@ -208,7 +214,7 @@ class PrintCode(gl_XML.gl_print_base): out('variable_data += {0};'.format(p.size_string(False, marshal = 1))) i += 1 - self.print_sync_call(func) + self.print_sync_call(func, unmarshal = 1) out('}') def validate_count_or_fallback(self, func): @@ -219,6 +225,7 @@ class PrintCode(gl_XML.gl_print_base): for p in func.parameters: if p.is_variable_length(): list.append('{0}_size < 0'.format(p.name)) + list.append('({0}_size > 0 && !{0})'.format(p.name)) if len(list) == 0: return @@ -252,8 +259,6 @@ class PrintCode(gl_XML.gl_print_base): out('int cmd_size = {0};'.format(' + '.join(size_terms))) out('{0} *cmd;'.format(struct)) - out('debug_print_marshal("{0}");'.format(func.name)) - self.validate_count_or_fallback(func) if func.marshal_fail: @@ -264,6 +269,14 @@ class PrintCode(gl_XML.gl_print_base): out('return;') out('}') + if func.marshal_sync: + out('if ({0}) {{'.format(func.marshal_sync)) + with indent(): + out('_mesa_glthread_finish_before(ctx, "{0}");'.format(func.name)) + self.print_sync_dispatch(func) + out('return;') + out('}') + with indent(): self.print_async_dispatch(func) out('}')