From 4106eb4ff92852a4eed5ac66d9cbedb14a7bfb8d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 21 Sep 2011 08:12:39 +0100 Subject: Split D3D specs for trace generators. --- .gitignore | 9 +++---- CMakeLists.txt | 29 +++++++++++---------- d3d.py | 52 ------------------------------------- d3d8.py | 25 ------------------ d3d8trace.py | 52 +++++++++++++++++++++++++++++++++++++ d3d9.py | 25 +----------------- d3d9trace.py | 51 ++++++++++++++++++++++++++++++++++++ ddraw.py | 1 - ddrawtrace.py | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 204 insertions(+), 121 deletions(-) create mode 100644 d3d8trace.py create mode 100644 d3d9trace.py create mode 100644 ddrawtrace.py diff --git a/.gitignore b/.gitignore index b2dda42..ed1ea5a 100644 --- a/.gitignore +++ b/.gitignore @@ -27,11 +27,10 @@ CMakeCache.txt CMakeFiles Makefile build -d3d10.cpp -d3d10_1.cpp -d3d8.cpp -d3d9.cpp -ddraw.cpp +d3d10trace.cpp +d3d8trace.cpp +d3d9trace.cpp +ddrawtrace.cpp dxsdk glproc.hpp glretrace diff --git a/CMakeLists.txt b/CMakeLists.txt index 360e830..32f1498 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,7 @@ link_libraries (common) add_executable (tracedump tracedump.cpp) install (TARGETS tracedump RUNTIME DESTINATION bin) + ############################################################################## # API tracers @@ -216,11 +217,11 @@ if (WIN32) if (DirectX_D3D_INCLUDE_DIR) include_directories (SYSTEM ${DirectX_D3D_INCLUDE_DIR}) add_custom_command ( - OUTPUT ddraw.cpp - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d.py > ${CMAKE_CURRENT_BINARY_DIR}/ddraw.cpp - DEPENDS d3d.py d3dtypes.py d3dcaps.py ddraw.py trace.py winapi.py stdapi.py + OUTPUT ddrawtrace.cpp + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/ddrawtrace.cpp + DEPENDS ddrawtrace.py d3d.py d3dtypes.py d3dcaps.py ddraw.py trace.py winapi.py stdapi.py ) - add_library (ddraw MODULE ddraw.def ddraw.cpp) + add_library (ddraw MODULE ddraw.def ddrawtrace.cpp) set_target_properties (ddraw PROPERTIES PREFIX "" RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers @@ -233,11 +234,11 @@ if (WIN32) if (DirectX_D3D8_INCLUDE_DIR AND DirectX_D3DX9_INCLUDE_DIR) include_directories (SYSTEM ${DirectX_D3D8_INCLUDE_DIR} ${DirectX_D3DX9_INCLUDE_DIR}) add_custom_command ( - OUTPUT d3d8.cpp - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8.cpp - DEPENDS d3d8.py trace.py d3d8types.py d3d8caps.py winapi.py stdapi.py + OUTPUT d3d8trace.cpp + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8trace.cpp + DEPENDS d3d8trace.py d3d8.py trace.py d3d8types.py d3d8caps.py winapi.py stdapi.py ) - add_library (d3d8 MODULE d3d8.def d3d8.cpp d3dshader.cpp) + add_library (d3d8 MODULE d3d8.def d3d8trace.cpp d3dshader.cpp) set_target_properties (d3d8 PROPERTIES PREFIX "" RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers @@ -250,11 +251,11 @@ if (WIN32) if (DirectX_D3DX9_INCLUDE_DIR) include_directories (SYSTEM ${DirectX_D3DX9_INCLUDE_DIR}) add_custom_command ( - OUTPUT d3d9.cpp - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9.cpp - DEPENDS d3d9.py trace.py d3d9types.py d3d9caps.py winapi.py stdapi.py + OUTPUT d3d9trace.cpp + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9trace.cpp + DEPENDS d3d9trace.py d3d9.py trace.py d3d9types.py d3d9caps.py winapi.py stdapi.py ) - add_library (d3d9 MODULE d3d9.def d3d9.cpp d3dshader.cpp) + add_library (d3d9 MODULE d3d9.def d3d9trace.cpp d3dshader.cpp) set_target_properties (d3d9 PROPERTIES PREFIX "" RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers @@ -268,10 +269,10 @@ if (WIN32) # include_directories (SYSTEM ${DirectX_D3D10_INCLUDE_DIR}) # add_custom_command ( # OUTPUT d3d10.cpp - # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10misc.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10.cpp + # COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10misc.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10trace.cpp # DEPENDS d3d10misc.py winapi.py stdapi.py # ) - # add_library (d3d10 MODULE d3d10.def d3d10.cpp) + # add_library (d3d10 MODULE d3d10.def d3d10trace.cpp) # set_target_properties (d3d10 PROPERTIES PREFIX "") # install (TARGETS d3d10 LIBRARY DESTINATION wrappers) #endif (DirectX_D3D10_INCLUDE_DIR) diff --git a/d3d.py b/d3d.py index f587fc5..857e5b3 100644 --- a/d3d.py +++ b/d3d.py @@ -473,55 +473,3 @@ interfaces = [ ddraw.add_interfaces(interfaces) - -class DDrawTracer(DllTracer): - - def trace_function_impl_body(self, function): - if function.name in ('AcquireDDThreadLock', 'ReleaseDDThreadLock'): - self.dispatch_function(function) - return - - DllTracer.trace_function_impl_body(self, function) - - def wrap_arg(self, function, arg): - if function.name == 'DirectDrawCreateEx' and arg.name == 'lplpDD': - print ' if (*lplpDD) {' - for iface in interfaces: - print ' if (iid == IID_%s) {' % iface.name - print ' *lplpDD = (LPVOID) new Wrap%s((%s *)*lplpDD);' % (iface.name, iface.name) - print ' }' - print ' }' - - DllTracer.wrap_arg(self, function, arg) - - -if __name__ == '__main__': - print '#define INITGUID' - print '#include ' - print '#include ' - print '#include ' - print - print ''' - -#ifndef DDBLT_EXTENDED_FLAGS -#define DDBLT_EXTENDED_FLAGS 0x40000000l -#endif - -#ifndef DDBLT_EXTENDED_LINEAR_CONTENT -#define DDBLT_EXTENDED_LINEAR_CONTENT 0x00000004l -#endif - -#ifndef D3DLIGHT_PARALLELPOINT -#define D3DLIGHT_PARALLELPOINT (D3DLIGHTTYPE)4 -#endif - -#ifndef D3DLIGHT_GLSPOT -#define D3DLIGHT_GLSPOT (D3DLIGHTTYPE)5 -#endif - -''' - print '#include "trace_writer.hpp"' - print '#include "os.hpp"' - print - tracer = DDrawTracer('ddraw.dll') - tracer.trace_api(ddraw) diff --git a/d3d8.py b/d3d8.py index f579a9b..0713696 100644 --- a/d3d8.py +++ b/d3d8.py @@ -28,7 +28,6 @@ from winapi import * from d3d8types import * from d3d8caps import * -from trace import DllTracer HRESULT = Enum("HRESULT", [ "D3D_OK", @@ -281,27 +280,3 @@ d3d8 = API("d3d8") d3d8.add_functions([ StdFunction(PDIRECT3D8, "Direct3DCreate8", [(UINT, "SDKVersion")]), ]) - - -class D3D8Tracer(DllTracer): - - def dump_arg_instance(self, function, arg): - # Dump shaders as strings - if function.name in ('CreateVertexShader', 'CreatePixelShader') and arg.name == 'pFunction': - print ' DumpShader(Trace::localWriter, %s);' % (arg.name) - return - - DllTracer.dump_arg_instance(self, function, arg) - - -if __name__ == '__main__': - print '#include ' - print '#include ' - print '#include "d3dshader.hpp"' - print - print '#include "trace_writer.hpp"' - print '#include "os.hpp"' - print - tracer = D3D8Tracer('d3d8.dll') - tracer.trace_api(d3d8) - diff --git a/d3d8trace.py b/d3d8trace.py new file mode 100644 index 0000000..236f56c --- /dev/null +++ b/d3d8trace.py @@ -0,0 +1,52 @@ +########################################################################## +# +# Copyright 2008-2009 VMware, Inc. +# 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. +# +##########################################################################/ + + +from d3d8 import d3d8 +from trace import DllTracer + + +class D3D8Tracer(DllTracer): + + def dump_arg_instance(self, function, arg): + # Dump shaders as strings + if function.name in ('CreateVertexShader', 'CreatePixelShader') and arg.name == 'pFunction': + print ' DumpShader(Trace::localWriter, %s);' % (arg.name) + return + + DllTracer.dump_arg_instance(self, function, arg) + + +if __name__ == '__main__': + print '#include ' + print '#include ' + print '#include "d3dshader.hpp"' + print + print '#include "trace_writer.hpp"' + print '#include "os.hpp"' + print + tracer = D3D8Tracer('d3d8.dll') + tracer.trace_api(d3d8) + diff --git a/d3d9.py b/d3d9.py index 640d218..251f292 100644 --- a/d3d9.py +++ b/d3d9.py @@ -28,7 +28,7 @@ from winapi import * from d3d9types import * from d3d9caps import * -from trace import DllTracer + D3DSHADER9 = Opaque("const DWORD *") @@ -448,26 +448,3 @@ d3d9.add_functions([ StdFunction(Void, "D3DPERF_SetOptions", [(DWORD, "dwOptions")]), StdFunction(DWORD, "D3DPERF_GetStatus", [], fail='0'), ]) - - -class D3D9Tracer(DllTracer): - - def dump_arg_instance(self, function, arg): - # Dump shaders as strings - if function.name in ('CreateVertexShader', 'CreatePixelShader') and arg.name == 'pFunction': - print ' DumpShader(Trace::localWriter, %s);' % (arg.name) - return - - DllTracer.dump_arg_instance(self, function, arg) - - -if __name__ == '__main__': - print '#include "trace_writer.hpp"' - print '#include "os.hpp"' - print - print '#include "d3d9imports.hpp"' - print '#include "d3dshader.hpp"' - print - tracer = D3D9Tracer('d3d9.dll') - tracer.trace_api(d3d9) - diff --git a/d3d9trace.py b/d3d9trace.py new file mode 100644 index 0000000..b83ebf6 --- /dev/null +++ b/d3d9trace.py @@ -0,0 +1,51 @@ +########################################################################## +# +# Copyright 2008-2009 VMware, Inc. +# 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. +# +##########################################################################/ + + +from trace import DllTracer +from d3d9 import d3d9 + + +class D3D9Tracer(DllTracer): + + def dump_arg_instance(self, function, arg): + # Dump shaders as strings + if function.name in ('CreateVertexShader', 'CreatePixelShader') and arg.name == 'pFunction': + print ' DumpShader(Trace::localWriter, %s);' % (arg.name) + return + + DllTracer.dump_arg_instance(self, function, arg) + + +if __name__ == '__main__': + print '#include "trace_writer.hpp"' + print '#include "os.hpp"' + print + print '#include "d3d9imports.hpp"' + print '#include "d3dshader.hpp"' + print + tracer = D3D9Tracer('d3d9.dll') + tracer.trace_api(d3d9) + diff --git a/ddraw.py b/ddraw.py index 8ac08a8..eb5a072 100644 --- a/ddraw.py +++ b/ddraw.py @@ -26,7 +26,6 @@ """ddraw.h""" from winapi import * -from trace import DllTracer DirectDrawOptSurfaceDescFlags = Flags(DWORD, [ "DDOSD_GUID", diff --git a/ddrawtrace.py b/ddrawtrace.py new file mode 100644 index 0000000..0b53f0d --- /dev/null +++ b/ddrawtrace.py @@ -0,0 +1,81 @@ +########################################################################## +# +# Copyright 2008-2009 VMware, Inc. +# 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. +# +##########################################################################/ + + +from d3d import ddraw, interfaces +from trace import DllTracer + + +class DDrawTracer(DllTracer): + + def trace_function_impl_body(self, function): + if function.name in ('AcquireDDThreadLock', 'ReleaseDDThreadLock'): + self.dispatch_function(function) + return + + DllTracer.trace_function_impl_body(self, function) + + def wrap_arg(self, function, arg): + if function.name == 'DirectDrawCreateEx' and arg.name == 'lplpDD': + print ' if (*lplpDD) {' + for iface in interfaces: + print ' if (iid == IID_%s) {' % iface.name + print ' *lplpDD = (LPVOID) new Wrap%s((%s *)*lplpDD);' % (iface.name, iface.name) + print ' }' + print ' }' + + DllTracer.wrap_arg(self, function, arg) + + +if __name__ == '__main__': + print '#define INITGUID' + print '#include ' + print '#include ' + print '#include ' + print + print ''' + +#ifndef DDBLT_EXTENDED_FLAGS +#define DDBLT_EXTENDED_FLAGS 0x40000000l +#endif + +#ifndef DDBLT_EXTENDED_LINEAR_CONTENT +#define DDBLT_EXTENDED_LINEAR_CONTENT 0x00000004l +#endif + +#ifndef D3DLIGHT_PARALLELPOINT +#define D3DLIGHT_PARALLELPOINT (D3DLIGHTTYPE)4 +#endif + +#ifndef D3DLIGHT_GLSPOT +#define D3DLIGHT_GLSPOT (D3DLIGHTTYPE)5 +#endif + +''' + print '#include "trace_writer.hpp"' + print '#include "os.hpp"' + print + tracer = DDrawTracer('ddraw.dll') + tracer.trace_api(ddraw) -- cgit v1.2.3