from dlltrace import DllTracer
-from specs.d3d9 import d3d9
+from specs.d3d9 import d3d9, D3DSHADER9
class D3D9Tracer(DllTracer):
def serializeArgValue(self, function, arg):
# Dump shaders as strings
- if function.name in ('CreateVertexShader', 'CreatePixelShader') and arg.name == 'pFunction':
+ if arg.type is D3DSHADER9:
print ' DumpShader(trace::localWriter, %s);' % (arg.name)
return
def declareWrapperInterfaceVariables(self, interface):
DllTracer.declareWrapperInterfaceVariables(self, interface)
- if interface.name in self.bufferInterfaceNames:
+ if interface.name in self.bufferInterfaceNames or \
+ interface.name == 'IDirect3DSurface9':
print ' UINT m_SizeToLock;'
print ' VOID *m_pbData;'
def implementWrapperInterfaceMethodBody(self, interface, base, method):
- if interface.name in self.bufferInterfaceNames and method.name == 'Unlock':
+ 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')
print ' }'
DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method)
- if interface.name in self.bufferInterfaceNames and method.name == 'Lock':
+ if interface.name in self.bufferInterfaceNames and method.name == 'Lock' or \
+ interface.name == 'IDirect3DSurface9' and method.name == 'LockRect':
# FIXME: handle recursive locks
getDescMethod = interface.getMethodByName('GetDesc')
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 ' %s Desc;' % descType
- print ' m_pInstance->GetDesc(&Desc);'
- print ' m_SizeToLock = Desc.Size;'
- print ' }'
- print ' m_pbData = *ppbData;'
+ 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 ' } else {'
print ' m_pbData = NULL;'
print ' }'