diff options
author | José Fonseca <jose.r.fonseca@gmail.com> | 2012-11-23 14:34:29 +0000 |
---|---|---|
committer | José Fonseca <jose.r.fonseca@gmail.com> | 2012-11-23 14:34:29 +0000 |
commit | 20aa935d4c87e47040d2e75bf746fcf9d5d8d6b2 (patch) | |
tree | 3da1bbb46b40af4a4d5199f0a2dafc5731e11b29 /wrappers/dxgitrace.py | |
parent | 00611a483a0a531272ba5810b77fb5d293db1723 (diff) |
dxgitrace: Merge tracing of all DXGI related APIs.
Diffstat (limited to 'wrappers/dxgitrace.py')
-rw-r--r-- | wrappers/dxgitrace.py | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/wrappers/dxgitrace.py b/wrappers/dxgitrace.py new file mode 100644 index 00000000..640f3562 --- /dev/null +++ b/wrappers/dxgitrace.py @@ -0,0 +1,113 @@ +########################################################################## +# +# 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. +# +##########################################################################/ + + +import sys +from dlltrace import DllTracer +from specs import 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 D3DCommonTracer(DllTracer): + + def serializeArgValue(self, function, arg): + # Dump shaders as strings + if isinstance(arg.type, stdapi.Blob) and arg.name.startswith('pShaderBytecode'): + print ' DumpShader(trace::localWriter, %s, %s);' % (arg.name, arg.type.size) + return + + DllTracer.serializeArgValue(self, function, arg) + + def enumWrapperInterfaceVariables(self, interface): + variables = DllTracer.enumWrapperInterfaceVariables(self, interface) + + # Add additional members to track maps + if interface.getMethodByName('Map') is not None: + variables += [ + ('VOID *', '_pMappedData', '0'), + ('size_t', '_MappedSize', '0'), + ] + + return variables + + def implementWrapperInterfaceMethodBody(self, interface, base, method): + if method.name == 'Unmap': + print ' if (_MappedSize && _pMappedData) {' + self.emit_memcpy('_pMappedData', '_pMappedData', '_MappedSize') + print ' }' + + DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) + + if method.name == 'Map': + # NOTE: recursive locks are explicitely forbidden + print ' if (SUCCEEDED(_result)) {' + print ' _getMapInfo(_this, %s, _pMappedData, _MappedSize);' % ', '.join(method.argNames()) + print ' } else {' + print ' _pMappedData = NULL;' + print ' _MappedSize = 0;' + print ' }' + + +if __name__ == '__main__': + print '#define INITGUID' + print + print '#include "trace_writer_local.hpp"' + print '#include "os.hpp"' + print + print '#include "d3dcommonshader.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) + + tracer = D3DCommonTracer() + tracer.traceApi(api) |