diff options
-rw-r--r-- | helpers/d3dsize.hpp | 30 | ||||
-rw-r--r-- | retrace/d3dretrace.py | 19 | ||||
-rw-r--r-- | specs/d3d9.py | 4 | ||||
-rw-r--r-- | wrappers/d3d9trace.py | 29 |
4 files changed, 39 insertions, 43 deletions
diff --git a/helpers/d3dsize.hpp b/helpers/d3dsize.hpp index 97fccd3e..92503fe8 100644 --- a/helpers/d3dsize.hpp +++ b/helpers/d3dsize.hpp @@ -161,6 +161,36 @@ _formatSize(D3DFORMAT Format, UINT Width, UINT Height, INT Pitch) { static inline size_t +_getLockSize(IDirect3DVertexBuffer9 *pBuffer, UINT OffsetToLock, UINT SizeToLock, void ** ppbData) { + if (SizeToLock == 0) { + D3DVERTEXBUFFER_DESC Desc; + HRESULT hr = pBuffer->GetDesc(&Desc); + if (FAILED(hr)) { + return 0; + } + SizeToLock = Desc.Size; + } + + return SizeToLock; +} + + +static inline size_t +_getLockSize(IDirect3DIndexBuffer9 *pBuffer, UINT OffsetToLock, UINT SizeToLock, void ** ppbData) { + if (SizeToLock == 0) { + D3DINDEXBUFFER_DESC Desc; + HRESULT hr = pBuffer->GetDesc(&Desc); + if (FAILED(hr)) { + return 0; + } + SizeToLock = Desc.Size; + } + + return SizeToLock; +} + + +static inline size_t _getLockSize(IDirect3DSurface9 *pSurface, const D3DLOCKED_RECT *pLockedRect, const RECT *pRect) { HRESULT hr; diff --git a/retrace/d3dretrace.py b/retrace/d3dretrace.py index 36b75b18..8af52654 100644 --- a/retrace/d3dretrace.py +++ b/retrace/d3dretrace.py @@ -60,23 +60,8 @@ class D3DRetracer(Retracer): print r' retrace::warning(call) << "failed\n";' print r' }' - if interface.name in self.bufferInterfaceNames and method.name == 'Lock' or \ - method.name == 'LockRect': - - if interface.name in self.bufferInterfaceNames: - getDescMethod = interface.getMethodByName('GetDesc') - descArg = getDescMethod.args[0] - assert descArg.output - descType = getDescMethod.args[0].type.type - print ' if (!SizeToLock) {' - print ' %s Desc;' % descType - print ' _this->GetDesc(&Desc);' - print ' SizeToLock = Desc.Size;' - print ' }' - elif method.name == 'LockRect': - print ' size_t _LockedSize = _getLockSize(_this, %s);' % ', '.join(method.argNames()[:-1]) - else: - raise NotImplementedError + if method.name in ('Lock', 'LockRect'): + print ' size_t _LockedSize = _getLockSize(_this, %s);' % ', '.join(method.argNames()[:-1]) if __name__ == '__main__': diff --git a/specs/d3d9.py b/specs/d3d9.py index 2fd7755d..78bd7da0 100644 --- a/specs/d3d9.py +++ b/specs/d3d9.py @@ -347,13 +347,13 @@ IDirect3DCubeTexture9.methods += [ ] IDirect3DVertexBuffer9.methods += [ - Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(LinearPointer(Void, "SizeToLock")), "ppbData"), (D3DLOCK, "Flags")]), + Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(LinearPointer(Void, "_LockedSize")), "ppbData"), (D3DLOCK, "Flags")]), Method(HRESULT, "Unlock", []), Method(HRESULT, "GetDesc", [Out(Pointer(D3DVERTEXBUFFER_DESC), "pDesc")], sideeffects=False), ] IDirect3DIndexBuffer9.methods += [ - Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(LinearPointer(Void, "SizeToLock")), "ppbData"), (D3DLOCK, "Flags")]), + Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(LinearPointer(Void, "_LockedSize")), "ppbData"), (D3DLOCK, "Flags")]), Method(HRESULT, "Unlock", []), Method(HRESULT, "GetDesc", [Out(Pointer(D3DINDEXBUFFER_DESC), "pDesc")], sideeffects=False), ] diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py index b2afdf9b..dbace8fe 100644 --- a/wrappers/d3d9trace.py +++ b/wrappers/d3d9trace.py @@ -38,49 +38,30 @@ class D3D9Tracer(DllTracer): DllTracer.serializeArgValue(self, function, arg) - bufferInterfaceNames = [ - 'IDirect3DVertexBuffer9', - 'IDirect3DIndexBuffer9', - ] - def declareWrapperInterfaceVariables(self, interface): DllTracer.declareWrapperInterfaceVariables(self, interface) - if interface.name in self.bufferInterfaceNames or \ + if interface.getMethodByName('Lock') is not None or \ interface.getMethodByName('LockRect') is not None: print ' size_t _LockedSize;' print ' VOID *m_pbData;' def implementWrapperInterfaceMethodBody(self, interface, base, method): - if interface.name in self.bufferInterfaceNames and method.name == 'Unlock' or \ - method.name == 'UnlockRect': + if method.name in ('Unlock', 'UnlockRect'): print ' if (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 \ - method.name == 'LockRect': - + if method.name in ('Lock', 'LockRect'): print ' if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {' - if interface.name in self.bufferInterfaceNames: + print ' _LockedSize = _getLockSize(_this, %s);' % ', '.join(method.argNames()[:-1]) + if method.name == 'Lock': # FIXME: handle recursive locks - getDescMethod = interface.getMethodByName('GetDesc') - descArg = getDescMethod.args[0] - assert descArg.output - descType = getDescMethod.args[0].type.type - print ' if (SizeToLock) {' - print ' _LockedSize = SizeToLock;' - print ' } else {' - print ' %s Desc;' % descType - print ' m_pInstance->GetDesc(&Desc);' - print ' _LockedSize = Desc.Size;' - print ' }' print ' m_pbData = *ppbData;' elif method.name == 'LockRect': - print ' _LockedSize = _getLockSize(_this, %s);' % ', '.join(method.argNames()[:-1]) print ' m_pbData = pLockedRect->pBits;' else: raise NotImplementedError |