X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=gltrace.py;h=9224bbeb4ba15b0048dcba8a7181721f958acd8a;hb=124cd34846abf59579fe7cbd819a3a719a07a29f;hp=4280b91f2eac4fb26832de62d06c7047422a0fcd;hpb=5a568a9aa9262a5b653fddbe8e89d2f9438ec4d2;p=apitrace diff --git a/gltrace.py b/gltrace.py index 4280b91..9224bbe 100644 --- a/gltrace.py +++ b/gltrace.py @@ -107,6 +107,8 @@ class GlTracer(Tracer): def header(self, api): Tracer.header(self, api) + print '#include "gltrace.hpp"' + print print '// Whether user arrays were used' print 'static bool __user_arrays = false;' print 'static bool __user_arrays_arb = false;' @@ -121,7 +123,7 @@ class GlTracer(Tracer): print '};' print print 'static vertex_attrib __get_vertex_attrib(void) {' - print ' if (__user_arrays_arb) {' + print ' if (__user_arrays_arb || __user_arrays_nv) {' print ' GLboolean __vertex_program = GL_FALSE;' print ' __glGetBooleanv(GL_VERTEX_PROGRAM_ARB, &__vertex_program);' print ' if (__vertex_program) {' @@ -410,13 +412,13 @@ class GlTracer(Tracer): # Emit a fake function print ' {' print ' static const Trace::FunctionSig &__sig = %s ? __glEnableClientState_sig : __glDisableClientState_sig;' % flag_name - print ' unsigned __call = __writer.beginEnter(&__sig);' - print ' __writer.beginArg(0);' + print ' unsigned __call = Trace::localWriter.beginEnter(&__sig);' + print ' Trace::localWriter.beginArg(0);' dump_instance(glapi.GLenum, enable_name) - print ' __writer.endArg();' - print ' __writer.endEnter();' - print ' __writer.beginLeave(__call);' - print ' __writer.endLeave();' + print ' Trace::localWriter.endArg();' + print ' Trace::localWriter.endEnter();' + print ' Trace::localWriter.beginLeave(__call);' + print ' Trace::localWriter.endLeave();' print ' }' print ' return;' @@ -492,27 +494,48 @@ class GlTracer(Tracer): Tracer.trace_function_impl_body(self, function) + gremedy_functions = [ + 'glStringMarkerGREMEDY', + 'glFrameTerminatorGREMEDY', + ] + def dispatch_function(self, function): if function.name in ('glLinkProgram', 'glLinkProgramARB'): # These functions have been dispatched already return + # We implement the GREMEDY extensions, not the driver + if function.name in self.gremedy_functions: + return + + if function.name in ('glXGetProcAddress', 'glXGetProcAddressARB', 'wglGetProcAddress'): + if_ = 'if' + for gremedy_function in self.gremedy_functions: + print ' %s (strcmp("%s", (const char *)%s) == 0) {' % (if_, gremedy_function, function.args[0].name) + print ' __result = (%s)&%s;' % (function.type, gremedy_function) + print ' }' + if_ = 'else if' + print ' else {' + Tracer.dispatch_function(self, function) + print ' }' + return + Tracer.dispatch_function(self, function) def emit_memcpy(self, dest, src, length): - print ' unsigned __call = __writer.beginEnter(&__memcpy_sig);' - print ' __writer.beginArg(0);' - print ' __writer.writeOpaque(%s);' % dest - print ' __writer.endArg();' - print ' __writer.beginArg(1);' - print ' __writer.writeBlob(%s, %s);' % (src, length) - print ' __writer.endArg();' - print ' __writer.beginArg(2);' - print ' __writer.writeUInt(%s);' % length - print ' __writer.endArg();' - print ' __writer.endEnter();' - print ' __writer.beginLeave(__call);' - print ' __writer.endLeave();' + print ' unsigned __call = Trace::localWriter.beginEnter(&__memcpy_sig);' + print ' Trace::localWriter.beginArg(0);' + print ' Trace::localWriter.writeOpaque(%s);' % dest + print ' Trace::localWriter.endArg();' + print ' Trace::localWriter.beginArg(1);' + print ' Trace::localWriter.writeBlob(%s, %s);' % (src, length) + print ' Trace::localWriter.endArg();' + print ' Trace::localWriter.beginArg(2);' + print ' Trace::localWriter.writeUInt(%s);' % length + print ' Trace::localWriter.endArg();' + print ' Trace::localWriter.endEnter();' + print ' Trace::localWriter.beginLeave(__call);' + print ' Trace::localWriter.endLeave();' buffer_targets = [ 'ARRAY_BUFFER', @@ -523,6 +546,17 @@ class GlTracer(Tracer): def wrap_ret(self, function, instance): Tracer.wrap_ret(self, function, instance) + + if function.name == 'glGetString': + print ' if (__result) {' + print ' switch (name) {' + print ' case GL_EXTENSIONS:' + print ' __result = gltrace::translateExtensionsString(__result);' + print ' break;' + print ' default:' + print ' break;' + print ' }' + print ' }' if function.name in ('glMapBuffer', 'glMapBufferARB'): print ' struct buffer_mapping *mapping = get_buffer_mapping(target);' @@ -603,15 +637,15 @@ class GlTracer(Tracer): print ' __glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &__element_array_buffer);' print ' if (!__element_array_buffer) {' if isinstance(arg.type, stdapi.Array): - print ' __writer.beginArray(%s);' % arg.type.length + print ' Trace::localWriter.beginArray(%s);' % arg.type.length print ' for(GLsizei i = 0; i < %s; ++i) {' % arg.type.length - print ' __writer.beginElement();' - print ' __writer.writeBlob(%s[i], count[i]*__gl_type_size(type));' % (arg.name) - print ' __writer.endElement();' + print ' Trace::localWriter.beginElement();' + print ' Trace::localWriter.writeBlob(%s[i], count[i]*__gl_type_size(type));' % (arg.name) + print ' Trace::localWriter.endElement();' print ' }' - print ' __writer.endArray();' + print ' Trace::localWriter.endArray();' else: - print ' __writer.writeBlob(%s, count*__gl_type_size(type));' % (arg.name) + print ' Trace::localWriter.writeBlob(%s, count*__gl_type_size(type));' % (arg.name) print ' } else {' Tracer.dump_arg_instance(self, function, arg) print ' }' @@ -626,7 +660,7 @@ class GlTracer(Tracer): print ' GLint __unpack_buffer = 0;' print ' __glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &__unpack_buffer);' print ' if (__unpack_buffer) {' - print ' __writer.writeOpaque(%s);' % arg.name + print ' Trace::localWriter.writeOpaque(%s);' % arg.name print ' } else {' Tracer.dump_arg_instance(self, function, arg) print ' }' @@ -684,19 +718,19 @@ class GlTracer(Tracer): # Emit a fake function self.array_trace_intermezzo(api, uppercase_name) - print ' unsigned __call = __writer.beginEnter(&__%s_sig);' % (function.name,) + print ' unsigned __call = Trace::localWriter.beginEnter(&__%s_sig);' % (function.name,) for arg in function.args: assert not arg.output - print ' __writer.beginArg(%u);' % (arg.index,) + print ' Trace::localWriter.beginArg(%u);' % (arg.index,) if arg.name != 'pointer': dump_instance(arg.type, arg.name) else: - print ' __writer.writeBlob((const void *)%s, __size);' % (arg.name) - print ' __writer.endArg();' + print ' Trace::localWriter.writeBlob((const void *)%s, __size);' % (arg.name) + print ' Trace::localWriter.endArg();' - print ' __writer.endEnter();' - print ' __writer.beginLeave(__call);' - print ' __writer.endLeave();' + print ' Trace::localWriter.endEnter();' + print ' Trace::localWriter.beginLeave(__call);' + print ' Trace::localWriter.endLeave();' print ' }' print ' }' self.array_epilog(api, uppercase_name) @@ -757,19 +791,19 @@ class GlTracer(Tracer): print ' size_t __size = __%s_size(%s, maxindex);' % (function.name, arg_names) # Emit a fake function - print ' unsigned __call = __writer.beginEnter(&__%s_sig);' % (function.name,) + print ' unsigned __call = Trace::localWriter.beginEnter(&__%s_sig);' % (function.name,) for arg in function.args: assert not arg.output - print ' __writer.beginArg(%u);' % (arg.index,) + print ' Trace::localWriter.beginArg(%u);' % (arg.index,) if arg.name != 'pointer': dump_instance(arg.type, arg.name) else: - print ' __writer.writeBlob((const void *)%s, __size);' % (arg.name) - print ' __writer.endArg();' + print ' Trace::localWriter.writeBlob((const void *)%s, __size);' % (arg.name) + print ' Trace::localWriter.endArg();' - print ' __writer.endEnter();' - print ' __writer.beginLeave(__call);' - print ' __writer.endLeave();' + print ' Trace::localWriter.endEnter();' + print ' Trace::localWriter.beginLeave(__call);' + print ' Trace::localWriter.endLeave();' print ' }' print ' }' print ' }' @@ -825,15 +859,15 @@ class GlTracer(Tracer): self.fake_call(function, [texture]) def fake_call(self, function, args): - print ' unsigned __fake_call = __writer.beginEnter(&__%s_sig);' % (function.name,) + print ' unsigned __fake_call = Trace::localWriter.beginEnter(&__%s_sig);' % (function.name,) for arg, instance in zip(function.args, args): assert not arg.output - print ' __writer.beginArg(%u);' % (arg.index,) + print ' Trace::localWriter.beginArg(%u);' % (arg.index,) dump_instance(arg.type, instance) - print ' __writer.endArg();' - print ' __writer.endEnter();' - print ' __writer.beginLeave(__fake_call);' - print ' __writer.endLeave();' + print ' Trace::localWriter.endArg();' + print ' Trace::localWriter.endEnter();' + print ' Trace::localWriter.beginLeave(__fake_call);' + print ' Trace::localWriter.endLeave();'