X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=wrappers%2Fdxgitrace.py;h=45767a0f6761410ac9908599496e7a9ffb9b91c4;hb=b79fe3d2e482c492248d96da992f8fabcd9fe8cd;hp=640f3562fdbbe8303acb82f0dae6072679d97a07;hpb=20aa935d4c87e47040d2e75bf746fcf9d5d8d6b2;p=apitrace diff --git a/wrappers/dxgitrace.py b/wrappers/dxgitrace.py index 640f356..45767a0 100644 --- a/wrappers/dxgitrace.py +++ b/wrappers/dxgitrace.py @@ -26,12 +26,13 @@ import sys from dlltrace import DllTracer +from trace import getWrapperInterfaceName 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 +from specs import dxgi +from specs import d3d10 +from specs import d3d10_1 +from specs import d3d11 class D3DCommonTracer(DllTracer): @@ -42,36 +43,87 @@ class D3DCommonTracer(DllTracer): print ' DumpShader(trace::localWriter, %s, %s);' % (arg.name, arg.type.size) return + # Serialize the swapchain dimensions + if function.name == 'CreateSwapChain' and arg.name == 'pDesc' \ + or arg.name == 'pSwapChainDesc': + print r' DXGI_SWAP_CHAIN_DESC *_pSwapChainDesc = NULL;' + print r' DXGI_SWAP_CHAIN_DESC _SwapChainDesc;' + print r' if (%s) {' % arg.name + print r' _SwapChainDesc = *%s;' % arg.name + if function.name != 'CreateSwapChain' or not self.interface.name.endswith('DWM'): + # Obtain size from the window + print r' RECT _rect;' + print r' if (GetClientRect(%s->OutputWindow, &_rect)) {' % arg.name + print r' if (%s->BufferDesc.Width == 0) {' % arg.name + print r' _SwapChainDesc.BufferDesc.Width = _rect.right - _rect.left;' + print r' }' + print r' if (%s->BufferDesc.Height == 0) {' % arg.name + print r' _SwapChainDesc.BufferDesc.Height = _rect.bottom - _rect.top;' + print r' }' + print r' }' + else: + # Obtain size from the output + print r' DXGI_OUTPUT_DESC _OutputDesc;' + print r' if (SUCCEEDED(pOutput->GetDesc(&_OutputDesc))) {' + print r' _SwapChainDesc.BufferDesc.Width = _OutputDesc.DesktopCoordinates.right - _OutputDesc.DesktopCoordinates.left;' + print r' _SwapChainDesc.BufferDesc.Height = _OutputDesc.DesktopCoordinates.bottom - _OutputDesc.DesktopCoordinates.top;' + print r' }' + print r' _pSwapChainDesc = &_SwapChainDesc;' + print r' }' + self.serializeValue(arg.type, '_pSwapChainDesc') + return + DllTracer.serializeArgValue(self, function, arg) + + # Interfaces that need book-keeping for maps + mapInterfaces = ( + dxgi.IDXGISurface, + d3d10.ID3D10Resource, + d3d11.ID3D11Resource, + ) def enumWrapperInterfaceVariables(self, interface): variables = DllTracer.enumWrapperInterfaceVariables(self, interface) # Add additional members to track maps - if interface.getMethodByName('Map') is not None: + if interface.hasBase(*self.mapInterfaces): variables += [ - ('VOID *', '_pMappedData', '0'), - ('size_t', '_MappedSize', '0'), + ('_MAP_DESC', '_MapDesc', None), ] return variables def implementWrapperInterfaceMethodBody(self, interface, base, method): + if method.name in ('Map', 'Unmap'): + # On D3D11 Map/Unmap is not a resource method, but a context method instead. + resourceArg = method.getArgByName('pResource') + if resourceArg is None: + pResource = 'this' + else: + wrapperInterfaceName = getWrapperInterfaceName(resourceArg.type.type) + print ' %s * _pResource = static_cast<%s*>(%s);' % (wrapperInterfaceName, wrapperInterfaceName, resourceArg.name) + pResource = '_pResource' + if method.name == 'Unmap': - print ' if (_MappedSize && _pMappedData) {' - self.emit_memcpy('_pMappedData', '_pMappedData', '_MappedSize') + print ' _MAP_DESC _MapDesc = %s->_MapDesc;' % pResource + #print r' os::log("%%p -> %%p+%%lu\n", %s,_MapDesc.pData, (unsigned long)_MapDesc.Size);' % pResource + print ' if (_MapDesc.Size && _MapDesc.pData) {' + self.emit_memcpy('_MapDesc.pData', '_MapDesc.pData', '_MapDesc.Size') print ' }' DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) if method.name == 'Map': # NOTE: recursive locks are explicitely forbidden + print ' _MAP_DESC _MapDesc;' print ' if (SUCCEEDED(_result)) {' - print ' _getMapInfo(_this, %s, _pMappedData, _MappedSize);' % ', '.join(method.argNames()) + print ' _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames()) print ' } else {' - print ' _pMappedData = NULL;' - print ' _MappedSize = 0;' + print ' _MapDesc.pData = NULL;' + print ' _MapDesc.Size = 0;' print ' }' + #print r' os::log("%%p <- %%p+%%lu\n", %s,_MapDesc.pData, (unsigned long)_MapDesc.Size);' % pResource + print ' %s->_MapDesc = _MapDesc;' % pResource if __name__ == '__main__': @@ -88,26 +140,24 @@ if __name__ == '__main__': api = API() if moduleNames: - api.addModule(dxgi) + api.addModule(dxgi.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) + api.addModule(d3d10_1.d3d10_1) else: print r'#include "d3d10imports.hpp"' print r'#include "d3d10size.hpp"' - api.addModule(d3d10) + api.addModule(d3d10.d3d10) if 'd3d11' in moduleNames: print r'#include "d3d11imports.hpp"' if 'd3d11_1' in moduleNames: print '#include ' - import specs.d3d11_1 + from specs import d3d11_1 print r'#include "d3d11size.hpp"' - api.addModule(d3d11) + api.addModule(d3d11.d3d11) tracer = D3DCommonTracer() tracer.traceApi(api)