]> git.cworth.org Git - apitrace/blobdiff - wrappers/gltrace.py
gltrace: Expose marker functions when tracing is disabled.
[apitrace] / wrappers / gltrace.py
index e9169ce8501d86b39ad5baff880de5e8eb806698..e73c5918140dcc63e6030cf7fb3b762ebff304eb 100644 (file)
@@ -700,12 +700,24 @@ class GlTracer(Tracer):
             # These functions have been dispatched already
             return
 
+        Tracer.invokeFunction(self, function)
+
+    def doInvokeFunction(self, function):
+        # Same as invokeFunction() but called both when trace is enabled or disabled.
+        #
+        # Used to modify the behavior of GL entry-points.
+
+        # Override GL extensions
+        if function.name in ('glGetString', 'glGetIntegerv', 'glGetStringi'):
+            Tracer.doInvokeFunction(self, function, prefix = 'gltrace::_', suffix = '_override')
+            return
+
         # We implement GL_EXT_debug_marker, GL_GREMEDY_*, etc., and not the
         # driver
         if function.name in self.marker_functions:
             return
 
-        if function.name in ('glXGetProcAddress', 'glXGetProcAddressARB', 'wglGetProcAddress'):
+        if function.name in self.getProcAddressFunctionNames:
             else_ = ''
             for marker_function in self.marker_functions:
                 if self.api.getFunctionByName(marker_function):
@@ -714,16 +726,19 @@ class GlTracer(Tracer):
                     print '    }'
                 else_ = 'else '
             print '    %s{' % else_
-            Tracer.invokeFunction(self, function)
-            print '    }'
-            return
+            Tracer.doInvokeFunction(self, function)
 
-        # Override GL extensions
-        if function.name in ('glGetString', 'glGetIntegerv', 'glGetStringi'):
-            Tracer.invokeFunction(self, function, prefix = 'gltrace::_', suffix = '_override')
+            # Replace function addresses with ours
+            # XXX: Doing this here instead of wrapRet means that the trace will
+            # contain the addresses of the wrapper functions, and not the real
+            # functions, but in practice this should make no difference.
+            if function.name in self.getProcAddressFunctionNames:
+                print '    _result = _wrapProcAddress(%s, _result);' % (function.args[0].name,)
+
+            print '    }'
             return
 
-        Tracer.invokeFunction(self, function)
+        Tracer.doInvokeFunction(self, function)
 
     buffer_targets = [
         'ARRAY_BUFFER',
@@ -742,10 +757,6 @@ class GlTracer(Tracer):
     def wrapRet(self, function, instance):
         Tracer.wrapRet(self, function, instance)
 
-        # Replace function addresses with ours
-        if function.name in self.getProcAddressFunctionNames:
-            print '    %s = _wrapProcAddress(%s, %s);' % (instance, function.args[0].name, instance)
-
         # Keep track of buffer mappings
         if function.name in ('glMapBuffer', 'glMapBufferARB'):
             print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'