]> git.cworth.org Git - apitrace/blob - d3d9.py
Fix a few more arrays args in D3D9.
[apitrace] / d3d9.py
1 ##########################################################################
2 #
3 # Copyright 2008-2009 VMware, Inc.
4 # All Rights Reserved.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24 ##########################################################################/
25
26 """d3d9.h"""
27
28 from winapi import *
29 from d3d9types import *
30 from d3d9caps import *
31 from trace import DllTracer
32
33 D3DSHADER9 = Opaque("const DWORD *")
34
35 HRESULT = Enum("HRESULT", [
36     "D3D_OK",
37     "D3DERR_WRONGTEXTUREFORMAT",
38     "D3DERR_UNSUPPORTEDCOLOROPERATION",
39     "D3DERR_UNSUPPORTEDCOLORARG",
40     "D3DERR_UNSUPPORTEDALPHAOPERATION",
41     "D3DERR_UNSUPPORTEDALPHAARG",
42     "D3DERR_TOOMANYOPERATIONS",
43     "D3DERR_CONFLICTINGTEXTUREFILTER",
44     "D3DERR_UNSUPPORTEDFACTORVALUE",
45     "D3DERR_CONFLICTINGRENDERSTATE",
46     "D3DERR_UNSUPPORTEDTEXTUREFILTER",
47     "D3DERR_CONFLICTINGTEXTUREPALETTE",
48     "D3DERR_DRIVERINTERNALERROR",
49     "D3DERR_NOTFOUND",
50     "D3DERR_MOREDATA",
51     "D3DERR_DEVICELOST",
52     "D3DERR_DEVICENOTRESET",
53     "D3DERR_NOTAVAILABLE",
54     "D3DERR_OUTOFVIDEOMEMORY",
55     "D3DERR_INVALIDDEVICE",
56     "D3DERR_INVALIDCALL",
57     "D3DERR_DRIVERINVALIDCALL",
58     "D3DERR_WASSTILLDRAWING",
59     "D3DOK_NOAUTOGEN",
60     "D3DERR_DEVICEREMOVED",
61     "S_NOT_RESIDENT",
62     "S_RESIDENT_IN_SHARED_MEMORY",
63     "S_PRESENT_MODE_CHANGED",
64     "S_PRESENT_OCCLUDED",
65     "D3DERR_DEVICEHUNG",
66 ])
67
68 IDirect3D9 = Interface("IDirect3D9", IUnknown)
69 IDirect3DDevice9 = Interface("IDirect3DDevice9", IUnknown)
70 IDirect3DStateBlock9 = Interface("IDirect3DStateBlock9", IUnknown)
71 IDirect3DSwapChain9 = Interface("IDirect3DSwapChain9", IUnknown)
72 IDirect3DResource9 = Interface("IDirect3DResource9", IUnknown)
73 IDirect3DVertexDeclaration9 = Interface("IDirect3DVertexDeclaration9", IUnknown)
74 IDirect3DVertexShader9 = Interface("IDirect3DVertexShader9", IUnknown)
75 IDirect3DPixelShader9 = Interface("IDirect3DPixelShader9", IUnknown)
76 IDirect3DBaseTexture9 = Interface("IDirect3DBaseTexture9", IDirect3DResource9)
77 IDirect3DTexture9 = Interface("IDirect3DTexture9", IDirect3DBaseTexture9)
78 IDirect3DVolumeTexture9 = Interface("IDirect3DVolumeTexture9", IDirect3DBaseTexture9)
79 IDirect3DCubeTexture9 = Interface("IDirect3DCubeTexture9", IDirect3DBaseTexture9)
80 IDirect3DVertexBuffer9 = Interface("IDirect3DVertexBuffer9", IDirect3DResource9)
81 IDirect3DIndexBuffer9 = Interface("IDirect3DIndexBuffer9", IDirect3DResource9)
82 IDirect3DSurface9 = Interface("IDirect3DSurface9", IDirect3DResource9)
83 IDirect3DVolume9 = Interface("IDirect3DVolume9", IUnknown)
84 IDirect3DQuery9 = Interface("IDirect3DQuery9", IUnknown)
85 IDirect3D9Ex = Interface("IDirect3D9Ex", IDirect3D9)
86 IDirect3DDevice9Ex = Interface("IDirect3DDevice9Ex", IDirect3DDevice9)
87 IDirect3DSwapChain9Ex = Interface("IDirect3DSwapChain9Ex", IDirect3DSwapChain9)
88
89 PDIRECT3D9 = WrapPointer(IDirect3D9)
90 PDIRECT3DDEVICE9 = WrapPointer(IDirect3DDevice9)
91 PDIRECT3DSTATEBLOCK9 = WrapPointer(IDirect3DStateBlock9)
92 PDIRECT3DSWAPCHAIN9 = WrapPointer(IDirect3DSwapChain9)
93 PDIRECT3DRESOURCE9 = WrapPointer(IDirect3DResource9)
94 PDIRECT3DVERTEXDECLARATION9 = WrapPointer(IDirect3DVertexDeclaration9)
95 PDIRECT3DVERTEXSHADER9 = WrapPointer(IDirect3DVertexShader9)
96 PDIRECT3DPIXELSHADER9 = WrapPointer(IDirect3DPixelShader9)
97 PDIRECT3DBASETEXTURE9 = WrapPointer(IDirect3DBaseTexture9)
98 PDIRECT3DTEXTURE9 = WrapPointer(IDirect3DTexture9)
99 PDIRECT3DVOLUMETEXTURE9 = WrapPointer(IDirect3DVolumeTexture9)
100 PDIRECT3DCUBETEXTURE9 = WrapPointer(IDirect3DCubeTexture9)
101 PDIRECT3DVERTEXBUFFER9 = WrapPointer(IDirect3DVertexBuffer9)
102 PDIRECT3DINDEXBUFFER9 = WrapPointer(IDirect3DIndexBuffer9)
103 PDIRECT3DSURFACE9 = WrapPointer(IDirect3DSurface9)
104 PDIRECT3DVOLUME9 = WrapPointer(IDirect3DVolume9)
105 PDIRECT3DQUERY9 = WrapPointer(IDirect3DQuery9)
106 PDIRECT3D9EX = WrapPointer(IDirect3D9Ex)
107 PDIRECT3DDEVICE9EX = WrapPointer(IDirect3DDevice9Ex)
108 PDIRECT3DSWAPCHAIN9EX = WrapPointer(IDirect3DSwapChain9Ex)
109
110 IDirect3D9.methods += [
111     Method(HRESULT, "RegisterSoftwareDevice", [(OpaquePointer(Void), "pInitializeFunction")]),
112     Method(UINT, "GetAdapterCount", []),
113     Method(HRESULT, "GetAdapterIdentifier", [(UINT, "Adapter"), (DWORD, "Flags"), Out(Pointer(D3DADAPTER_IDENTIFIER9), "pIdentifier")]),
114     Method(UINT, "GetAdapterModeCount", [(UINT, "Adapter"), (D3DFORMAT, "Format")]),
115     Method(HRESULT, "EnumAdapterModes", [(UINT, "Adapter"), (D3DFORMAT, "Format"), (UINT, "Mode"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
116     Method(HRESULT, "GetAdapterDisplayMode", [(UINT, "Adapter"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
117     Method(HRESULT, "CheckDeviceType", [(UINT, "Adapter"), (D3DDEVTYPE, "DevType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "BackBufferFormat"), (BOOL, "bWindowed")]),
118     Method(HRESULT, "CheckDeviceFormat", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (D3DUSAGE, "Usage"), (D3DRESOURCETYPE, "RType"), (D3DFORMAT, "CheckFormat")]),
119     Method(HRESULT, "CheckDeviceMultiSampleType", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SurfaceFormat"), (BOOL, "Windowed"), (D3DMULTISAMPLE_TYPE, "MultiSampleType"), Out(Pointer(DWORD), "pQualityLevels")]),
120     Method(HRESULT, "CheckDepthStencilMatch", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "RenderTargetFormat"), (D3DFORMAT, "DepthStencilFormat")]),
121     Method(HRESULT, "CheckDeviceFormatConversion", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SourceFormat"), (D3DFORMAT, "TargetFormat")]),
122     Method(HRESULT, "GetDeviceCaps", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), Out(Pointer(D3DCAPS9), "pCaps")]),
123     Method(HMONITOR, "GetAdapterMonitor", [(UINT, "Adapter")]),
124     Method(HRESULT, "CreateDevice", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (DWORD, "BehaviorFlags"), Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(PDIRECT3DDEVICE9), "ppReturnedDeviceInterface")]),
125 ]
126
127 IDirect3DDevice9.methods += [
128     Method(HRESULT, "TestCooperativeLevel", []),
129     Method(UINT, "GetAvailableTextureMem", []),
130     Method(HRESULT, "EvictManagedResources", []),
131     Method(HRESULT, "GetDirect3D", [Out(Pointer(PDIRECT3D9), "ppD3D9")]),
132     Method(HRESULT, "GetDeviceCaps", [Out(Pointer(D3DCAPS9), "pCaps")]),
133     Method(HRESULT, "GetDisplayMode", [(UINT, "iSwapChain"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
134     Method(HRESULT, "GetCreationParameters", [Out(Pointer(D3DDEVICE_CREATION_PARAMETERS), "pParameters")]),
135     Method(HRESULT, "SetCursorProperties", [(UINT, "XHotSpot"), (UINT, "YHotSpot"), (PDIRECT3DSURFACE9, "pCursorBitmap")]),
136     Method(Void, "SetCursorPosition", [(Int, "X"), (Int, "Y"), (DWORD, "Flags")]),
137     Method(BOOL, "ShowCursor", [(BOOL, "bShow")]),
138     Method(HRESULT, "CreateAdditionalSwapChain", [Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(PDIRECT3DSWAPCHAIN9), "pSwapChain")]),
139     Method(HRESULT, "GetSwapChain", [(UINT, "iSwapChain"), Out(Pointer(PDIRECT3DSWAPCHAIN9), "pSwapChain")]),
140     Method(UINT, "GetNumberOfSwapChains", []),
141     Method(HRESULT, "Reset", [Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters")]),
142     Method(HRESULT, "Present", [(ConstPointer(RECT), "pSourceRect"), (ConstPointer(RECT), "pDestRect"), (HWND, "hDestWindowOverride"), (ConstPointer(RGNDATA), "pDirtyRegion")]),
143     Method(HRESULT, "GetBackBuffer", [(UINT, "iSwapChain"), (UINT, "iBackBuffer"), (D3DBACKBUFFER_TYPE, "Type"), Out(Pointer(PDIRECT3DSURFACE9), "ppBackBuffer")]),
144     Method(HRESULT, "GetRasterStatus", [(UINT, "iSwapChain"), Out(Pointer(D3DRASTER_STATUS), "pRasterStatus")]),
145     Method(HRESULT, "SetDialogBoxMode", [(BOOL, "bEnableDialogs")]),
146     Method(Void, "SetGammaRamp", [(UINT, "iSwapChain"), (DWORD, "Flags"), (ConstPointer(D3DGAMMARAMP), "pRamp")]),
147     Method(Void, "GetGammaRamp", [(UINT, "iSwapChain"), Out(Pointer(D3DGAMMARAMP), "pRamp")]),
148     Method(HRESULT, "CreateTexture", [(UINT, "Width"), (UINT, "Height"), (UINT, "Levels"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DTEXTURE9), "ppTexture"), Out(Pointer(HANDLE), "pSharedHandle")]),
149     Method(HRESULT, "CreateVolumeTexture", [(UINT, "Width"), (UINT, "Height"), (UINT, "Depth"), (UINT, "Levels"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DVOLUMETEXTURE9), "ppVolumeTexture"), Out(Pointer(HANDLE), "pSharedHandle")]),
150     Method(HRESULT, "CreateCubeTexture", [(UINT, "EdgeLength"), (UINT, "Levels"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DCUBETEXTURE9), "ppCubeTexture"), Out(Pointer(HANDLE), "pSharedHandle")]),
151     Method(HRESULT, "CreateVertexBuffer", [(UINT, "Length"), (D3DUSAGE, "Usage"), (D3DFVF, "FVF"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DVERTEXBUFFER9), "ppVertexBuffer"), Out(Pointer(HANDLE), "pSharedHandle")]),
152     Method(HRESULT, "CreateIndexBuffer", [(UINT, "Length"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DINDEXBUFFER9), "ppIndexBuffer"), Out(Pointer(HANDLE), "pSharedHandle")]),
153     Method(HRESULT, "CreateRenderTarget", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Lockable"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle")]),
154     Method(HRESULT, "CreateDepthStencilSurface", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Discard"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle")]),
155     Method(HRESULT, "UpdateSurface", [(PDIRECT3DSURFACE9, "pSourceSurface"), (ConstPointer(RECT), "pSourceRect"), (PDIRECT3DSURFACE9, "pDestinationSurface"), (ConstPointer(POINT), "pDestPoint")]),
156     Method(HRESULT, "UpdateTexture", [(PDIRECT3DBASETEXTURE9, "pSourceTexture"), (PDIRECT3DBASETEXTURE9, "pDestinationTexture")]),
157     Method(HRESULT, "GetRenderTargetData", [(PDIRECT3DSURFACE9, "pRenderTarget"), (PDIRECT3DSURFACE9, "pDestSurface")]),
158     Method(HRESULT, "GetFrontBufferData", [(UINT, "iSwapChain"), (PDIRECT3DSURFACE9, "pDestSurface")]),
159     Method(HRESULT, "StretchRect", [(PDIRECT3DSURFACE9, "pSourceSurface"), (ConstPointer(RECT), "pSourceRect"), (PDIRECT3DSURFACE9, "pDestSurface"), (ConstPointer(RECT), "pDestRect"), (D3DTEXTUREFILTERTYPE, "Filter")]),
160     Method(HRESULT, "ColorFill", [(PDIRECT3DSURFACE9, "pSurface"), (ConstPointer(RECT), "pRect"), (D3DCOLOR, "color")]),
161     Method(HRESULT, "CreateOffscreenPlainSurface", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle")]),
162     Method(HRESULT, "SetRenderTarget", [(DWORD, "RenderTargetIndex"), (PDIRECT3DSURFACE9, "pRenderTarget")]),
163     Method(HRESULT, "GetRenderTarget", [(DWORD, "RenderTargetIndex"), Out(Pointer(PDIRECT3DSURFACE9), "ppRenderTarget")]),
164     Method(HRESULT, "SetDepthStencilSurface", [(PDIRECT3DSURFACE9, "pNewZStencil")]),
165     Method(HRESULT, "GetDepthStencilSurface", [Out(Pointer(PDIRECT3DSURFACE9), "ppZStencilSurface")]),
166     Method(HRESULT, "BeginScene", []),
167     Method(HRESULT, "EndScene", []),
168     Method(HRESULT, "Clear", [(DWORD, "Count"), (ConstPointer(D3DRECT), "pRects"), (D3DCLEAR, "Flags"), (D3DCOLOR, "Color"), (Float, "Z"), (DWORD, "Stencil")]),
169     Method(HRESULT, "SetTransform", [(D3DTRANSFORMSTATETYPE, "State"), (ConstPointer(D3DMATRIX), "pMatrix")]),
170     Method(HRESULT, "GetTransform", [(D3DTRANSFORMSTATETYPE, "State"), Out(Pointer(D3DMATRIX), "pMatrix")]),
171     Method(HRESULT, "MultiplyTransform", [(D3DTRANSFORMSTATETYPE, "State"), (ConstPointer(D3DMATRIX), "pMatrix")]),
172     Method(HRESULT, "SetViewport", [(ConstPointer(D3DVIEWPORT9), "pViewport")]),
173     Method(HRESULT, "GetViewport", [Out(Pointer(D3DVIEWPORT9), "pViewport")]),
174     Method(HRESULT, "SetMaterial", [(ConstPointer(D3DMATERIAL9), "pMaterial")]),
175     Method(HRESULT, "GetMaterial", [Out(Pointer(D3DMATERIAL9), "pMaterial")]),
176     Method(HRESULT, "SetLight", [(DWORD, "Index"), (ConstPointer(D3DLIGHT9), "pLight")]),
177     Method(HRESULT, "GetLight", [(DWORD, "Index"), Out(Pointer(D3DLIGHT9), "pLight")]),
178     Method(HRESULT, "LightEnable", [(DWORD, "Index"), (BOOL, "Enable")]),
179     Method(HRESULT, "GetLightEnable", [(DWORD, "Index"), Out(Pointer(BOOL), "pEnable")]),
180     Method(HRESULT, "SetClipPlane", [(DWORD, "Index"), (ConstPointer(Float), "pPlane")]),
181     Method(HRESULT, "GetClipPlane", [(DWORD, "Index"), Out(Pointer(Float), "pPlane")]),
182     Method(HRESULT, "SetRenderState", [(D3DRENDERSTATETYPE, "State"), (DWORD, "Value")]),
183     Method(HRESULT, "GetRenderState", [(D3DRENDERSTATETYPE, "State"), Out(Pointer(DWORD), "pValue")]),
184     Method(HRESULT, "CreateStateBlock", [(D3DSTATEBLOCKTYPE, "Type"), Out(Pointer(PDIRECT3DSTATEBLOCK9), "ppSB")]),
185     Method(HRESULT, "BeginStateBlock", []),
186     Method(HRESULT, "EndStateBlock", [Out(Pointer(PDIRECT3DSTATEBLOCK9), "ppSB")]),
187     Method(HRESULT, "SetClipStatus", [(ConstPointer(D3DCLIPSTATUS9), "pClipStatus")]),
188     Method(HRESULT, "GetClipStatus", [Out(Pointer(D3DCLIPSTATUS9), "pClipStatus")]),
189     Method(HRESULT, "GetTexture", [(DWORD, "Stage"), Out(Pointer(PDIRECT3DBASETEXTURE9), "ppTexture")]),
190     Method(HRESULT, "SetTexture", [(DWORD, "Stage"), (PDIRECT3DBASETEXTURE9, "pTexture")]),
191     Method(HRESULT, "GetTextureStageState", [(DWORD, "Stage"), (D3DTEXTURESTAGESTATETYPE, "Type"), Out(Pointer(DWORD), "pValue")]),
192     Method(HRESULT, "SetTextureStageState", [(DWORD, "Stage"), (D3DTEXTURESTAGESTATETYPE, "Type"), (DWORD, "Value")]),
193     Method(HRESULT, "GetSamplerState", [(DWORD, "Sampler"), (D3DSAMPLERSTATETYPE, "Type"), Out(Pointer(DWORD), "pValue")]),
194     Method(HRESULT, "SetSamplerState", [(DWORD, "Sampler"), (D3DSAMPLERSTATETYPE, "Type"), (DWORD, "Value")]),
195     Method(HRESULT, "ValidateDevice", [Out(Pointer(DWORD), "pNumPasses")]),
196     Method(HRESULT, "SetPaletteEntries", [(UINT, "PaletteNumber"), (ConstPointer(PALETTEENTRY), "pEntries")]),
197     Method(HRESULT, "GetPaletteEntries", [(UINT, "PaletteNumber"), Out(Pointer(PALETTEENTRY), "pEntries")]),
198     Method(HRESULT, "SetCurrentTexturePalette", [(UINT, "PaletteNumber")]),
199     Method(HRESULT, "GetCurrentTexturePalette", [Out(Pointer(UINT), "PaletteNumber")]),
200     Method(HRESULT, "SetScissorRect", [(ConstPointer(RECT), "pRect")]),
201     Method(HRESULT, "GetScissorRect", [Out(Pointer(RECT), "pRect")]),
202     Method(HRESULT, "SetSoftwareVertexProcessing", [(BOOL, "bSoftware")]),
203     Method(BOOL, "GetSoftwareVertexProcessing", []),
204     Method(HRESULT, "SetNPatchMode", [(Float, "nSegments")]),
205     Method(Float, "GetNPatchMode", []),
206     Method(HRESULT, "DrawPrimitive", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "StartVertex"), (UINT, "PrimitiveCount")]),
207     Method(HRESULT, "DrawIndexedPrimitive", [(D3DPRIMITIVETYPE, "PrimitiveType"), (INT, "BaseVertexIndex"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "startIndex"), (UINT, "primCount")]),
208     Method(HRESULT, "DrawPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "PrimitiveCount"), (OpaquePointer(Const(Void)), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]),
209     Method(HRESULT, "DrawIndexedPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "PrimitiveCount"), (OpaquePointer(Const(Void)), "pIndexData"), (D3DFORMAT, "IndexDataFormat"), (OpaquePointer(Const(Void)), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]),
210     Method(HRESULT, "ProcessVertices", [(UINT, "SrcStartIndex"), (UINT, "DestIndex"), (UINT, "VertexCount"), (PDIRECT3DVERTEXBUFFER9, "pDestBuffer"), (PDIRECT3DVERTEXDECLARATION9, "pVertexDecl"), (DWORD, "Flags")]),
211     Method(HRESULT, "CreateVertexDeclaration", [(ConstPointer(D3DVERTEXELEMENT9), "pVertexElements"), Out(Pointer(PDIRECT3DVERTEXDECLARATION9), "ppDecl")]),
212     Method(HRESULT, "SetVertexDeclaration", [(PDIRECT3DVERTEXDECLARATION9, "pDecl")]),
213     Method(HRESULT, "GetVertexDeclaration", [Out(Pointer(PDIRECT3DVERTEXDECLARATION9), "ppDecl")]),
214     Method(HRESULT, "SetFVF", [(D3DFVF, "FVF")]),
215     Method(HRESULT, "GetFVF", [Out(Pointer(D3DFVF), "pFVF")]),
216     Method(HRESULT, "CreateVertexShader", [(D3DSHADER9, "pFunction"), Out(Pointer(PDIRECT3DVERTEXSHADER9), "ppShader")]),
217     Method(HRESULT, "SetVertexShader", [(PDIRECT3DVERTEXSHADER9, "pShader")]),
218     Method(HRESULT, "GetVertexShader", [Out(Pointer(PDIRECT3DVERTEXSHADER9), "ppShader")]),
219     Method(HRESULT, "SetVertexShaderConstantF", [(UINT, "StartRegister"), (Const(Array(Float, "4*Vector4fCount")), "pConstantData"), (UINT, "Vector4fCount")]),
220     Method(HRESULT, "GetVertexShaderConstantF", [(UINT, "StartRegister"), Out(Array(Float, "4*Vector4fCount"), "pConstantData"), (UINT, "Vector4fCount")]),
221     Method(HRESULT, "SetVertexShaderConstantI", [(UINT, "StartRegister"), (Const(Array(Int, "4*Vector4iCount")), "pConstantData"), (UINT, "Vector4iCount")]),
222     Method(HRESULT, "GetVertexShaderConstantI", [(UINT, "StartRegister"), Out(Array(Int, "4*Vector4iCount"), "pConstantData"), (UINT, "Vector4iCount")]),
223     Method(HRESULT, "SetVertexShaderConstantB", [(UINT, "StartRegister"), (Const(Array(BOOL, "BoolCount")), "pConstantData"), (UINT, "BoolCount")]),
224     Method(HRESULT, "GetVertexShaderConstantB", [(UINT, "StartRegister"), Out(Array(BOOL, "BoolCount"), "pConstantData"), (UINT, "BoolCount")]),
225     Method(HRESULT, "SetStreamSource", [(UINT, "StreamNumber"), (PDIRECT3DVERTEXBUFFER9, "pStreamData"), (UINT, "OffsetInBytes"), (UINT, "Stride")]),
226     Method(HRESULT, "GetStreamSource", [(UINT, "StreamNumber"), Out(Pointer(PDIRECT3DVERTEXBUFFER9), "ppStreamData"), Out(Pointer(UINT), "pOffsetInBytes"), Out(Pointer(UINT), "pStride")]),
227     Method(HRESULT, "SetStreamSourceFreq", [(UINT, "StreamNumber"), (UINT, "Setting")]),
228     Method(HRESULT, "GetStreamSourceFreq", [(UINT, "StreamNumber"), Out(Pointer(UINT), "pSetting")]),
229     Method(HRESULT, "SetIndices", [(PDIRECT3DINDEXBUFFER9, "pIndexData")]),
230     Method(HRESULT, "GetIndices", [Out(Pointer(PDIRECT3DINDEXBUFFER9), "ppIndexData")]),
231     Method(HRESULT, "CreatePixelShader", [(D3DSHADER9, "pFunction"), Out(Pointer(PDIRECT3DPIXELSHADER9), "ppShader")]),
232     Method(HRESULT, "SetPixelShader", [(PDIRECT3DPIXELSHADER9, "pShader")]),
233     Method(HRESULT, "GetPixelShader", [Out(Pointer(PDIRECT3DPIXELSHADER9), "ppShader")]),
234     Method(HRESULT, "SetPixelShaderConstantF", [(UINT, "StartRegister"), (Const(Array(Float, "4*Vector4fCount")), "pConstantData"), (UINT, "Vector4fCount")]),
235     Method(HRESULT, "GetPixelShaderConstantF", [(UINT, "StartRegister"), Out(Array(Float, "4*Vector4fCount"), "pConstantData"), (UINT, "Vector4fCount")]),
236     Method(HRESULT, "SetPixelShaderConstantI", [(UINT, "StartRegister"), (Const(Array(Int, "4*Vector4iCount")), "pConstantData"), (UINT, "Vector4iCount")]),
237     Method(HRESULT, "GetPixelShaderConstantI", [(UINT, "StartRegister"), Out(Array(Int, "4*Vector4iCount"), "pConstantData"), (UINT, "Vector4iCount")]),
238     Method(HRESULT, "SetPixelShaderConstantB", [(UINT, "StartRegister"), (Const(Array(BOOL, "BoolCount")), "pConstantData"), (UINT, "BoolCount")]),
239     Method(HRESULT, "GetPixelShaderConstantB", [(UINT, "StartRegister"), Out(Array(BOOL, "BoolCount"), "pConstantData"), (UINT, "BoolCount")]),
240     Method(HRESULT, "DrawRectPatch", [(UINT, "Handle"), (ConstPointer(Float), "pNumSegs"), (ConstPointer(D3DRECTPATCH_INFO), "pRectPatchInfo")]),
241     Method(HRESULT, "DrawTriPatch", [(UINT, "Handle"), (ConstPointer(Float), "pNumSegs"), (ConstPointer(D3DTRIPATCH_INFO), "pTriPatchInfo")]),
242     Method(HRESULT, "DeletePatch", [(UINT, "Handle")]),
243     Method(HRESULT, "CreateQuery", [(D3DQUERYTYPE, "Type"), Out(Pointer(PDIRECT3DQUERY9), "ppQuery")]),
244 ]
245
246 IDirect3DStateBlock9.methods += [
247     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
248     Method(HRESULT, "Capture", []),
249     Method(HRESULT, "Apply", []),
250 ]
251
252 IDirect3DSwapChain9.methods += [
253     Method(HRESULT, "Present", [(ConstPointer(RECT), "pSourceRect"), (ConstPointer(RECT), "pDestRect"), (HWND, "hDestWindowOverride"), (ConstPointer(RGNDATA), "pDirtyRegion"), (D3DPRESENT, "dwFlags")]),
254     Method(HRESULT, "GetFrontBufferData", [(PDIRECT3DSURFACE9, "pDestSurface")]),
255     Method(HRESULT, "GetBackBuffer", [(UINT, "iBackBuffer"), (D3DBACKBUFFER_TYPE, "Type"), Out(Pointer(PDIRECT3DSURFACE9), "ppBackBuffer")]),
256     Method(HRESULT, "GetRasterStatus", [Out(Pointer(D3DRASTER_STATUS), "pRasterStatus")]),
257     Method(HRESULT, "GetDisplayMode", [Out(Pointer(D3DDISPLAYMODE), "pMode")]),
258     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
259     Method(HRESULT, "GetPresentParameters", [Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters")]),
260 ]
261
262 IDirect3DResource9.methods += [
263     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
264     Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaquePointer(Const(Void)), "pData"), (DWORD, "SizeOfData"), (DWORD, "Flags")]),
265     Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaquePointer(Void), "pData"), Out(Pointer(DWORD), "pSizeOfData")]),
266     Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]),
267     Method(DWORD, "SetPriority", [(DWORD, "PriorityNew")]),
268     Method(DWORD, "GetPriority", []),
269     Method(Void, "PreLoad", []),
270     Method(D3DRESOURCETYPE, "GetType", []),
271 ]
272
273 IDirect3DVertexDeclaration9.methods += [
274     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
275     Method(HRESULT, "GetDeclaration", [Out(Pointer(D3DVERTEXELEMENT9), "pElement"), Out(Pointer(UINT), "pNumElements")]),
276 ]
277
278 IDirect3DVertexShader9.methods += [
279     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
280     Method(HRESULT, "GetFunction", [Out(OpaquePointer(Void), "pData"), Out(Pointer(UINT), "pSizeOfData")]),
281 ]
282
283 IDirect3DPixelShader9.methods += [
284     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
285     Method(HRESULT, "GetFunction", [Out(OpaquePointer(Void), "pData"), Out(Pointer(UINT), "pSizeOfData")]),
286 ]
287
288 IDirect3DBaseTexture9.methods += [
289     Method(DWORD, "SetLOD", [(DWORD, "LODNew")]),
290     Method(DWORD, "GetLOD", []),
291     Method(DWORD, "GetLevelCount", []),
292     Method(HRESULT, "SetAutoGenFilterType", [(D3DTEXTUREFILTERTYPE, "FilterType")]),
293     Method(D3DTEXTUREFILTERTYPE, "GetAutoGenFilterType", []),
294     Method(Void, "GenerateMipSubLevels", []),
295 ]
296
297 IDirect3DTexture9.methods += [
298     Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), Out(Pointer(D3DSURFACE_DESC), "pDesc")]),
299     Method(HRESULT, "GetSurfaceLevel", [(UINT, "Level"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurfaceLevel")]),
300     Method(HRESULT, "LockRect", [(UINT, "Level"), Out(Pointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (D3DLOCK, "Flags")]),
301     Method(HRESULT, "UnlockRect", [(UINT, "Level")]),
302     Method(HRESULT, "AddDirtyRect", [(ConstPointer(RECT), "pDirtyRect")]),
303 ]
304
305 IDirect3DVolumeTexture9.methods += [
306     Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), Out(Pointer(D3DVOLUME_DESC), "pDesc")]),
307     Method(HRESULT, "GetVolumeLevel", [(UINT, "Level"), Out(Pointer(PDIRECT3DVOLUME9), "ppVolumeLevel")]),
308     Method(HRESULT, "LockBox", [(UINT, "Level"), Out(Pointer(D3DLOCKED_BOX), "pLockedVolume"), (ConstPointer(D3DBOX), "pBox"), (D3DLOCK, "Flags")]),
309     Method(HRESULT, "UnlockBox", [(UINT, "Level")]),
310     Method(HRESULT, "AddDirtyBox", [(ConstPointer(D3DBOX), "pDirtyBox")]),
311 ]
312
313 IDirect3DCubeTexture9.methods += [
314     Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), Out(Pointer(D3DSURFACE_DESC), "pDesc")]),
315     Method(HRESULT, "GetCubeMapSurface", [(D3DCUBEMAP_FACES, "FaceType"), (UINT, "Level"), Out(Pointer(PDIRECT3DSURFACE9), "ppCubeMapSurface")]),
316     Method(HRESULT, "LockRect", [(D3DCUBEMAP_FACES, "FaceType"), (UINT, "Level"), Out(Pointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (D3DLOCK, "Flags")]),
317     Method(HRESULT, "UnlockRect", [(D3DCUBEMAP_FACES, "FaceType"), (UINT, "Level")]),
318     Method(HRESULT, "AddDirtyRect", [(D3DCUBEMAP_FACES, "FaceType"), (ConstPointer(RECT), "pDirtyRect")]),
319 ]
320
321 IDirect3DVertexBuffer9.methods += [
322     Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(OpaquePointer(Void)), "ppbData"), (D3DLOCK, "Flags")]),
323     Method(HRESULT, "Unlock", []),
324     Method(HRESULT, "GetDesc", [Out(Pointer(D3DVERTEXBUFFER_DESC), "pDesc")]),
325 ]
326
327 IDirect3DIndexBuffer9.methods += [
328     Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(OpaquePointer(Void)), "ppbData"), (D3DLOCK, "Flags")]),
329     Method(HRESULT, "Unlock", []),
330     Method(HRESULT, "GetDesc", [Out(Pointer(D3DINDEXBUFFER_DESC), "pDesc")]),
331 ]
332
333 IDirect3DSurface9.methods += [
334     Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "ppContainer")]),
335     Method(HRESULT, "GetDesc", [Out(Pointer(D3DSURFACE_DESC), "pDesc")]),
336     Method(HRESULT, "LockRect", [Out(Pointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (D3DLOCK, "Flags")]),
337     Method(HRESULT, "UnlockRect", []),
338     Method(HRESULT, "GetDC", [Out(Pointer(HDC), "phdc")]),
339     Method(HRESULT, "ReleaseDC", [(HDC, "hdc")]),
340 ]
341
342 IDirect3DVolume9.methods += [
343     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
344     Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaquePointer(Const(Void)), "pData"), (DWORD, "SizeOfData"), (DWORD, "Flags")]),
345     Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaquePointer(Void), "pData"), Out(Pointer(DWORD), "pSizeOfData")]),
346     Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]),
347     Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "ppContainer")]),
348     Method(HRESULT, "GetDesc", [Out(Pointer(D3DVOLUME_DESC), "pDesc")]),
349     Method(HRESULT, "LockBox", [Out(Pointer(D3DLOCKED_BOX), "pLockedVolume"), (ConstPointer(D3DBOX), "pBox"), (D3DLOCK, "Flags")]),
350     Method(HRESULT, "UnlockBox", []),
351 ]
352
353 IDirect3DQuery9.methods += [
354     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
355     Method(D3DQUERYTYPE, "GetType", []),
356     Method(DWORD, "GetDataSize", []),
357     Method(HRESULT, "Issue", [(DWORD, "dwIssueFlags")]),
358     Method(HRESULT, "GetData", [Out(OpaquePointer(Void), "pData"), (DWORD, "dwSize"), (DWORD, "dwGetDataFlags")]),
359 ]
360
361 IDirect3D9Ex.methods += [
362     Method(UINT, "GetAdapterModeCountEx", [(UINT, "Adapter"), (ConstPointer(D3DDISPLAYMODEFILTER), "pFilter") ]),
363     Method(HRESULT, "EnumAdapterModesEx", [(UINT, "Adapter"), (ConstPointer(D3DDISPLAYMODEFILTER), "pFilter"), (UINT, "Mode"), Out(Pointer(D3DDISPLAYMODEEX), "pMode")]),
364     Method(HRESULT, "GetAdapterDisplayModeEx", [(UINT, "Adapter"), Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")]),
365     Method(HRESULT, "CreateDeviceEx", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (DWORD, "BehaviorFlags"), Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(D3DDISPLAYMODEEX), "pFullscreenDisplayMode"), Out(Pointer(PDIRECT3DDEVICE9EX), "ppReturnedDeviceInterface")]),
366     Method(HRESULT, "GetAdapterLUID", [(UINT, "Adapter"), Out(Pointer(LUID), "pLUID")]),
367 ]
368
369 IDirect3DDevice9Ex.methods += [
370     Method(HRESULT, "SetConvolutionMonoKernel", [(UINT, "width"), (UINT, "height"), (Array(Float, "width"), "rows"), (Array(Float, "height"), "columns")]),
371     Method(HRESULT, "ComposeRects", [(PDIRECT3DSURFACE9, "pSrc"), (PDIRECT3DSURFACE9, "pDst"), (PDIRECT3DVERTEXBUFFER9, "pSrcRectDescs"), (UINT, "NumRects"), (PDIRECT3DVERTEXBUFFER9, "pDstRectDescs"), (D3DCOMPOSERECTSOP, "Operation"), (Int, "Xoffset"), (Int, "Yoffset")]),
372     Method(HRESULT, "PresentEx", [(ConstPointer(RECT), "pSourceRect"), (ConstPointer(RECT), "pDestRect"), (HWND, "hDestWindowOverride"), (ConstPointer(RGNDATA), "pDirtyRegion"), (DWORD, "dwFlags")]),
373     Method(HRESULT, "GetGPUThreadPriority", [Out(Pointer(INT), "pPriority")]),
374     Method(HRESULT, "SetGPUThreadPriority", [(INT, "Priority")]),
375     Method(HRESULT, "WaitForVBlank", [(UINT, "iSwapChain")]),
376     Method(HRESULT, "CheckResourceResidency", [(Array(PDIRECT3DRESOURCE9, "NumResources"), "pResourceArray"), (UINT32, "NumResources")]),
377     Method(HRESULT, "SetMaximumFrameLatency", [(UINT, "MaxLatency")]),
378     Method(HRESULT, "GetMaximumFrameLatency", [Out(Pointer(UINT), "pMaxLatency")]),
379     Method(HRESULT, "CheckDeviceState", [(HWND, "hDestinationWindow")]),
380     Method(HRESULT, "CreateRenderTargetEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Lockable"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle"), (D3DUSAGE, "Usage")]),
381     Method(HRESULT, "CreateOffscreenPlainSurfaceEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle"), (D3DUSAGE, "Usage")]),
382     Method(HRESULT, "CreateDepthStencilSurfaceEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Discard"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle"), (D3DUSAGE, "Usage")]),
383     Method(HRESULT, "ResetEx", [Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(D3DDISPLAYMODEEX), "pFullscreenDisplayMode")]),
384     Method(HRESULT, "GetDisplayModeEx", [(UINT, "iSwapChain"), Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")]),
385 ]
386
387 IDirect3DSwapChain9Ex.methods += [
388     Method(HRESULT, "GetLastPresentCount", [Out(Pointer(UINT), "pLastPresentCount")]),
389     Method(HRESULT, "GetPresentStats", [Out(Pointer(D3DPRESENTSTATS), "pPresentationStatistics")]),
390     Method(HRESULT, "GetDisplayModeEx", [Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")]),
391 ]
392
393 d3d9 = API("d3d9")
394 d3d9.add_functions([
395     StdFunction(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")], fail='NULL'),
396     StdFunction(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), Out(Pointer(PDIRECT3D9EX), "ppD3D")], fail='D3DERR_NOTAVAILABLE'),
397     StdFunction(Int, "D3DPERF_BeginEvent", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail='-1'),
398     StdFunction(Int, "D3DPERF_EndEvent", [], fail='-1'),
399     StdFunction(Void, "D3DPERF_SetMarker", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail=''),
400     StdFunction(Void, "D3DPERF_SetRegion", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail=''),
401     StdFunction(BOOL, "D3DPERF_QueryRepeatFrame", [], fail='FALSE'),
402     StdFunction(Void, "D3DPERF_SetOptions", [(DWORD, "dwOptions")], fail=''),
403     StdFunction(DWORD, "D3DPERF_GetStatus", [], fail='0'),
404 ])
405
406
407 class D3D9Tracer(DllTracer):
408
409     pass
410
411
412
413 if __name__ == '__main__':
414     print '#include "d3d9imports.hpp"'
415     print
416     print '#include "trace_write.hpp"'
417     print '#include "os.hpp"'
418     print
419     tracer = D3D9Tracer('d3d9.dll')
420     tracer.trace_api(d3d9)
421