X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=wrappers%2Fd3d9trace.py;h=df39927f787a7854a233eb4689d9e39698aca4b7;hb=82715be6c3d6bf058c9eca236bf30d26cc7fd22f;hp=566ac76e0b7015c9e03a08bd65b54ec4e0a0ca2f;hpb=a0e97860386786fcdb106471a3908b4ba66242e6;p=apitrace diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py index 566ac76..df39927 100644 --- a/wrappers/d3d9trace.py +++ b/wrappers/d3d9trace.py @@ -38,54 +38,35 @@ class D3D9Tracer(DllTracer): DllTracer.serializeArgValue(self, function, arg) - bufferInterfaceNames = [ - 'IDirect3DVertexBuffer9', - 'IDirect3DIndexBuffer9', - ] - - def declareWrapperInterfaceVariables(self, interface): - DllTracer.declareWrapperInterfaceVariables(self, interface) + def enumWrapperInterfaceVariables(self, interface): + variables = DllTracer.enumWrapperInterfaceVariables(self, interface) - if interface.name in self.bufferInterfaceNames or \ - interface.name == 'IDirect3DSurface9': - print ' UINT m_SizeToLock;' - print ' VOID *m_pbData;' + # Add additional members to track locks + if interface.getMethodByName('Lock') is not None or \ + interface.getMethodByName('LockRect') is not None or \ + interface.getMethodByName('LockBox') is not None: + variables += [ + ('size_t', '_LockedSize', '0'), + ('VOID *', 'm_pbData', '0'), + ] + + return variables def implementWrapperInterfaceMethodBody(self, interface, base, method): - if interface.name in self.bufferInterfaceNames and method.name == 'Unlock' or \ - interface.name == 'IDirect3DSurface9' and method.name == 'UnlockRect': - print ' if (m_pbData) {' - self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', 'm_SizeToLock') + if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): + print ' if (_LockedSize && m_pbData) {' + self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', '_LockedSize') print ' }' DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) - if interface.name in self.bufferInterfaceNames and method.name == 'Lock' or \ - interface.name == 'IDirect3DSurface9' and method.name == 'LockRect': + if method.name in ('Lock', 'LockRect', 'LockBox'): # FIXME: handle recursive locks - - getDescMethod = interface.getMethodByName('GetDesc') - descArg = getDescMethod.args[0] - assert descArg.output - descType = getDescMethod.args[0].type.type - - print ' if (_result == D3D_OK && !(Flags & D3DLOCK_READONLY)) {' - if interface.name in self.bufferInterfaceNames: - print ' if (SizeToLock) {' - print ' m_SizeToLock = SizeToLock;' - print ' } else {' - print ' %s Desc;' % descType - print ' m_pInstance->GetDesc(&Desc);' - print ' m_SizeToLock = Desc.Size;' - print ' }' - print ' m_pbData = *ppbData;' - elif interface.name == 'IDirect3DSurface9': - print ' m_SizeToLock = _lockSize(_this, pLockedRect, pRect);' - print ' m_pbData = pLockedRect->pBits;' - else: - raise NotImplementedError + print ' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {' + print ' _getLockInfo(_this, %s, m_pbData, _LockedSize);' % ', '.join(method.argNames()[:-1]) print ' } else {' print ' m_pbData = NULL;' + print ' _LockedSize = 0;' print ' }' @@ -96,8 +77,8 @@ if __name__ == '__main__': print '#include "os.hpp"' print print '#include "d3d9imports.hpp"' - print '#include "d3dsize.hpp"' - print '#include "d3dshader.hpp"' + print '#include "d3d9size.hpp"' + print '#include "d3d9shader.hpp"' print print ''' static inline size_t