]> git.cworth.org Git - apitrace/commitdiff
d3dretrace: Basic d3d10 support.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 7 Nov 2012 20:00:46 +0000 (20:00 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 7 Nov 2012 20:00:46 +0000 (20:00 +0000)
helpers/dxgisize.hpp
retrace/CMakeLists.txt
retrace/d3d10retrace.py [new file with mode: 0644]
retrace/d3dretrace.hpp
retrace/d3dretrace_main.cpp
specs/d3d10.py
specs/d3d10effect.py

index 3048d3fc6cfc3ad29971215676a8df19d77509be..a2749ffbe642d9abd6d634f044306279daac6711 100644 (file)
@@ -41,6 +41,8 @@
 
 #include <algorithm>
 
+#include "os.hpp"
+
 
 static size_t
 _calcDataSize(DXGI_FORMAT Format, UINT Width, UINT Height, UINT RowPitch, UINT Depth = 1, UINT DepthPitch = 0) {
index aaaa006beff61806f8215cb668c73eb239bfeada..69612f029cb3dc787fd3a935293cb68ae952f07c 100644 (file)
@@ -128,7 +128,7 @@ if (ENABLE_EGL AND X11_FOUND AND NOT WIN32 AND NOT APPLE)
     install (TARGETS eglretrace RUNTIME DESTINATION bin) 
 endif ()
 
-if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
+if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR AND DirectX_D3D10_INCLUDE_DIR)
     add_custom_command (
         OUTPUT d3dretrace_d3d9.cpp
         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9retrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp
@@ -144,10 +144,32 @@ if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
                 ${CMAKE_SOURCE_DIR}/specs/stdapi.py
     )
 
+    add_custom_command (
+        OUTPUT d3dretrace_d3d10.cpp
+        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10retrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d10.cpp
+        DEPENDS
+                d3d10retrace.py
+                dllretrace.py
+                retrace.py
+                ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10misc.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10shader.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10effect.py
+                ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgi.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+    )
+
     include_directories (SYSTEM ${DirectX_D3DX9_INCLUDE_DIR})
     add_executable (d3dretrace
         d3dretrace_main.cpp
         d3dretrace_d3d9.cpp
+        d3dretrace_d3d10.cpp
         d3dretrace_ws.cpp
         d3d9state.cpp
         d3d9state_images.cpp
diff --git a/retrace/d3d10retrace.py b/retrace/d3d10retrace.py
new file mode 100644 (file)
index 0000000..ee8736b
--- /dev/null
@@ -0,0 +1,111 @@
+##########################################################################
+#
+# 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."""
+
+
+from dllretrace import DllRetracer as Retracer
+import specs.stdapi as stdapi
+from specs.d3d10 import *
+
+
+class D3DRetracer(Retracer):
+
+    def retraceApi(self, api):
+        print '// Swizzling mapping for lock addresses'
+        print 'static std::map<void *, void *> _maps;'
+        print
+
+        self.table_name = 'd3dretrace::%s_callbacks' % api.name.lower()
+
+        Retracer.retraceApi(self, api)
+
+    def invokeFunction(self, function):
+        # create windows as neccessary
+        if function.name == 'D3D10CreateDeviceAndSwapChain':
+            print r'    pSwapChainDesc->OutputWindow = d3dretrace::createWindow(512, 512);'
+
+        Retracer.invokeFunction(self, function)
+
+    def invokeInterfaceMethod(self, interface, method):
+        # keep track of the last used device for state dumping
+        #if interface.name in ('IDirect3DDevice9', 'IDirect3DDevice9Ex'):
+        #    print r'    d3dretrace::pLastDirect3DDevice9 = _this;'
+
+        # create windows as neccessary
+        if method.name == 'CreateSwapChain':
+            print r'    pDesc->OutputWindow = d3dretrace::createWindow(512, 512);'
+
+        # 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();'
+
+        # check errors
+        if str(method.type) == 'HRESULT':
+            print r'    if (FAILED(_result)) {'
+            print r'        retrace::warning(call) << "failed\n";'
+            print r'    }'
+
+        if method.name == 'Map':
+            print '    VOID *_pbData = NULL;'
+            print '    size_t _MappedSize = 0;'
+            print '    _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames())
+            print '    _maps[_this] = _pbData;'
+        
+        if method.name == 'Unmap':
+            print '    VOID *_pbData = 0;'
+            print '    _pbData = _maps[_this];'
+            print '    if (_pbData) {'
+            print '        retrace::delRegionByPointer(_pbData);'
+            print '    }'
+
+
+if __name__ == '__main__':
+    print r'''
+#include <string.h>
+
+#include <iostream>
+
+#include "d3d10imports.hpp"
+#include "d3d10size.hpp"
+#include "d3dretrace.hpp"
+
+'''
+
+    retracer = D3DRetracer()
+    retracer.retraceApi(d3d10)
index b552c0bf3935a609d06fe9be07f34bf4095897ec..c4e5bb4ae2bab0c0556edf08726e32c23f877b42 100644 (file)
@@ -45,6 +45,7 @@ extern IDirect3DDevice9 *pLastDirect3DDevice9;
 
 
 extern const retrace::Entry d3d9_callbacks[];
+extern const retrace::Entry d3d10_callbacks[];
 
 
 HWND
index 7471195e42bbf98cbb5006f265bee1cdff47d943..5806546f754a5c5014cdf9588b07a32479ebd9f8 100644 (file)
@@ -55,6 +55,7 @@ void
 retrace::addCallbacks(retrace::Retracer &retracer)
 {
     retracer.addCallbacks(d3dretrace::d3d9_callbacks);
+    retracer.addCallbacks(d3dretrace::d3d10_callbacks);
 }
 
 
index 7b0f1824158405aa7b7bc535764baebd9d3681a7..9a253279d4b866c0e483368c94e3ef2349a2efa7 100644 (file)
@@ -603,12 +603,12 @@ D3D10_VIEWPORT = Struct("D3D10_VIEWPORT", [
 ])
 
 D3D10_MAPPED_TEXTURE2D = Struct("D3D10_MAPPED_TEXTURE2D", [
-    (OpaquePointer(Void), "pData"),
+    (LinearPointer(Void, "_MappedSize"), "pData"),
     (UINT, "RowPitch"),
 ])
 
 D3D10_MAPPED_TEXTURE3D = Struct("D3D10_MAPPED_TEXTURE3D", [
-    (OpaquePointer(Void), "pData"),
+    (LinearPointer(Void, "_MappedSize"), "pData"),
     (UINT, "RowPitch"),
     (UINT, "DepthPitch"),
 ])
@@ -722,13 +722,13 @@ ID3D10Resource.methods += [
 ]
 
 ID3D10Buffer.methods += [
-    Method(HRESULT, "Map", [(D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(OpaquePointer(Void)), "ppData")]),
+    Method(HRESULT, "Map", [(D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(LinearPointer(Void, "_MappedSize")), "ppData")]),
     Method(Void, "Unmap", []),
     Method(Void, "GetDesc", [Out(Pointer(D3D10_BUFFER_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10Texture1D.methods += [
-    Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(OpaquePointer(Void)), "ppData")]),
+    Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(LinearPointer(Void, "_MappedSize")), "ppData")]),
     Method(Void, "Unmap", [(UINT, "Subresource")]),
     Method(Void, "GetDesc", [Out(Pointer(D3D10_TEXTURE1D_DESC), "pDesc")], sideeffects=False),
 ]
index 9a5e89e45e5b0f998196a52f5680239f99a9feb4..401808d7f840064764c2ac6e795359aa37bab686 100644 (file)
@@ -177,8 +177,8 @@ ID3D10EffectVariable.methods += [
     StdMethod(ObjPointer(ID3D10EffectDepthStencilVariable), "AsDepthStencil", []),
     StdMethod(ObjPointer(ID3D10EffectRasterizerVariable), "AsRasterizer", []),
     StdMethod(ObjPointer(ID3D10EffectSamplerVariable), "AsSampler", []),
-    StdMethod(HRESULT, "SetRawValue", [(OpaquePointer(Void), "pData"), (UINT, "Offset"), (UINT, "ByteCount")]),
-    StdMethod(HRESULT, "GetRawValue", [Out(OpaquePointer(Void), "pData"), (UINT, "Offset"), (UINT, "ByteCount")]),
+    StdMethod(HRESULT, "SetRawValue", [(Blob(Void, "ByteCount"), "pData"), (UINT, "Offset"), (UINT, "ByteCount")]),
+    StdMethod(HRESULT, "GetRawValue", [Out(OpaqueBlob(Void, "ByteCount"), "pData"), (UINT, "Offset"), (UINT, "ByteCount")], sideeffects=False),
 ]
 
 ID3D10EffectScalarVariable.methods += [