#include <algorithm>
+#include "os.hpp"
+
static size_t
_calcDataSize(DXGI_FORMAT Format, UINT Width, UINT Height, UINT RowPitch, UINT Depth = 1, UINT DepthPitch = 0) {
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
${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
--- /dev/null
+##########################################################################
+#
+# 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)
extern const retrace::Entry d3d9_callbacks[];
+extern const retrace::Entry d3d10_callbacks[];
HWND
retrace::addCallbacks(retrace::Retracer &retracer)
{
retracer.addCallbacks(d3dretrace::d3d9_callbacks);
+ retracer.addCallbacks(d3dretrace::d3d10_callbacks);
}
])
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"),
])
]
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),
]
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 += [