]> git.cworth.org Git - apitrace/commitdiff
gltrace: Expose marker functions when tracing is disabled.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 10 Jun 2013 07:05:29 +0000 (08:05 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 10 Jun 2013 07:21:47 +0000 (08:21 +0100)
Matches the output of change proposed by Peter Lohrmann in issue #138,
but with slightly less new code.

This is achieved by adding a new hook point, doInvokeFunction (could not
think of a better name), used to generate the call to the real function,
both when trace is enabled or disabled.

wrappers/gltrace.py
wrappers/trace.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);'
index 4abd20eeb6920f72ca6e80548b1d7c14ebee97cf..31087e92b722c9ef4b6991078172a67551d1500f 100644 (file)
@@ -474,7 +474,7 @@ class Tracer:
 
         # No-op if tracing is disabled
         print '    if (!trace::isTracingEnabled()) {'
-        Tracer.invokeFunction(self, function)
+        self.doInvokeFunction(function)
         if function.type is not stdapi.Void:
             print '        return _result;'
         else:
@@ -512,7 +512,11 @@ class Tracer:
                 self.wrapRet(function, "_result")
             print '    trace::localWriter.endLeave();'
 
-    def invokeFunction(self, function, prefix='_', suffix=''):
+    def invokeFunction(self, function):
+        self.doInvokeFunction(function)
+
+    def doInvokeFunction(self, function, prefix='_', suffix=''):
+        # Same as invokeFunction() but called both when trace is enabled or disabled.
         if function.type is stdapi.Void:
             result = ''
         else: