]> git.cworth.org Git - apitrace/blobdiff - wrappers/d3d9trace.py
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / wrappers / d3d9trace.py
index d3f2e024a0330146d35f79a2de80fd05148fbcf2..f3236e729b64d34c5e400aeb7855a894f49ffdbe 100644 (file)
 
 
 from dlltrace import DllTracer
+from specs.stdapi import API
 from specs.d3d9 import d3d9, D3DSHADER9
 
+import specs.d3d9dxva2
+
 
 class D3D9Tracer(DllTracer):
 
@@ -41,11 +44,12 @@ class D3D9Tracer(DllTracer):
     def enumWrapperInterfaceVariables(self, interface):
         variables = DllTracer.enumWrapperInterfaceVariables(self, interface)
         
+        # 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'),
+                ('size_t', '_MappedSize', '0'),
                 ('VOID *', 'm_pbData', '0'),
             ]
 
@@ -53,26 +57,19 @@ class D3D9Tracer(DllTracer):
 
     def implementWrapperInterfaceMethodBody(self, interface, base, method):
         if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'):
-            print '    if (_LockedSize && m_pbData) {'
-            self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', '_LockedSize')
+            print '    if (_MappedSize && m_pbData) {'
+            self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', '_MappedSize')
             print '    }'
 
         DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method)
 
-        if method.name in ('Lock', 'LockRect', 'LockedBox'):
+        if method.name in ('Lock', 'LockRect', 'LockBox'):
+            # FIXME: handle recursive locks
             print '    if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {'
-            print '        _LockedSize = _getLockSize(_this, %s);' % ', '.join(method.argNames()[:-1])
-            if method.name == 'Lock':
-                # FIXME: handle recursive locks
-                print '        m_pbData = *ppbData;'
-            elif method.name == 'LockRect':
-                print '        m_pbData = pLockedRect->pBits;'
-            elif method.name == 'LockBox':
-                print '        m_pbData = pLockedBox->pBits;'
-            else:
-                raise NotImplementedError
+            print '        _getMapInfo(_this, %s, m_pbData, _MappedSize);' % ', '.join(method.argNames()[:-1])
             print '    } else {'
             print '        m_pbData = NULL;'
+            print '        _MappedSize = 0;'
             print '    }'
 
 
@@ -83,20 +80,12 @@ 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 '#include "dxvaint.h"'
     print
-    print '''
-static inline size_t
-_declCount(const D3DVERTEXELEMENT9 *pVertexElements) {
-    size_t count = 0;
-    if (pVertexElements) {
-        while (pVertexElements[count++].Stream != 0xff)
-            ;
-    }
-    return count;
-}
-'''
-    tracer = D3D9Tracer('d3d9.dll')
-    tracer.traceApi(d3d9)
 
+    api = API()
+    api.addModule(d3d9)
+    tracer = D3D9Tracer()
+    tracer.traceApi(api)