#include "dispatch.h"
#include "glthread.h"
#include "marshal.h"
+
+#define COMPAT (ctx->API != API_OPENGL_CORE)
"""
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)
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);')
if p.count_scale != 1:
out(('/* Next {0} bytes are '
'{1} {2}[{3}][{4}] */').format(
- p.size_string(), p.get_base_type_string(),
+ p.size_string(marshal = 1), p.get_base_type_string(),
p.name, p.counter, p.count_scale))
else:
out(('/* Next {0} bytes are '
'{1} {2}[{3}] */').format(
- p.size_string(), p.get_base_type_string(),
+ p.size_string(marshal = 1), p.get_base_type_string(),
p.name, p.counter))
out('};')
if i < len(func.variable_params):
out('else')
with indent():
- out('variable_data += {0};'.format(p.size_string(False)))
+ out('variable_data += {0};'.format(p.size_string(False, marshal = 1)))
elif i < len(func.variable_params):
- out('variable_data += {0};'.format(p.size_string(False)))
+ 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):
# Check that any counts for variable-length arguments might be < 0, in
# which case the command alloc or the memcpy would blow up before we
# get to the validation in Mesa core.
+ list = []
for p in func.parameters:
if p.is_variable_length():
- out('if (unlikely({0}_size < 0)) {{'.format(p.name))
- with indent():
- out('goto fallback_to_sync;')
- out('}')
- return True
- return False
+ list.append('{0}_size < 0'.format(p.name))
+ list.append('({0}_size > 0 && !{0})'.format(p.name))
+ if len(list) == 0:
+ return
+
+ list.append('(unsigned)cmd_size > MARSHAL_MAX_CMD_SIZE')
+
+ out('if (unlikely({0})) {{'.format(' || '.join(list)))
+ with indent():
+ out('_mesa_glthread_finish_before(ctx, "{0}");'.format(func.name))
+ self.print_sync_dispatch(func)
+ out('return;')
+ out('}')
def print_async_marshal(self, func):
- need_fallback_sync = False
out('static void GLAPIENTRY')
out('_mesa_marshal_{0}({1})'.format(
func.name, func.get_parameter_string()))
with indent():
out('GET_CURRENT_CONTEXT(ctx);')
for p in func.variable_params:
- out('int {0}_size = {1};'.format(p.name, p.size_string()))
+ out('int {0}_size = {1};'.format(p.name, p.size_string(marshal = 1)))
struct = 'struct marshal_cmd_{0}'.format(func.name)
size_terms = ['sizeof({0})'.format(struct)]
out('int cmd_size = {0};'.format(' + '.join(size_terms)))
out('{0} *cmd;'.format(struct))
- out('debug_print_marshal("{0}");'.format(func.name))
-
- need_fallback_sync = self.validate_count_or_fallback(func)
+ self.validate_count_or_fallback(func)
if func.marshal_fail:
out('if ({0}) {{'.format(func.marshal_fail))
out('return;')
out('}')
- if len(func.variable_params) > 0:
- with indent():
- out('if (cmd_size <= MARSHAL_MAX_CMD_SIZE) {')
+ if func.marshal_sync:
+ out('if ({0}) {{'.format(func.marshal_sync))
with indent():
- self.print_async_dispatch(func)
+ out('_mesa_glthread_finish_before(ctx, "{0}");'.format(func.name))
+ self.print_sync_dispatch(func)
out('return;')
out('}')
- out('')
- if need_fallback_sync:
- out('fallback_to_sync:')
- with indent():
- out('_mesa_glthread_finish_before(ctx, "{0}");'.format(func.name))
- self.print_sync_dispatch(func)
- else:
- with indent():
- self.print_async_dispatch(func)
- assert not need_fallback_sync
+
+ with indent():
+ self.print_async_dispatch(func)
out('}')
def print_async_body(self, func):