]> git.cworth.org Git - apitrace/commitdiff
d3dretrace: Use consistent filenames.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 24 Nov 2012 09:30:50 +0000 (09:30 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 24 Nov 2012 09:30:50 +0000 (09:30 +0000)
retrace/.gitignore
retrace/CMakeLists.txt
retrace/d3dcommonretrace.py [deleted file]
retrace/dxgiretrace.py [new file with mode: 0644]

index ebcad87ca6edbdf6adeaf0cd626172a155367956..978f7a334d64567e18983afcc91c81588028d5cb 100644 (file)
@@ -1,2 +1,4 @@
+d3dretrace_d3d9.cpp
+d3dretrace_dxgi.cpp
 glretrace_gl.cpp
 glstate_params.cpp
index fd51c2dd9ede6f39416a65d727e7f061b1b880a5..b3068fc8fb1578860ea4f9b8e8b3052976037c7e 100644 (file)
@@ -173,10 +173,10 @@ if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
     endif ()
 
     add_custom_command (
-        OUTPUT d3dretrace_d3d10.cpp
-        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3dcommonretrace.py ${DXGI_MODULES} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d10.cpp
+        OUTPUT d3dretrace_dxgi.cpp
+        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dxgiretrace.py ${DXGI_MODULES} > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_dxgi.cpp
         DEPENDS
-                d3dcommonretrace.py
+                dxgiretrace.py
                 dllretrace.py
                 retrace.py
                 ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
@@ -200,7 +200,7 @@ if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
     add_executable (d3dretrace
         d3dretrace_main.cpp
         d3dretrace_d3d9.cpp
-        d3dretrace_d3d10.cpp
+        d3dretrace_dxgi.cpp
         d3dretrace_ws.cpp
         d3d9state.cpp
         d3d9state_images.cpp
diff --git a/retrace/d3dcommonretrace.py b/retrace/d3dcommonretrace.py
deleted file mode 100644 (file)
index e3eddbb..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-##########################################################################
-#
-# Copyright 2011 Jose Fonseca
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""D3D retracer generator."""
-
-
-import sys
-from dllretrace import DllRetracer as Retracer
-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 retraceApi(self, api):
-        print '// Swizzling mapping for lock addresses'
-        print 'static std::map<void *, void *> _maps;'
-        print
-        print r'''
-static void 
-createWindow(DXGI_SWAP_CHAIN_DESC *pSwapChainDesc) {
-    if (pSwapChainDesc->Windowed) {
-        UINT Width  = pSwapChainDesc->BufferDesc.Width;
-        UINT Height = pSwapChainDesc->BufferDesc.Height;
-        if (!Width)  Width = 1024;
-        if (!Height) Height = 768;
-        pSwapChainDesc->OutputWindow = d3dretrace::createWindow(Width, Height);
-    }
-}
-'''
-
-        self.table_name = 'd3dretrace::d3d10_callbacks'
-
-        Retracer.retraceApi(self, api)
-
-    createDeviceFunctionNames = [
-        "D3D10CreateDevice",
-        "D3D10CreateDeviceAndSwapChain",
-        "D3D10CreateDevice1",
-        "D3D10CreateDeviceAndSwapChain1",
-        "D3D11CreateDevice",
-        "D3D11CreateDeviceAndSwapChain",
-    ]
-
-    def invokeFunction(self, function):
-        if function.name in self.createDeviceFunctionNames:
-            # create windows as neccessary
-            if 'pSwapChainDesc' in function.argNames():
-                print r'    createWindow(pSwapChainDesc);'
-
-            # Compensate for the fact we don't trace the software renderer
-            # module LoadLibrary call
-            if 'Software' in function.argNames():
-                print r'    if (Software) {'
-                print r'        retrace::warning(call) << "using WARP for software device\n";'
-                print r'        Software = LoadLibraryA("d3d10warp");'
-                print r'    }'
-
-            # Compensate for the fact we don't trace DXGI object creation
-            if function.name.startswith('D3D11CreateDevice'):
-                print r'    if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {'
-                print r'        DriverType = D3D_DRIVER_TYPE_HARDWARE;'
-                print r'    }'
-
-        Retracer.invokeFunction(self, function)
-
-
-    def invokeInterfaceMethod(self, interface, method):
-        # keep track of the last used device for state dumping
-        if interface.name in ('ID3D10Device', 'ID3D10Device1'):
-            if method.name == 'Release':
-                print r'    d3d10Dumper.unbindDevice(_this);'
-            else:
-                print r'    d3d10Dumper.bindDevice(_this);'
-        if interface.name in ('ID3D11DeviceContext',):
-            if method.name == 'Release':
-                print r'    d3d11Dumper.unbindDevice(_this);'
-            else:
-                print r'    d3d11Dumper.bindDevice(_this);'
-
-        # create windows as neccessary
-        if method.name == 'CreateSwapChain':
-            print r'    createWindow(pDesc);'
-
-        # notify frame has been completed
-        if method.name == 'Present':
-            print r'    retrace::frameComplete(call);'
-
-        if 'pSharedResource' in method.argNames():
-            print r'    if (pSharedResource) {'
-            print r'        retrace::warning(call) << "shared surfaces unsupported\n";'
-            print r'        pSharedResource = NULL;'
-            print r'    }'
-
-        Retracer.invokeInterfaceMethod(self, interface, method)
-
-        # process events after presents
-        if method.name == 'Present':
-            print r'    d3dretrace::processEvents();'
-
-        if method.name == 'Map':
-            print '    VOID *_pbData = NULL;'
-            print '    size_t _MappedSize = 0;'
-            print '    _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames())
-            print '    if (_MappedSize) {'
-            print '        _maps[_this] = _pbData;'
-            print '    } else {'
-            print '        return;'
-            print '    }'
-        
-        if method.name == 'Unmap':
-            print '    VOID *_pbData = 0;'
-            print '    _pbData = _maps[_this];'
-            print '    if (_pbData) {'
-            print '        retrace::delRegionByPointer(_pbData);'
-            print '        _maps[_this] = 0;'
-            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)
-        print
-        print '''static d3dretrace::D3DDumper<ID3D10Device> d3d10Dumper;'''
-        print
-
-    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"'
-        print r'#include "d3dstate.hpp"'
-        api.addModule(d3d11)
-        
-        print
-        print '''static d3dretrace::D3DDumper<ID3D11DeviceContext> d3d11Dumper;'''
-        print
-
-    retracer = D3DRetracer()
-    retracer.retraceApi(api)
-
-
-if __name__ == '__main__':
-    main()
diff --git a/retrace/dxgiretrace.py b/retrace/dxgiretrace.py
new file mode 100644 (file)
index 0000000..e3eddbb
--- /dev/null
@@ -0,0 +1,193 @@
+##########################################################################
+#
+# Copyright 2011 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""D3D retracer generator."""
+
+
+import sys
+from dllretrace import DllRetracer as Retracer
+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 retraceApi(self, api):
+        print '// Swizzling mapping for lock addresses'
+        print 'static std::map<void *, void *> _maps;'
+        print
+        print r'''
+static void 
+createWindow(DXGI_SWAP_CHAIN_DESC *pSwapChainDesc) {
+    if (pSwapChainDesc->Windowed) {
+        UINT Width  = pSwapChainDesc->BufferDesc.Width;
+        UINT Height = pSwapChainDesc->BufferDesc.Height;
+        if (!Width)  Width = 1024;
+        if (!Height) Height = 768;
+        pSwapChainDesc->OutputWindow = d3dretrace::createWindow(Width, Height);
+    }
+}
+'''
+
+        self.table_name = 'd3dretrace::d3d10_callbacks'
+
+        Retracer.retraceApi(self, api)
+
+    createDeviceFunctionNames = [
+        "D3D10CreateDevice",
+        "D3D10CreateDeviceAndSwapChain",
+        "D3D10CreateDevice1",
+        "D3D10CreateDeviceAndSwapChain1",
+        "D3D11CreateDevice",
+        "D3D11CreateDeviceAndSwapChain",
+    ]
+
+    def invokeFunction(self, function):
+        if function.name in self.createDeviceFunctionNames:
+            # create windows as neccessary
+            if 'pSwapChainDesc' in function.argNames():
+                print r'    createWindow(pSwapChainDesc);'
+
+            # Compensate for the fact we don't trace the software renderer
+            # module LoadLibrary call
+            if 'Software' in function.argNames():
+                print r'    if (Software) {'
+                print r'        retrace::warning(call) << "using WARP for software device\n";'
+                print r'        Software = LoadLibraryA("d3d10warp");'
+                print r'    }'
+
+            # Compensate for the fact we don't trace DXGI object creation
+            if function.name.startswith('D3D11CreateDevice'):
+                print r'    if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {'
+                print r'        DriverType = D3D_DRIVER_TYPE_HARDWARE;'
+                print r'    }'
+
+        Retracer.invokeFunction(self, function)
+
+
+    def invokeInterfaceMethod(self, interface, method):
+        # keep track of the last used device for state dumping
+        if interface.name in ('ID3D10Device', 'ID3D10Device1'):
+            if method.name == 'Release':
+                print r'    d3d10Dumper.unbindDevice(_this);'
+            else:
+                print r'    d3d10Dumper.bindDevice(_this);'
+        if interface.name in ('ID3D11DeviceContext',):
+            if method.name == 'Release':
+                print r'    d3d11Dumper.unbindDevice(_this);'
+            else:
+                print r'    d3d11Dumper.bindDevice(_this);'
+
+        # create windows as neccessary
+        if method.name == 'CreateSwapChain':
+            print r'    createWindow(pDesc);'
+
+        # notify frame has been completed
+        if method.name == 'Present':
+            print r'    retrace::frameComplete(call);'
+
+        if 'pSharedResource' in method.argNames():
+            print r'    if (pSharedResource) {'
+            print r'        retrace::warning(call) << "shared surfaces unsupported\n";'
+            print r'        pSharedResource = NULL;'
+            print r'    }'
+
+        Retracer.invokeInterfaceMethod(self, interface, method)
+
+        # process events after presents
+        if method.name == 'Present':
+            print r'    d3dretrace::processEvents();'
+
+        if method.name == 'Map':
+            print '    VOID *_pbData = NULL;'
+            print '    size_t _MappedSize = 0;'
+            print '    _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames())
+            print '    if (_MappedSize) {'
+            print '        _maps[_this] = _pbData;'
+            print '    } else {'
+            print '        return;'
+            print '    }'
+        
+        if method.name == 'Unmap':
+            print '    VOID *_pbData = 0;'
+            print '    _pbData = _maps[_this];'
+            print '    if (_pbData) {'
+            print '        retrace::delRegionByPointer(_pbData);'
+            print '        _maps[_this] = 0;'
+            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)
+        print
+        print '''static d3dretrace::D3DDumper<ID3D10Device> d3d10Dumper;'''
+        print
+
+    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"'
+        print r'#include "d3dstate.hpp"'
+        api.addModule(d3d11)
+        
+        print
+        print '''static d3dretrace::D3DDumper<ID3D11DeviceContext> d3d11Dumper;'''
+        print
+
+    retracer = D3DRetracer()
+    retracer.retraceApi(api)
+
+
+if __name__ == '__main__':
+    main()