]> git.cworth.org Git - apitrace/blobdiff - retrace/retrace.py
Fix D3D11 tracing with D3D11_CREATE_DEVICE_DEBUG flag.
[apitrace] / retrace / retrace.py
index 6206905dcd787d166f95617a4a851a99466ce09d..51da6fec24ff2ec78beeb280fd3f591b9a62178e 100644 (file)
@@ -323,6 +323,9 @@ class Retracer:
     def retraceFunctionBody(self, function):
         assert function.sideeffects
 
+        if function.type is not stdapi.Void:
+            self.checkOrigResult(function)
+
         self.deserializeArgs(function)
         
         self.invokeFunction(function)
@@ -332,6 +335,9 @@ class Retracer:
     def retraceInterfaceMethodBody(self, interface, method):
         assert method.sideeffects
 
+        if method.type is not stdapi.Void:
+            self.checkOrigResult(method)
+
         self.deserializeThisPointer(interface)
 
         self.deserializeArgs(method)
@@ -340,6 +346,18 @@ class Retracer:
 
         self.swizzleValues(method)
 
+    def checkOrigResult(self, function):
+        '''Hook for checking the original result, to prevent succeeding now
+        where the original did not, which would cause diversion and potentially
+        unpredictable results.'''
+
+        assert function.type is not stdapi.Void
+
+        if str(function.type) == 'HRESULT':
+            print r'    if (call.ret && FAILED(call.ret->toSInt())) {'
+            print r'        return;'
+            print r'    }'
+
     def deserializeThisPointer(self, interface):
         print r'    %s *_this;' % (interface.name,)
         print r'    _this = static_cast<%s *>(_obj_map[call.arg(0).toUIntPtr()]);' % (interface.name,)
@@ -468,20 +486,21 @@ class Retracer:
 
         functions = filter(self.filterFunction, api.functions)
         for function in functions:
-            if function.sideeffects:
+            if function.sideeffects and not function.internal:
                 self.retraceFunction(function)
         interfaces = api.getAllInterfaces()
         for interface in interfaces:
             for method in interface.iterMethods():
-                if method.sideeffects:
+                if method.sideeffects and not method.internal:
                     self.retraceInterfaceMethod(interface, method)
 
         print 'const retrace::Entry %s[] = {' % self.table_name
         for function in functions:
-            if function.sideeffects:
-                print '    {"%s", &retrace_%s},' % (function.name, function.name)
-            else:
-                print '    {"%s", &retrace::ignore},' % (function.name,)
+            if not function.internal:
+                if function.sideeffects:
+                    print '    {"%s", &retrace_%s},' % (function.name, function.name)
+                else:
+                    print '    {"%s", &retrace::ignore},' % (function.name,)
         for interface in interfaces:
             for method in interface.iterMethods():                
                 if method.sideeffects: