From bd0863402aa31ad674ca248ba82dfcc1ee90afea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 18 Apr 2012 19:58:32 +0100 Subject: [PATCH] Trace/retrace IDirect3DVertexBuffer9 locks --- retrace/d3dretrace.py | 14 ++++++++++++-- specs/stdapi.py | 6 ++++++ wrappers/d3d9trace.py | 19 +++++++++++++++---- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/retrace/d3dretrace.py b/retrace/d3dretrace.py index ca936f2..0d63746 100644 --- a/retrace/d3dretrace.py +++ b/retrace/d3dretrace.py @@ -36,6 +36,11 @@ class D3DRetracer(Retracer): table_name = 'd3dretrace::d3d9_callbacks' + bufferInterfaceNames = [ + 'IDirect3DVertexBuffer9', + 'IDirect3DIndexBuffer9', + ] + def invokeInterfaceMethod(self, interface, method): if interface.name == 'IDirect3D9' and method.name == 'CreateDevice': print 'HWND hWnd = createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' @@ -49,9 +54,14 @@ class D3DRetracer(Retracer): print r' retrace::warning(call) << "failed\n";' print r' }' - if interface.name == 'IDirect3DVertexBuffer9' and method.name == 'Lock': + if interface.name in self.bufferInterfaceNames and method.name == 'Lock': + getDescMethod = interface.getMethodByName('GetDesc') + descArg = getDescMethod.args[0] + assert descArg.output + descType = getDescMethod.args[0].type.type + print ' if (!SizeToLock) {' - print ' D3DVERTEXBUFFER_DESC Desc;' + print ' %s Desc;' % descType print ' _this->GetDesc(&Desc);' print ' SizeToLock = Desc.Size;' print ' }' diff --git a/specs/stdapi.py b/specs/stdapi.py index b099578..ff7508b 100644 --- a/specs/stdapi.py +++ b/specs/stdapi.py @@ -401,6 +401,12 @@ class Interface(Type): def visit(self, visitor, *args, **kwargs): return visitor.visitInterface(self, *args, **kwargs) + def getMethodByName(self, name): + for methods in self.methods: + if methods.name == name: + return methods + return None + def iterMethods(self): if self.base is not None: for method in self.base.iterMethods(): diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py index 804e90f..9fb290d 100644 --- a/wrappers/d3d9trace.py +++ b/wrappers/d3d9trace.py @@ -38,28 +38,39 @@ class D3D9Tracer(DllTracer): DllTracer.serializeArgValue(self, function, arg) + bufferInterfaceNames = [ + 'IDirect3DVertexBuffer9', + 'IDirect3DIndexBuffer9', + ] + def declareWrapperInterfaceVariables(self, interface): DllTracer.declareWrapperInterfaceVariables(self, interface) - if interface.name == 'IDirect3DVertexBuffer9': + if interface.name in self.bufferInterfaceNames: print ' UINT m_SizeToLock;' print ' VOID *m_pbData;' def implementWrapperInterfaceMethodBody(self, interface, base, method): - if interface.name == 'IDirect3DVertexBuffer9' and method.name == 'Unlock': + if interface.name in self.bufferInterfaceNames and method.name == 'Unlock': print ' if (m_pbData) {' self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', 'm_SizeToLock') print ' }' DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method) - if interface.name == 'IDirect3DVertexBuffer9' and method.name == 'Lock': + if interface.name in self.bufferInterfaceNames and 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 (__result == D3D_OK && !(Flags & D3DLOCK_READONLY)) {' print ' if (SizeToLock) {' print ' m_SizeToLock = SizeToLock;' print ' } else {' - print ' D3DVERTEXBUFFER_DESC Desc;' + print ' %s Desc;' % descType print ' m_pInstance->GetDesc(&Desc);' print ' m_SizeToLock = Desc.Size;' print ' }' -- 2.7.4