]> git.cworth.org Git - apitrace/commitdiff
Handle more REFIID queries.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 31 Jan 2012 12:19:57 +0000 (12:19 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 31 Jan 2012 12:19:57 +0000 (12:19 +0000)
d3d10trace.py
specs/d3d10misc.py
trace.py

index a2120032946e974fe31c36312bb8294ce27db8ac..7d0fc75573d8121497a7d27b5a1c9d0bf4eaae2c 100644 (file)
@@ -29,6 +29,8 @@ from dlltrace import DllTracer
 
 
 if __name__ == '__main__':
+    print '#define INITGUID'
+    print
     print '#include "trace_writer_local.hpp"'
     print '#include "os.hpp"'
     print
index 8ee9cf7249bfa141d29dc36be9ed256a8f429a17..a129382d6f11e70a26b3a268ae186d63abe9f105 100644 (file)
@@ -47,8 +47,36 @@ D3D10_DRIVER_TYPE = Enum("D3D10_DRIVER_TYPE", [
 
 
 d3d10 = API("d3d10")
+
 d3d10.addFunctions([
     StdFunction(HRESULT, "D3D10CreateDevice", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), Out(Pointer(Pointer(ID3D10Device)), "ppDevice")]),
     StdFunction(HRESULT, "D3D10CreateDeviceAndSwapChain", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), Out(Pointer(Pointer(IDXGISwapChain)), "ppSwapChain"), Out(Pointer(Pointer(ID3D10Device)), "ppDevice")]),
     StdFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), Out(Pointer(LPD3D10BLOB), "ppBuffer")]),
 ])
+
+d3d10.addInterfaces([
+    ID3D10DeviceChild,
+    ID3D10Resource,
+    ID3D10Buffer,
+    ID3D10Texture1D,
+    ID3D10Texture2D,
+    ID3D10Texture3D,
+    ID3D10View,
+    ID3D10DepthStencilView,
+    ID3D10RenderTargetView,
+    ID3D10ShaderResourceView,
+    ID3D10BlendState,
+    ID3D10DepthStencilState,
+    ID3D10GeometryShader,
+    ID3D10InputLayout,
+    ID3D10PixelShader,
+    ID3D10RasterizerState,
+    ID3D10SamplerState,
+    ID3D10VertexShader,
+    ID3D10Asynchronous,
+    ID3D10Counter,
+    ID3D10Query,
+    ID3D10Predicate,
+    ID3D10Device,
+    ID3D10Multithread,
+])
index 0d973a21082bcd1989feeb9b39ad969c1a7a09bc..c759607ebe12678b0e9012c4363d2608d0a5bb81 100644 (file)
--- a/trace.py
+++ b/trace.py
@@ -484,10 +484,17 @@ class Tracer:
         print '    trace::localWriter.beginArg(0);'
         print '    trace::localWriter.writeOpaque((const void *)m_pInstance);'
         print '    trace::localWriter.endArg();'
+
+        from specs.winapi import REFIID
+        from specs.stdapi import Pointer, Opaque
+
+        riid = None
         for arg in method.args:
             if not arg.output:
                 self.unwrapArg(method, arg)
                 self.serializeArg(method, arg)
+                if arg.type is REFIID:
+                    riid = arg
         print '    trace::localWriter.endEnter();'
         
         self.invokeMethod(interface, method)
@@ -497,38 +504,43 @@ class Tracer:
             if arg.output:
                 self.serializeArg(method, arg)
                 self.wrapArg(method, arg)
+                if riid is not None and isinstance(arg.type, Pointer):
+                    assert isinstance(arg.type.type, Opaque)
+                    self.wrapIid(interface, method, riid, arg)
+
         if method.type is not stdapi.Void:
             print '    trace::localWriter.beginReturn();'
             self.serializeValue(method.type, "__result")
             print '    trace::localWriter.endReturn();'
             self.wrapValue(method.type, '__result')
         print '    trace::localWriter.endLeave();'
-        if method.name == 'QueryInterface':
-            print '    if (ppvObj && *ppvObj) {'
-            print '        if (*ppvObj == m_pInstance) {'
-            print '            *ppvObj = this;'
+        if method.name == 'Release':
+            assert method.type is not stdapi.Void
+            print '    if (!__result)'
+            print '        delete this;'
+
+    def wrapIid(self, interface, method, riid, out):
+            print '    if (%s && *%s) {' % (out.name, out.name)
+            print '        if (*%s == m_pInstance) {' % (out.name,)
+            print '            *%s = this;' % (out.name,)
             print '        }'
             for iface in self.api.interfaces:
-                print r'        else if (riid == IID_%s) {' % iface.name
-                print r'            *ppvObj = new Wrap%s((%s *) *ppvObj);' % (iface.name, iface.name)
+                print r'        else if (%s == IID_%s) {' % (riid.name, iface.name)
+                print r'            *%s = new Wrap%s((%s *) *%s);' % (out.name, iface.name, iface.name, out.name)
                 print r'        }'
             print r'        else {'
             print r'            os::log("apitrace: warning: unknown REFIID {0x%08lX,0x%04X,0x%04X,{0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X}}\n",'
-            print r'                    riid.Data1, riid.Data2, riid.Data3,'
-            print r'                    riid.Data4[0],'
-            print r'                    riid.Data4[1],'
-            print r'                    riid.Data4[2],'
-            print r'                    riid.Data4[3],'
-            print r'                    riid.Data4[4],'
-            print r'                    riid.Data4[5],'
-            print r'                    riid.Data4[6],'
-            print r'                    riid.Data4[7]);'
+            print r'                    %s.Data1, %s.Data2, %s.Data3,' % (riid.name, riid.name, riid.name)
+            print r'                    %s.Data4[0],' % (riid.name,)
+            print r'                    %s.Data4[1],' % (riid.name,)
+            print r'                    %s.Data4[2],' % (riid.name,)
+            print r'                    %s.Data4[3],' % (riid.name,)
+            print r'                    %s.Data4[4],' % (riid.name,)
+            print r'                    %s.Data4[5],' % (riid.name,)
+            print r'                    %s.Data4[6],' % (riid.name,)
+            print r'                    %s.Data4[7]);' % (riid.name,)
             print r'        }'
             print '    }'
-        if method.name == 'Release':
-            assert method.type is not stdapi.Void
-            print '    if (!__result)'
-            print '        delete this;'
 
     def invokeMethod(self, interface, method):
         if method.type is stdapi.Void: