1 #############################################################################
3 # Copyright 2008 Tungsten Graphics, Inc.
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published
7 # by the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #############################################################################
23 from d3dshader import *
24 from d3d9types import *
25 from d3d9caps import *
27 D3DSHADER9 = D3DShader(9)
29 HRESULT = Enum("HRESULT", [
31 "D3DERR_WRONGTEXTUREFORMAT",
32 "D3DERR_UNSUPPORTEDCOLOROPERATION",
33 "D3DERR_UNSUPPORTEDCOLORARG",
34 "D3DERR_UNSUPPORTEDALPHAOPERATION",
35 "D3DERR_UNSUPPORTEDALPHAARG",
36 "D3DERR_TOOMANYOPERATIONS",
37 "D3DERR_CONFLICTINGTEXTUREFILTER",
38 "D3DERR_UNSUPPORTEDFACTORVALUE",
39 "D3DERR_CONFLICTINGRENDERSTATE",
40 "D3DERR_UNSUPPORTEDTEXTUREFILTER",
41 "D3DERR_CONFLICTINGTEXTUREPALETTE",
42 "D3DERR_DRIVERINTERNALERROR",
46 "D3DERR_DEVICENOTRESET",
47 "D3DERR_NOTAVAILABLE",
48 "D3DERR_OUTOFVIDEOMEMORY",
49 "D3DERR_INVALIDDEVICE",
51 "D3DERR_DRIVERINVALIDCALL",
52 "D3DERR_WASSTILLDRAWING",
54 "D3DERR_DEVICEREMOVED",
56 "S_RESIDENT_IN_SHARED_MEMORY",
57 "S_PRESENT_MODE_CHANGED",
62 IDirect3D9 = Interface("IDirect3D9", IUnknown)
63 IDirect3DDevice9 = Interface("IDirect3DDevice9", IUnknown)
64 IDirect3DStateBlock9 = Interface("IDirect3DStateBlock9", IUnknown)
65 IDirect3DSwapChain9 = Interface("IDirect3DSwapChain9", IUnknown)
66 IDirect3DResource9 = Interface("IDirect3DResource9", IUnknown)
67 IDirect3DVertexDeclaration9 = Interface("IDirect3DVertexDeclaration9", IUnknown)
68 IDirect3DVertexShader9 = Interface("IDirect3DVertexShader9", IUnknown)
69 IDirect3DPixelShader9 = Interface("IDirect3DPixelShader9", IUnknown)
70 IDirect3DBaseTexture9 = Interface("IDirect3DBaseTexture9", IDirect3DResource9)
71 IDirect3DTexture9 = Interface("IDirect3DTexture9", IDirect3DBaseTexture9)
72 IDirect3DVolumeTexture9 = Interface("IDirect3DVolumeTexture9", IDirect3DBaseTexture9)
73 IDirect3DCubeTexture9 = Interface("IDirect3DCubeTexture9", IDirect3DBaseTexture9)
74 IDirect3DVertexBuffer9 = Interface("IDirect3DVertexBuffer9", IDirect3DResource9)
75 IDirect3DIndexBuffer9 = Interface("IDirect3DIndexBuffer9", IDirect3DResource9)
76 IDirect3DSurface9 = Interface("IDirect3DSurface9", IDirect3DResource9)
77 IDirect3DVolume9 = Interface("IDirect3DVolume9", IUnknown)
78 IDirect3DQuery9 = Interface("IDirect3DQuery9", IUnknown)
79 IDirect3D9Ex = Interface("IDirect3D9Ex", IDirect3D9)
80 IDirect3DDevice9Ex = Interface("IDirect3DDevice9Ex", IDirect3DDevice9)
81 IDirect3DSwapChain9Ex = Interface("IDirect3DSwapChain9Ex", IDirect3DSwapChain9)
83 PDIRECT3D9 = WrapPointer(IDirect3D9)
84 PDIRECT3DDEVICE9 = WrapPointer(IDirect3DDevice9)
85 PDIRECT3DSTATEBLOCK9 = WrapPointer(IDirect3DStateBlock9)
86 PDIRECT3DSWAPCHAIN9 = WrapPointer(IDirect3DSwapChain9)
87 PDIRECT3DRESOURCE9 = WrapPointer(IDirect3DResource9)
88 PDIRECT3DVERTEXDECLARATION9 = WrapPointer(IDirect3DVertexDeclaration9)
89 PDIRECT3DVERTEXSHADER9 = WrapPointer(IDirect3DVertexShader9)
90 PDIRECT3DPIXELSHADER9 = WrapPointer(IDirect3DPixelShader9)
91 PDIRECT3DBASETEXTURE9 = WrapPointer(IDirect3DBaseTexture9)
92 PDIRECT3DTEXTURE9 = WrapPointer(IDirect3DTexture9)
93 PDIRECT3DVOLUMETEXTURE9 = WrapPointer(IDirect3DVolumeTexture9)
94 PDIRECT3DCUBETEXTURE9 = WrapPointer(IDirect3DCubeTexture9)
95 PDIRECT3DVERTEXBUFFER9 = WrapPointer(IDirect3DVertexBuffer9)
96 PDIRECT3DINDEXBUFFER9 = WrapPointer(IDirect3DIndexBuffer9)
97 PDIRECT3DSURFACE9 = WrapPointer(IDirect3DSurface9)
98 PDIRECT3DVOLUME9 = WrapPointer(IDirect3DVolume9)
99 PDIRECT3DQUERY9 = WrapPointer(IDirect3DQuery9)
100 PDIRECT3D9EX = WrapPointer(IDirect3D9Ex)
101 PDIRECT3DDEVICE9EX = WrapPointer(IDirect3DDevice9Ex)
102 PDIRECT3DSWAPCHAIN9EX = WrapPointer(IDirect3DSwapChain9Ex)
104 IDirect3D9.methods += [
105 Method(HRESULT, "RegisterSoftwareDevice", [(Pointer(Void), "pInitializeFunction")]),
106 Method(UINT, "GetAdapterCount", []),
107 Method(HRESULT, "GetAdapterIdentifier", [(UINT, "Adapter"), (DWORD, "Flags"), (OutPointer(D3DADAPTER_IDENTIFIER9), "pIdentifier")]),
108 Method(UINT, "GetAdapterModeCount", [(UINT, "Adapter"), (D3DFORMAT, "Format")]),
109 Method(HRESULT, "EnumAdapterModes", [(UINT, "Adapter"), (D3DFORMAT, "Format"), (UINT, "Mode"), (OutPointer(D3DDISPLAYMODE), "pMode")]),
110 Method(HRESULT, "GetAdapterDisplayMode", [(UINT, "Adapter"), (OutPointer(D3DDISPLAYMODE), "pMode")]),
111 Method(HRESULT, "CheckDeviceType", [(UINT, "Adapter"), (D3DDEVTYPE, "DevType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "BackBufferFormat"), (BOOL, "bWindowed")]),
112 Method(HRESULT, "CheckDeviceFormat", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (DWORD, "Usage"), (D3DRESOURCETYPE, "RType"), (D3DFORMAT, "CheckFormat")]),
113 Method(HRESULT, "CheckDeviceMultiSampleType", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SurfaceFormat"), (BOOL, "Windowed"), (D3DMULTISAMPLE_TYPE, "MultiSampleType"), (OutPointer(DWORD), "pQualityLevels")]),
114 Method(HRESULT, "CheckDepthStencilMatch", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "RenderTargetFormat"), (D3DFORMAT, "DepthStencilFormat")]),
115 Method(HRESULT, "CheckDeviceFormatConversion", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SourceFormat"), (D3DFORMAT, "TargetFormat")]),
116 Method(HRESULT, "GetDeviceCaps", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (OutPointer(D3DCAPS9), "pCaps")]),
117 Method(HMONITOR, "GetAdapterMonitor", [(UINT, "Adapter")]),
118 Method(HRESULT, "CreateDevice", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (DWORD, "BehaviorFlags"), (OutPointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), (OutPointer(PDIRECT3DDEVICE9), "ppReturnedDeviceInterface")]),
121 IDirect3DDevice9.methods += [
122 Method(HRESULT, "TestCooperativeLevel", []),
123 Method(UINT, "GetAvailableTextureMem", []),
124 Method(HRESULT, "EvictManagedResources", []),
125 Method(HRESULT, "GetDirect3D", [(OutPointer(PDIRECT3D9), "ppD3D9")]),
126 Method(HRESULT, "GetDeviceCaps", [(OutPointer(D3DCAPS9), "pCaps")]),
127 Method(HRESULT, "GetDisplayMode", [(UINT, "iSwapChain"), (OutPointer(D3DDISPLAYMODE), "pMode")]),
128 Method(HRESULT, "GetCreationParameters", [(OutPointer(D3DDEVICE_CREATION_PARAMETERS), "pParameters")]),
129 Method(HRESULT, "SetCursorProperties", [(UINT, "XHotSpot"), (UINT, "YHotSpot"), (PDIRECT3DSURFACE9, "pCursorBitmap")]),
130 Method(Void, "SetCursorPosition", [(Int, "X"), (Int, "Y"), (DWORD, "Flags")]),
131 Method(BOOL, "ShowCursor", [(BOOL, "bShow")]),
132 Method(HRESULT, "CreateAdditionalSwapChain", [(OutPointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), (OutPointer(PDIRECT3DSWAPCHAIN9), "pSwapChain")]),
133 Method(HRESULT, "GetSwapChain", [(UINT, "iSwapChain"), (OutPointer(PDIRECT3DSWAPCHAIN9), "pSwapChain")]),
134 Method(UINT, "GetNumberOfSwapChains", []),
135 Method(HRESULT, "Reset", [(OutPointer(D3DPRESENT_PARAMETERS), "pPresentationParameters")]),
136 Method(HRESULT, "Present", [(ConstPointer(RECT), "pSourceRect"), (ConstPointer(RECT), "pDestRect"), (HWND, "hDestWindowOverride"), (ConstPointer(RGNDATA), "pDirtyRegion")]),
137 Method(HRESULT, "GetBackBuffer", [(UINT, "iSwapChain"), (UINT, "iBackBuffer"), (D3DBACKBUFFER_TYPE, "Type"), (OutPointer(PDIRECT3DSURFACE9), "ppBackBuffer")]),
138 Method(HRESULT, "GetRasterStatus", [(UINT, "iSwapChain"), (OutPointer(D3DRASTER_STATUS), "pRasterStatus")]),
139 Method(HRESULT, "SetDialogBoxMode", [(BOOL, "bEnableDialogs")]),
140 Method(Void, "SetGammaRamp", [(UINT, "iSwapChain"), (DWORD, "Flags"), (ConstPointer(D3DGAMMARAMP), "pRamp")]),
141 Method(Void, "GetGammaRamp", [(UINT, "iSwapChain"), (OutPointer(D3DGAMMARAMP), "pRamp")]),
142 Method(HRESULT, "CreateTexture", [(UINT, "Width"), (UINT, "Height"), (UINT, "Levels"), (DWORD, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), (OutPointer(PDIRECT3DTEXTURE9), "ppTexture"), (OutPointer(HANDLE), "pSharedHandle")]),
143 Method(HRESULT, "CreateVolumeTexture", [(UINT, "Width"), (UINT, "Height"), (UINT, "Depth"), (UINT, "Levels"), (DWORD, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), (OutPointer(PDIRECT3DVOLUMETEXTURE9), "ppVolumeTexture"), (OutPointer(HANDLE), "pSharedHandle")]),
144 Method(HRESULT, "CreateCubeTexture", [(UINT, "EdgeLength"), (UINT, "Levels"), (DWORD, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), (OutPointer(PDIRECT3DCUBETEXTURE9), "ppCubeTexture"), (OutPointer(HANDLE), "pSharedHandle")]),
145 Method(HRESULT, "CreateVertexBuffer", [(UINT, "Length"), (DWORD, "Usage"), (DWORD, "FVF"), (D3DPOOL, "Pool"), (OutPointer(PDIRECT3DVERTEXBUFFER9), "ppVertexBuffer"), (OutPointer(HANDLE), "pSharedHandle")]),
146 Method(HRESULT, "CreateIndexBuffer", [(UINT, "Length"), (DWORD, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), (OutPointer(PDIRECT3DINDEXBUFFER9), "ppIndexBuffer"), (OutPointer(HANDLE), "pSharedHandle")]),
147 Method(HRESULT, "CreateRenderTarget", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Lockable"), (OutPointer(PDIRECT3DSURFACE9), "ppSurface"), (OutPointer(HANDLE), "pSharedHandle")]),
148 Method(HRESULT, "CreateDepthStencilSurface", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Discard"), (OutPointer(PDIRECT3DSURFACE9), "ppSurface"), (OutPointer(HANDLE), "pSharedHandle")]),
149 Method(HRESULT, "UpdateSurface", [(PDIRECT3DSURFACE9, "pSourceSurface"), (ConstPointer(RECT), "pSourceRect"), (PDIRECT3DSURFACE9, "pDestinationSurface"), (ConstPointer(POINT), "pDestPoint")]),
150 Method(HRESULT, "UpdateTexture", [(PDIRECT3DBASETEXTURE9, "pSourceTexture"), (PDIRECT3DBASETEXTURE9, "pDestinationTexture")]),
151 Method(HRESULT, "GetRenderTargetData", [(PDIRECT3DSURFACE9, "pRenderTarget"), (PDIRECT3DSURFACE9, "pDestSurface")]),
152 Method(HRESULT, "GetFrontBufferData", [(UINT, "iSwapChain"), (PDIRECT3DSURFACE9, "pDestSurface")]),
153 Method(HRESULT, "StretchRect", [(PDIRECT3DSURFACE9, "pSourceSurface"), (ConstPointer(RECT), "pSourceRect"), (PDIRECT3DSURFACE9, "pDestSurface"), (ConstPointer(RECT), "pDestRect"), (D3DTEXTUREFILTERTYPE, "Filter")]),
154 Method(HRESULT, "ColorFill", [(PDIRECT3DSURFACE9, "pSurface"), (ConstPointer(RECT), "pRect"), (D3DCOLOR, "color")]),
155 Method(HRESULT, "CreateOffscreenPlainSurface", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), (OutPointer(PDIRECT3DSURFACE9), "ppSurface"), (OutPointer(HANDLE), "pSharedHandle")]),
156 Method(HRESULT, "SetRenderTarget", [(DWORD, "RenderTargetIndex"), (PDIRECT3DSURFACE9, "pRenderTarget")]),
157 Method(HRESULT, "GetRenderTarget", [(DWORD, "RenderTargetIndex"), (OutPointer(PDIRECT3DSURFACE9), "ppRenderTarget")]),
158 Method(HRESULT, "SetDepthStencilSurface", [(PDIRECT3DSURFACE9, "pNewZStencil")]),
159 Method(HRESULT, "GetDepthStencilSurface", [(OutPointer(PDIRECT3DSURFACE9), "ppZStencilSurface")]),
160 Method(HRESULT, "BeginScene", []),
161 Method(HRESULT, "EndScene", []),
162 Method(HRESULT, "Clear", [(DWORD, "Count"), (ConstPointer(D3DRECT), "pRects"), (DWORD, "Flags"), (D3DCOLOR, "Color"), (Float, "Z"), (DWORD, "Stencil")]),
163 Method(HRESULT, "SetTransform", [(D3DTRANSFORMSTATETYPE, "State"), (ConstPointer(D3DMATRIX), "pMatrix")]),
164 Method(HRESULT, "GetTransform", [(D3DTRANSFORMSTATETYPE, "State"), (OutPointer(D3DMATRIX), "pMatrix")]),
165 Method(HRESULT, "MultiplyTransform", [(D3DTRANSFORMSTATETYPE, "State"), (ConstPointer(D3DMATRIX), "pMatrix")]),
166 Method(HRESULT, "SetViewport", [(ConstPointer(D3DVIEWPORT9), "pViewport")]),
167 Method(HRESULT, "GetViewport", [(OutPointer(D3DVIEWPORT9), "pViewport")]),
168 Method(HRESULT, "SetMaterial", [(ConstPointer(D3DMATERIAL9), "pMaterial")]),
169 Method(HRESULT, "GetMaterial", [(OutPointer(D3DMATERIAL9), "pMaterial")]),
170 Method(HRESULT, "SetLight", [(DWORD, "Index"), (ConstPointer(D3DLIGHT9), "pLight")]),
171 Method(HRESULT, "GetLight", [(DWORD, "Index"), (OutPointer(D3DLIGHT9), "pLight")]),
172 Method(HRESULT, "LightEnable", [(DWORD, "Index"), (BOOL, "Enable")]),
173 Method(HRESULT, "GetLightEnable", [(DWORD, "Index"), (OutPointer(BOOL), "pEnable")]),
174 Method(HRESULT, "SetClipPlane", [(DWORD, "Index"), (ConstPointer(Float), "pPlane")]),
175 Method(HRESULT, "GetClipPlane", [(DWORD, "Index"), (OutPointer(Float), "pPlane")]),
176 Method(HRESULT, "SetRenderState", [(D3DRENDERSTATETYPE, "State"), (DWORD, "Value")]),
177 Method(HRESULT, "GetRenderState", [(D3DRENDERSTATETYPE, "State"), (OutPointer(DWORD), "pValue")]),
178 Method(HRESULT, "CreateStateBlock", [(D3DSTATEBLOCKTYPE, "Type"), (OutPointer(PDIRECT3DSTATEBLOCK9), "ppSB")]),
179 Method(HRESULT, "BeginStateBlock", []),
180 Method(HRESULT, "EndStateBlock", [(OutPointer(PDIRECT3DSTATEBLOCK9), "ppSB")]),
181 Method(HRESULT, "SetClipStatus", [(ConstPointer(D3DCLIPSTATUS9), "pClipStatus")]),
182 Method(HRESULT, "GetClipStatus", [(OutPointer(D3DCLIPSTATUS9), "pClipStatus")]),
183 Method(HRESULT, "GetTexture", [(DWORD, "Stage"), (OutPointer(PDIRECT3DBASETEXTURE9), "ppTexture")]),
184 Method(HRESULT, "SetTexture", [(DWORD, "Stage"), (PDIRECT3DBASETEXTURE9, "pTexture")]),
185 Method(HRESULT, "GetTextureStageState", [(DWORD, "Stage"), (D3DTEXTURESTAGESTATETYPE, "Type"), (OutPointer(DWORD), "pValue")]),
186 Method(HRESULT, "SetTextureStageState", [(DWORD, "Stage"), (D3DTEXTURESTAGESTATETYPE, "Type"), (DWORD, "Value")]),
187 Method(HRESULT, "GetSamplerState", [(DWORD, "Sampler"), (D3DSAMPLERSTATETYPE, "Type"), (OutPointer(DWORD), "pValue")]),
188 Method(HRESULT, "SetSamplerState", [(DWORD, "Sampler"), (D3DSAMPLERSTATETYPE, "Type"), (DWORD, "Value")]),
189 Method(HRESULT, "ValidateDevice", [(OutPointer(DWORD), "pNumPasses")]),
190 Method(HRESULT, "SetPaletteEntries", [(UINT, "PaletteNumber"), (ConstPointer(PALETTEENTRY), "pEntries")]),
191 Method(HRESULT, "GetPaletteEntries", [(UINT, "PaletteNumber"), (OutPointer(PALETTEENTRY), "pEntries")]),
192 Method(HRESULT, "SetCurrentTexturePalette", [(UINT, "PaletteNumber")]),
193 Method(HRESULT, "GetCurrentTexturePalette", [(OutPointer(UINT), "PaletteNumber")]),
194 Method(HRESULT, "SetScissorRect", [(ConstPointer(RECT), "pRect")]),
195 Method(HRESULT, "GetScissorRect", [(OutPointer(RECT), "pRect")]),
196 Method(HRESULT, "SetSoftwareVertexProcessing", [(BOOL, "bSoftware")]),
197 Method(BOOL, "GetSoftwareVertexProcessing", []),
198 Method(HRESULT, "SetNPatchMode", [(Float, "nSegments")]),
199 Method(Float, "GetNPatchMode", []),
200 Method(HRESULT, "DrawPrimitive", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "StartVertex"), (UINT, "PrimitiveCount")]),
201 Method(HRESULT, "DrawIndexedPrimitive", [(D3DPRIMITIVETYPE, "PrimitiveType"), (INT, "BaseVertexIndex"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "startIndex"), (UINT, "primCount")]),
202 Method(HRESULT, "DrawPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "PrimitiveCount"), (ConstPointer(Void), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]),
203 Method(HRESULT, "DrawIndexedPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "PrimitiveCount"), (ConstPointer(Void), "pIndexData"), (D3DFORMAT, "IndexDataFormat"), (ConstPointer(Void), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]),
204 Method(HRESULT, "ProcessVertices", [(UINT, "SrcStartIndex"), (UINT, "DestIndex"), (UINT, "VertexCount"), (PDIRECT3DVERTEXBUFFER9, "pDestBuffer"), (PDIRECT3DVERTEXDECLARATION9, "pVertexDecl"), (DWORD, "Flags")]),
205 Method(HRESULT, "CreateVertexDeclaration", [(ConstPointer(D3DVERTEXELEMENT9), "pVertexElements"), (OutPointer(PDIRECT3DVERTEXDECLARATION9), "ppDecl")]),
206 Method(HRESULT, "SetVertexDeclaration", [(PDIRECT3DVERTEXDECLARATION9, "pDecl")]),
207 Method(HRESULT, "GetVertexDeclaration", [(OutPointer(PDIRECT3DVERTEXDECLARATION9), "ppDecl")]),
208 Method(HRESULT, "SetFVF", [(DWORD, "FVF")]),
209 Method(HRESULT, "GetFVF", [(OutPointer(DWORD), "pFVF")]),
210 Method(HRESULT, "CreateVertexShader", [(D3DSHADER9, "pFunction"), (OutPointer(PDIRECT3DVERTEXSHADER9), "ppShader")]),
211 Method(HRESULT, "SetVertexShader", [(PDIRECT3DVERTEXSHADER9, "pShader")]),
212 Method(HRESULT, "GetVertexShader", [(OutPointer(PDIRECT3DVERTEXSHADER9), "ppShader")]),
213 Method(HRESULT, "SetVertexShaderConstantF", [(UINT, "StartRegister"), (ConstPointer(Float), "pConstantData"), (UINT, "Vector4fCount")]),
214 Method(HRESULT, "GetVertexShaderConstantF", [(UINT, "StartRegister"), (OutPointer(Float), "pConstantData"), (UINT, "Vector4fCount")]),
215 Method(HRESULT, "SetVertexShaderConstantI", [(UINT, "StartRegister"), (ConstPointer(Int), "pConstantData"), (UINT, "Vector4iCount")]),
216 Method(HRESULT, "GetVertexShaderConstantI", [(UINT, "StartRegister"), (OutPointer(Int), "pConstantData"), (UINT, "Vector4iCount")]),
217 Method(HRESULT, "SetVertexShaderConstantB", [(UINT, "StartRegister"), (ConstPointer(BOOL), "pConstantData"), (UINT, "BoolCount")]),
218 Method(HRESULT, "GetVertexShaderConstantB", [(UINT, "StartRegister"), (OutPointer(BOOL), "pConstantData"), (UINT, "BoolCount")]),
219 Method(HRESULT, "SetStreamSource", [(UINT, "StreamNumber"), (PDIRECT3DVERTEXBUFFER9, "pStreamData"), (UINT, "OffsetInBytes"), (UINT, "Stride")]),
220 Method(HRESULT, "GetStreamSource", [(UINT, "StreamNumber"), (OutPointer(PDIRECT3DVERTEXBUFFER9), "ppStreamData"), (OutPointer(UINT), "pOffsetInBytes"), (OutPointer(UINT), "pStride")]),
221 Method(HRESULT, "SetStreamSourceFreq", [(UINT, "StreamNumber"), (UINT, "Setting")]),
222 Method(HRESULT, "GetStreamSourceFreq", [(UINT, "StreamNumber"), (OutPointer(UINT), "pSetting")]),
223 Method(HRESULT, "SetIndices", [(PDIRECT3DINDEXBUFFER9, "pIndexData")]),
224 Method(HRESULT, "GetIndices", [(OutPointer(PDIRECT3DINDEXBUFFER9), "ppIndexData")]),
225 Method(HRESULT, "CreatePixelShader", [(D3DSHADER9, "pFunction"), (OutPointer(PDIRECT3DPIXELSHADER9), "ppShader")]),
226 Method(HRESULT, "SetPixelShader", [(PDIRECT3DPIXELSHADER9, "pShader")]),
227 Method(HRESULT, "GetPixelShader", [(OutPointer(PDIRECT3DPIXELSHADER9), "ppShader")]),
228 Method(HRESULT, "SetPixelShaderConstantF", [(UINT, "StartRegister"), (ConstPointer(Float), "pConstantData"), (UINT, "Vector4fCount")]),
229 Method(HRESULT, "GetPixelShaderConstantF", [(UINT, "StartRegister"), (OutPointer(Float), "pConstantData"), (UINT, "Vector4fCount")]),
230 Method(HRESULT, "SetPixelShaderConstantI", [(UINT, "StartRegister"), (ConstPointer(Int), "pConstantData"), (UINT, "Vector4iCount")]),
231 Method(HRESULT, "GetPixelShaderConstantI", [(UINT, "StartRegister"), (OutPointer(Int), "pConstantData"), (UINT, "Vector4iCount")]),
232 Method(HRESULT, "SetPixelShaderConstantB", [(UINT, "StartRegister"), (ConstPointer(BOOL), "pConstantData"), (UINT, "BoolCount")]),
233 Method(HRESULT, "GetPixelShaderConstantB", [(UINT, "StartRegister"), (OutPointer(BOOL), "pConstantData"), (UINT, "BoolCount")]),
234 Method(HRESULT, "DrawRectPatch", [(UINT, "Handle"), (ConstPointer(Float), "pNumSegs"), (ConstPointer(D3DRECTPATCH_INFO), "pRectPatchInfo")]),
235 Method(HRESULT, "DrawTriPatch", [(UINT, "Handle"), (ConstPointer(Float), "pNumSegs"), (ConstPointer(D3DTRIPATCH_INFO), "pTriPatchInfo")]),
236 Method(HRESULT, "DeletePatch", [(UINT, "Handle")]),
237 Method(HRESULT, "CreateQuery", [(D3DQUERYTYPE, "Type"), (OutPointer(PDIRECT3DQUERY9), "ppQuery")]),
240 IDirect3DStateBlock9.methods += [
241 Method(HRESULT, "GetDevice", [(OutPointer(PDIRECT3DDEVICE9), "ppDevice")]),
242 Method(HRESULT, "Capture", []),
243 Method(HRESULT, "Apply", []),
246 IDirect3DSwapChain9.methods += [
247 Method(HRESULT, "Present", [(ConstPointer(RECT), "pSourceRect"), (ConstPointer(RECT), "pDestRect"), (HWND, "hDestWindowOverride"), (ConstPointer(RGNDATA), "pDirtyRegion"), (DWORD, "dwFlags")]),
248 Method(HRESULT, "GetFrontBufferData", [(PDIRECT3DSURFACE9, "pDestSurface")]),
249 Method(HRESULT, "GetBackBuffer", [(UINT, "iBackBuffer"), (D3DBACKBUFFER_TYPE, "Type"), (OutPointer(PDIRECT3DSURFACE9), "ppBackBuffer")]),
250 Method(HRESULT, "GetRasterStatus", [(OutPointer(D3DRASTER_STATUS), "pRasterStatus")]),
251 Method(HRESULT, "GetDisplayMode", [(OutPointer(D3DDISPLAYMODE), "pMode")]),
252 Method(HRESULT, "GetDevice", [(OutPointer(PDIRECT3DDEVICE9), "ppDevice")]),
253 Method(HRESULT, "GetPresentParameters", [(OutPointer(D3DPRESENT_PARAMETERS), "pPresentationParameters")]),
256 IDirect3DResource9.methods += [
257 Method(HRESULT, "GetDevice", [(OutPointer(PDIRECT3DDEVICE9), "ppDevice")]),
258 Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (ConstPointer(Void), "pData"), (DWORD, "SizeOfData"), (DWORD, "Flags")]),
259 Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), (OutPointer(Void), "pData"), (OutPointer(DWORD), "pSizeOfData")]),
260 Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]),
261 Method(DWORD, "SetPriority", [(DWORD, "PriorityNew")]),
262 Method(DWORD, "GetPriority", []),
263 Method(Void, "PreLoad", []),
264 Method(D3DRESOURCETYPE, "GetType", []),
267 IDirect3DVertexDeclaration9.methods += [
268 Method(HRESULT, "GetDevice", [(OutPointer(PDIRECT3DDEVICE9), "ppDevice")]),
269 Method(HRESULT, "GetDeclaration", [(OutPointer(D3DVERTEXELEMENT9), "pElement"), (OutPointer(UINT), "pNumElements")]),
272 IDirect3DVertexShader9.methods += [
273 Method(HRESULT, "GetDevice", [(OutPointer(PDIRECT3DDEVICE9), "ppDevice")]),
274 Method(HRESULT, "GetFunction", [(OutPointer(Void), "pData"), (OutPointer(UINT), "pSizeOfData")]),
277 IDirect3DPixelShader9.methods += [
278 Method(HRESULT, "GetDevice", [(OutPointer(PDIRECT3DDEVICE9), "ppDevice")]),
279 Method(HRESULT, "GetFunction", [(OutPointer(Void), "pData"), (OutPointer(UINT), "pSizeOfData")]),
282 IDirect3DBaseTexture9.methods += [
283 Method(DWORD, "SetLOD", [(DWORD, "LODNew")]),
284 Method(DWORD, "GetLOD", []),
285 Method(DWORD, "GetLevelCount", []),
286 Method(HRESULT, "SetAutoGenFilterType", [(D3DTEXTUREFILTERTYPE, "FilterType")]),
287 Method(D3DTEXTUREFILTERTYPE, "GetAutoGenFilterType", []),
288 Method(Void, "GenerateMipSubLevels", []),
291 IDirect3DTexture9.methods += [
292 Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), (OutPointer(D3DSURFACE_DESC), "pDesc")]),
293 Method(HRESULT, "GetSurfaceLevel", [(UINT, "Level"), (OutPointer(PDIRECT3DSURFACE9), "ppSurfaceLevel")]),
294 Method(HRESULT, "LockRect", [(UINT, "Level"), (OutPointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (DWORD, "Flags")]),
295 Method(HRESULT, "UnlockRect", [(UINT, "Level")]),
296 Method(HRESULT, "AddDirtyRect", [(ConstPointer(RECT), "pDirtyRect")]),
299 IDirect3DVolumeTexture9.methods += [
300 Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), (OutPointer(D3DVOLUME_DESC), "pDesc")]),
301 Method(HRESULT, "GetVolumeLevel", [(UINT, "Level"), (OutPointer(PDIRECT3DVOLUME9), "ppVolumeLevel")]),
302 Method(HRESULT, "LockBox", [(UINT, "Level"), (OutPointer(D3DLOCKED_BOX), "pLockedVolume"), (ConstPointer(D3DBOX), "pBox"), (DWORD, "Flags")]),
303 Method(HRESULT, "UnlockBox", [(UINT, "Level")]),
304 Method(HRESULT, "AddDirtyBox", [(ConstPointer(D3DBOX), "pDirtyBox")]),
307 IDirect3DCubeTexture9.methods += [
308 Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), (OutPointer(D3DSURFACE_DESC), "pDesc")]),
309 Method(HRESULT, "GetCubeMapSurface", [(D3DCUBEMAP_FACES, "FaceType"), (UINT, "Level"), (OutPointer(PDIRECT3DSURFACE9), "ppCubeMapSurface")]),
310 Method(HRESULT, "LockRect", [(D3DCUBEMAP_FACES, "FaceType"), (UINT, "Level"), (OutPointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (DWORD, "Flags")]),
311 Method(HRESULT, "UnlockRect", [(D3DCUBEMAP_FACES, "FaceType"), (UINT, "Level")]),
312 Method(HRESULT, "AddDirtyRect", [(D3DCUBEMAP_FACES, "FaceType"), (ConstPointer(RECT), "pDirtyRect")]),
315 IDirect3DVertexBuffer9.methods += [
316 Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), (OutPointer(Pointer(Void)), "ppbData"), (DWORD, "Flags")]),
317 Method(HRESULT, "Unlock", []),
318 Method(HRESULT, "GetDesc", [(OutPointer(D3DVERTEXBUFFER_DESC), "pDesc")]),
321 IDirect3DIndexBuffer9.methods += [
322 Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), (OutPointer(Pointer(Void)), "ppbData"), (DWORD, "Flags")]),
323 Method(HRESULT, "Unlock", []),
324 Method(HRESULT, "GetDesc", [(OutPointer(D3DINDEXBUFFER_DESC), "pDesc")]),
327 IDirect3DSurface9.methods += [
328 Method(HRESULT, "GetContainer", [(REFIID, "riid"), (OutPointer(Pointer(Void)), "ppContainer")]),
329 Method(HRESULT, "GetDesc", [(OutPointer(D3DSURFACE_DESC), "pDesc")]),
330 Method(HRESULT, "LockRect", [(OutPointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (DWORD, "Flags")]),
331 Method(HRESULT, "UnlockRect", []),
332 Method(HRESULT, "GetDC", [(OutPointer(HDC), "phdc")]),
333 Method(HRESULT, "ReleaseDC", [(HDC, "hdc")]),
336 IDirect3DVolume9.methods += [
337 Method(HRESULT, "GetDevice", [(OutPointer(PDIRECT3DDEVICE9), "ppDevice")]),
338 Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (ConstPointer(Void), "pData"), (DWORD, "SizeOfData"), (DWORD, "Flags")]),
339 Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), (OutPointer(Void), "pData"), (OutPointer(DWORD), "pSizeOfData")]),
340 Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]),
341 Method(HRESULT, "GetContainer", [(REFIID, "riid"), (OutPointer(Pointer(Void)), "ppContainer")]),
342 Method(HRESULT, "GetDesc", [(OutPointer(D3DVOLUME_DESC), "pDesc")]),
343 Method(HRESULT, "LockBox", [(OutPointer(D3DLOCKED_BOX), "pLockedVolume"), (ConstPointer(D3DBOX), "pBox"), (DWORD, "Flags")]),
344 Method(HRESULT, "UnlockBox", []),
347 IDirect3DQuery9.methods += [
348 Method(HRESULT, "GetDevice", [(OutPointer(PDIRECT3DDEVICE9), "ppDevice")]),
349 Method(D3DQUERYTYPE, "GetType", []),
350 Method(DWORD, "GetDataSize", []),
351 Method(HRESULT, "Issue", [(DWORD, "dwIssueFlags")]),
352 Method(HRESULT, "GetData", [(OutPointer(Void), "pData"), (DWORD, "dwSize"), (DWORD, "dwGetDataFlags")]),
355 IDirect3D9Ex.methods += [
356 Method(UINT, "GetAdapterModeCountEx", [(UINT, "Adapter"), (ConstPointer(D3DDISPLAYMODEFILTER), "pFilter") ]),
357 Method(HRESULT, "EnumAdapterModesEx", [(UINT, "Adapter"), (ConstPointer(D3DDISPLAYMODEFILTER), "pFilter"), (UINT, "Mode"), (OutPointer(D3DDISPLAYMODEEX), "pMode")]),
358 Method(HRESULT, "GetAdapterDisplayModeEx", [(UINT, "Adapter"), (OutPointer(D3DDISPLAYMODEEX), "pMode"), (OutPointer(D3DDISPLAYROTATION), "pRotation")]),
359 Method(HRESULT, "CreateDeviceEx", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (DWORD, "BehaviorFlags"), (OutPointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), (OutPointer(D3DDISPLAYMODEEX), "pFullscreenDisplayMode"), (OutPointer(PDIRECT3DDEVICE9EX), "ppReturnedDeviceInterface")]),
360 Method(HRESULT, "GetAdapterLUID", [(UINT, "Adapter"), (OutPointer(LUID), "pLUID")]),
363 IDirect3DDevice9Ex.methods += [
364 Method(HRESULT, "SetConvolutionMonoKernel", [(UINT, "width"), (UINT, "height"), (OutPointer(Float), "rows"), (OutPointer(Float), "columns")]),
365 Method(HRESULT, "ComposeRects", [(PDIRECT3DSURFACE9, "pSrc"), (PDIRECT3DSURFACE9, "pDst"), (PDIRECT3DVERTEXBUFFER9, "pSrcRectDescs"), (UINT, "NumRects"), (PDIRECT3DVERTEXBUFFER9, "pDstRectDescs"), (D3DCOMPOSERECTSOP, "Operation"), (Int, "Xoffset"), (Int, "Yoffset")]),
366 Method(HRESULT, "PresentEx", [(ConstPointer(RECT), "pSourceRect"), (ConstPointer(RECT), "pDestRect"), (HWND, "hDestWindowOverride"), (ConstPointer(RGNDATA), "pDirtyRegion"), (DWORD, "dwFlags")]),
367 Method(HRESULT, "GetGPUThreadPriority", [(OutPointer(INT), "pPriority")]),
368 Method(HRESULT, "SetGPUThreadPriority", [(INT, "Priority")]),
369 Method(HRESULT, "WaitForVBlank", [(UINT, "iSwapChain")]),
370 Method(HRESULT, "CheckResourceResidency", [(OutPointer(PDIRECT3DRESOURCE9), "pResourceArray"), (UINT32, "NumResources")]),
371 Method(HRESULT, "SetMaximumFrameLatency", [(UINT, "MaxLatency")]),
372 Method(HRESULT, "GetMaximumFrameLatency", [(OutPointer(UINT), "pMaxLatency")]),
373 Method(HRESULT, "CheckDeviceState", [(HWND, "hDestinationWindow")]),
374 Method(HRESULT, "CreateRenderTargetEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Lockable"), (OutPointer(PDIRECT3DSURFACE9), "ppSurface"), (OutPointer(HANDLE), "pSharedHandle"), (DWORD, "Usage")]),
375 Method(HRESULT, "CreateOffscreenPlainSurfaceEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), (OutPointer(PDIRECT3DSURFACE9), "ppSurface"), (OutPointer(HANDLE), "pSharedHandle"), (DWORD, "Usage")]),
376 Method(HRESULT, "CreateDepthStencilSurfaceEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Discard"), (OutPointer(PDIRECT3DSURFACE9), "ppSurface"), (OutPointer(HANDLE), "pSharedHandle"), (DWORD, "Usage")]),
377 Method(HRESULT, "ResetEx", [(OutPointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), (OutPointer(D3DDISPLAYMODEEX), "pFullscreenDisplayMode")]),
378 Method(HRESULT, "GetDisplayModeEx", [(UINT, "iSwapChain"), (OutPointer(D3DDISPLAYMODEEX), "pMode"), (OutPointer(D3DDISPLAYROTATION), "pRotation")]),
381 IDirect3DSwapChain9Ex.methods += [
382 Method(HRESULT, "GetLastPresentCount", [(OutPointer(UINT), "pLastPresentCount")]),
383 Method(HRESULT, "GetPresentStats", [(OutPointer(D3DPRESENTSTATS), "pPresentationStatistics")]),
384 Method(HRESULT, "GetDisplayModeEx", [(OutPointer(D3DDISPLAYMODEEX), "pMode"), (OutPointer(D3DDISPLAYROTATION), "pRotation")]),
389 DllFunction(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")], fail='NULL'),
390 DllFunction(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), (OutPointer(PDIRECT3D9EX), "ppD3D")], fail='D3DERR_NOTAVAILABLE'),
391 DllFunction(Int, "D3DPERF_BeginEvent", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail='-1'),
392 DllFunction(Int, "D3DPERF_EndEvent", [], fail='-1'),
393 DllFunction(Void, "D3DPERF_SetMarker", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail=''),
394 DllFunction(Void, "D3DPERF_SetRegion", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail=''),
395 DllFunction(BOOL, "D3DPERF_QueryRepeatFrame", [], fail='FALSE'),
396 DllFunction(Void, "D3DPERF_SetOptions", [(DWORD, "dwOptions")], fail=''),
397 DllFunction(DWORD, "D3DPERF_GetStatus", [], fail='0'),
400 if __name__ == '__main__':
401 print '#include <windows.h>'
402 print '#include <tchar.h>'
403 print '#include <d3d9.h>'
405 print '#include "log.hpp"'