from dlltrace import DllTracer
from specs.d3d9 import d3d9, D3DSHADER9
+import specs.d3d9dxva2
+
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 == 'DecodeExecute':
+ print r' _NumCompBuffers = pExecuteParams->NumCompBuffers;'
+
+ if method.name == 'VideoProcessBlt':
+ print r' _NumSrcSurfaces = pData->NumSrcSurfaces;'
+
+ 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 ' UINT Width;'
- print ' UINT Height;'
- print ' if (pRect) {'
- print ' Width = pRect->right - pRect->left;'
- print ' Height = pRect->bottom - pRect->top;'
- print ' } else {'
- print ' %s Desc;' % descType
- print ' m_pInstance->GetDesc(&Desc);'
- print ' Width = Desc.Width;'
- print ' Height = Desc.Height;'
- print ' }'
- print ' m_SizeToLock = Height * pLockedRect->Pitch;'
- # TODO: take in consideration the width and pixels and blocks
- print ' (void)Width;'
- 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 ' }'
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 '#include "dxvaint.h"'
print
print '''
static inline size_t
}
return count;
}
+
+static UINT _NumCompBuffers = 0; /* XXX */
+static UINT _NumSrcSurfaces = 0; /* XXX */
'''
tracer = D3D9Tracer('d3d9.dll')
tracer.traceApi(d3d9)