]> git.cworth.org Git - apitrace/blobdiff - retrace/d3dcommonretrace.py
d3dretrace: Single retrace for d3d10 and higher
[apitrace] / retrace / d3dcommonretrace.py
index 75262c2c62a1457db7dbb677d82a8cf7be640c6a..9cd5da51f579cad0011edc22e80aa7071a351862 100644 (file)
 """D3D retracer generator."""
 
 
+import sys
 from dllretrace import DllRetracer as Retracer
-import specs.stdapi as stdapi
+from specs.stdapi import API
+from specs.dxgi import dxgi
+from specs.d3d10 import d3d10
+from specs.d3d10_1 import d3d10_1
+from specs.d3d11 import d3d11
 
 
 class D3DRetracer(Retracer):
 
-    def retraceModule(self, api):
+    def retraceApi(self, api):
+        print '''
+image::Image *
+retrace::getSnapshot(void) {
+    return NULL;
+}
+
+
+bool
+retrace::dumpState(std::ostream &os)
+{
+    return false;
+}
+'''
+
         print '// Swizzling mapping for lock addresses'
         print 'static std::map<void *, void *> _maps;'
         print
 
         self.table_name = 'd3dretrace::d3d_callbacks'
 
-        Retracer.retraceModule(self, api)
+        Retracer.retraceApi(self, api)
 
     def invokeFunction(self, function):
         # create windows as neccessary
@@ -92,3 +111,42 @@ class D3DRetracer(Retracer):
             print '    if (_pbData) {'
             print '        retrace::delRegionByPointer(_pbData);'
             print '    }'
+
+
+def main():
+    print r'''#include <string.h>'''
+    print
+    print r'#include <iostream>'
+    print
+    print r'#include "d3dretrace.hpp"'
+    print
+
+    moduleNames = sys.argv[1:]
+
+    api = API()
+    if moduleNames:
+        api.addModule(dxgi)
+    if 'd3d10' in moduleNames:
+        if 'd3d10_1' in moduleNames:
+            print r'#include "d3d10_1imports.hpp"'
+            # D3D10CreateBlob is duplicated in d3d10 and d3d10_1
+            d3d10_1.functions = [function for function in d3d10_1.functions if function.name != 'D3D10CreateBlob']
+            api.addModule(d3d10_1)
+        else:
+            print r'#include "d3d10imports.hpp"'
+        print r'#include "d3d10size.hpp"'
+        api.addModule(d3d10)
+    if 'd3d11' in moduleNames:
+        print r'#include "d3d11imports.hpp"'
+        if 'd3d11_1' in moduleNames:
+            print '#include <d3d11_1.h>'
+            import specs.d3d11_1
+        print r'#include "d3d11size.hpp"'
+        api.addModule(d3d11)
+
+    retracer = D3DRetracer()
+    retracer.retraceApi(api)
+
+
+if __name__ == '__main__':
+    main()