1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS ReactX 4 * FILE: dll/directx/d3d9/d3d9_device.h 5 * PURPOSE: d3d9.dll internal device structures 6 * PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se> 7 */ 8 #ifndef _D3D9_DEVICE_H_ 9 #define _D3D9_DEVICE_H_ 10 11 #include "d3d9_common.h" 12 #include <d3d9.h> 13 #include <d3d9types.h> 14 #include "d3d9_private.h" 15 #include "d3d9_swapchain.h" 16 #include "d3d9_surface.h" 17 18 #if !defined(__cplusplus) || defined(CINTERFACE) 19 typedef struct _IDirect3DDevice9Vtbl_INT 20 { 21 struct IDirect3DDevice9Vtbl PublicInterface; 22 23 HRESULT (WINAPI *SetRenderStateWorker)(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD Value); // Value = D3DDEGREETYPE Degree ); 24 HRESULT (WINAPI *SetTextureStageStateI)(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value); 25 HRESULT (WINAPI *SetSamplerStateI)(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value); 26 HRESULT (WINAPI *SetMaterial)(LPDIRECT3DDEVICE9 iface, CONST D3DMATERIAL9* pMaterial); 27 HRESULT (WINAPI *SetVertexShader)(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9* pShader); 28 HRESULT (WINAPI *SetVertexShaderConstantF)(LPDIRECT3DDEVICE9 iface, UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount); 29 HRESULT (WINAPI *SetVertexShaderConstantI)(LPDIRECT3DDEVICE9 iface, UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount); 30 HRESULT (WINAPI *SetVertexShaderConstantB)(LPDIRECT3DDEVICE9 iface, UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount); 31 HRESULT (WINAPI *SetPixelShader)(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader); 32 HRESULT (WINAPI *SetPixelShaderConstantF)(LPDIRECT3DDEVICE9 iface, UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount); 33 HRESULT (WINAPI *SetPixelShaderConstantI)(LPDIRECT3DDEVICE9 iface, UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount); 34 HRESULT (WINAPI *SetPixelShaderConstantB)(LPDIRECT3DDEVICE9 iface, UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount); 35 HRESULT (WINAPI *SetFVF)(LPDIRECT3DDEVICE9 iface, DWORD FVF); 36 HRESULT (WINAPI *SetTexture)(LPDIRECT3DDEVICE9 iface, DWORD Stage,IDirect3DBaseTexture9* pTexture); 37 HRESULT (WINAPI *SetIndices)(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9* pIndexData); 38 HRESULT (WINAPI *SetStreamSource)(LPDIRECT3DDEVICE9 iface, UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride); 39 HRESULT (WINAPI *SetStreamSourceFreq)(LPDIRECT3DDEVICE9 iface, UINT StreamNumber,UINT Setting); 40 VOID (WINAPI *UpdateRenderState)(LPDIRECT3DDEVICE9 iface, DWORD Unknown1, DWORD Unknown2); 41 HRESULT (WINAPI *SetTransform)(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix); 42 HRESULT (WINAPI *MultiplyTransform)(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*); 43 HRESULT (WINAPI *SetClipPlane)(LPDIRECT3DDEVICE9 iface, DWORD Index,CONST float* pPlane); 44 VOID (WINAPI *UpdateDriverState)(LPDIRECT3DDEVICE9 iface); 45 HRESULT (WINAPI *SetViewport)(LPDIRECT3DDEVICE9 iface, CONST D3DVIEWPORT9* pViewport); 46 VOID (WINAPI *SetStreamSourceInt)(LPDIRECT3DDEVICE9 iface, LPVOID UnknownStreamData); 47 HRESULT (WINAPI *SetPixelShaderConstantFWorker)(LPDIRECT3DDEVICE9 iface, UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount); 48 HRESULT (WINAPI *SetPixelShaderConstantIWorker)(LPDIRECT3DDEVICE9 iface, UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount); 49 HRESULT (WINAPI *SetPixelShaderConstantBWorker)(LPDIRECT3DDEVICE9 iface, UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount); 50 VOID (WINAPI *DrawPrimitiveWorker)(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount); 51 HRESULT (WINAPI *SetLight)(LPDIRECT3DDEVICE9 iface, DWORD Index,CONST D3DLIGHT9*); 52 HRESULT (WINAPI *LightEnable)(LPDIRECT3DDEVICE9 iface, DWORD Index,BOOL Enable); 53 HRESULT (WINAPI *SetRenderStateInt)(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD Value ); // Value = D3DDEGREETYPE Degree ); 54 HRESULT (WINAPI *DrawPrimitiveUPInt)(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount); 55 HRESULT (WINAPI *Clear)(LPDIRECT3DDEVICE9 iface, DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil); 56 VOID (WINAPI *DrawPrimitivesWorker)(LPDIRECT3DDEVICE9 iface); 57 VOID (WINAPI *UpdateVertexShader)(LPDIRECT3DDEVICE9 iface); 58 HRESULT (WINAPI *ValidateDrawCall)(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT Unknown1, UINT Unknown2, UINT Unknown3, INT Unknown4, UINT Unknown5, INT Unknown6); 59 HRESULT (WINAPI *Init)(LPDIRECT3DDEVICE9 iface); 60 VOID (WINAPI *InitState)(LPDIRECT3DDEVICE9 iface, INT State); 61 VOID (WINAPI *Destroy)(LPDIRECT3DDEVICE9 iface); 62 VOID (WINAPI *VirtualDestructor)(LPDIRECT3DDEVICE9 iface); 63 } IDirect3DDevice9Vtbl_INT; 64 #endif 65 66 typedef struct _D3D9HeapTexture 67 { 68 /* 0x0000 */ DWORD dwUnknown00; 69 /* 0x0004 */ DWORD dwUnknown04; // 0x400 70 /* 0x0008 */ LPDWORD pUnknown08; // malloc(dwUnknown04 * 2) 71 } D3D9HeapTexture; 72 73 typedef struct _D3D9ResourceManager 74 { 75 #ifdef D3D_DEBUG_INFO 76 /* N/A - 0x0000 */ DDSURFACEDESC SurfaceDesc[8]; 77 #endif 78 /* 0x0000 - 0x0160 */ struct _Direct3DDevice9_INT* pBaseDevice; 79 /* 0x0004 - 0x0164 */ DWORD dwUnknown0004; 80 /* 0x0008 - 0x0168 */ DWORD dwUnknown0008; 81 /* 0x000c - 0x016c */ DWORD MaxSimultaneousTextures; 82 /* 0x0010 - 0x0170 */ DWORD dwUnknown0010; 83 /* 0x0014 - 0x0174 */ D3D9HeapTexture* pTextureHeap; 84 } D3D9ResourceManager; 85 86 typedef struct _Direct3DDevice9_INT 87 { 88 /* 0x0000 */ struct _IDirect3DDevice9Vtbl_INT* lpVtbl; 89 /* 0x0004 */ CRITICAL_SECTION CriticalSection; 90 #ifdef D3D_DEBUG_INFO 91 /* N/A - 0x001c */ DWORD dbg0004; 92 /* N/A - 0x0020 */ DWORD dbg0008; 93 /* N/A - 0x0024 */ DWORD dbg000c; 94 /* N/A - 0x0028 */ DWORD dbg0010; 95 /* N/A - 0x002c */ DWORD dbg0014; 96 /* N/A - 0x0030 */ DWORD dbg0018; 97 /* N/A - 0x0034 */ DWORD dbg001c; 98 /* N/A - 0x0038 */ DWORD dbg0020; 99 /* N/A - 0x003c */ DWORD dbg0024; 100 /* N/A - 0x0040 */ DWORD dbg0028; 101 /* N/A - 0x0044 */ DWORD dbg002c; 102 /* N/A - 0x0048 */ DWORD dbg0030; 103 /* N/A - 0x004c */ DWORD dbg0034; 104 /* N/A - 0x0050 */ DWORD dbg0038; 105 #endif 106 /* 0x001c - 0x0054 */ BOOL bLockDevice; 107 /* 0x0020 - 0x0058 */ DWORD dwProcessId; 108 /* 0x0024 - 0x005c */ IUnknown* pUnknown; 109 /* 0x0028 - 0x0060 */ DWORD dwDXVersion; 110 /* 0x002c - 0x0064 */ DWORD unknown000011; 111 /* 0x0030 - 0x0068 */ LONG lRefCnt; 112 /* 0x0034 - 0x006c */ DWORD unknown000013; 113 /* 0x0038 - 0x0070 */ D3D9ResourceManager* pResourceManager; 114 /* 0x003c - 0x0074 */ HWND hWnd; 115 /* 0x0040 - 0x0078 */ DWORD AdjustedBehaviourFlags; 116 /* 0x0044 - 0x007c */ DWORD BehaviourFlags; 117 /* 0x0048 - 0x0080 */ D3D9BaseSurface* pUnknown0010; 118 /* 0x004c - 0x0084 */ DWORD NumAdaptersInDevice; 119 /* 0x0050 - 0x0088 */ D3DDISPLAYMODE CurrentDisplayMode[D3D9_INT_MAX_NUM_ADAPTERS]; 120 /* 0x0110 - 0x0148 */ DWORD AdapterIndexInGroup[D3D9_INT_MAX_NUM_ADAPTERS]; 121 /* 0x0140 - 0x0178 */ D3D9_DEVICEDATA DeviceData[D3D9_INT_MAX_NUM_ADAPTERS]; 122 /* 0x1df0 - 0x1e28 */ LPDIRECT3DSWAPCHAIN9_INT pSwapChains[D3D9_INT_MAX_NUM_ADAPTERS]; 123 /* 0x1e20 - 0x1e58 */ LPDIRECT3DSWAPCHAIN9_INT pSwapChains2[D3D9_INT_MAX_NUM_ADAPTERS]; 124 /* 0x1e50 */ D3D9BaseSurface* pRenderTargetList; 125 /* 0x1e54 */ DWORD unknown001941; 126 /* 0x1e58 */ DWORD unknown001942; 127 /* 0x1e5c */ DWORD unknown001943; 128 /* 0x1e60 */ D3D9BaseSurface* pUnknown001944; 129 /* 0x1e64 */ D3DDEVTYPE DeviceType; 130 /* 0x1e68 */ LPDIRECT3D9_INT pDirect3D9; 131 /* 0x1e6c */ D3D9DriverSurface* pDriverSurfaceList; 132 /* 0x1e70 */ DWORD unknown001948; 133 /* 0x1e74 */ HANDLE hDX10UMDriver; 134 /* 0x1e78 */ HANDLE hDX10UMDriverInst; 135 /* 0x1e7c */ DWORD unknown001951; 136 /* 0x1e80 */ DWORD unknown001952; 137 /* 0x1e84 */ DWORD unknown001953; 138 /* 0x1e88 */ DWORD unknown001954; 139 /* 0x1e8c */ DWORD unknown001955; 140 /* 0x1e90 */ DWORD unknown001956; 141 /* 0x1e94 */ DWORD unknown001957; 142 /* 0x1e98 */ DWORD unknown001958; 143 /* 0x1e9c */ DWORD unknown001959; 144 /* 0x1ea0 */ DWORD unknown001960; 145 /* 0x1ea4 */ DWORD unknown001961; 146 /* 0x1ea8 */ DWORD unknown001962; 147 /* 0x1eac */ DWORD unknown001963; 148 /* 0x1eb0 */ DWORD unknown001964; 149 /* 0x1eb4 */ DWORD unknown001965; 150 /* 0x1eb8 */ DWORD unknown001966; 151 /* 0x1ebc */ DWORD unknown001967; 152 /* 0x1ec0 */ DWORD unknown001968; 153 /* 0x1ec4 */ DWORD unknown001969; 154 /* 0x1ec8 */ DWORD unknown001970; 155 /* 0x1ecc */ DWORD unknown001971; 156 /* 0x1ed0 */ DWORD unknown001972; 157 /* 0x1ed4 */ DWORD unknown001973; 158 /* 0x1ed8 */ DWORD unknown001974; 159 /* 0x1edc */ DWORD unknown001975; 160 /* 0x1ee0 */ DWORD unknown001976; 161 /* 0x1ee4 */ DWORD unknown001977; 162 /* 0x1ee8 */ DWORD unknown001978; 163 /* 0x1eec */ DWORD unknown001979; 164 /* 0x1ef0 */ DWORD unknown001980; 165 /* 0x1ef4 */ DWORD unknown001981; 166 /* 0x1ef8 */ DWORD unknown001982; 167 /* 0x1efc */ DWORD unknown001983; 168 /* 0x1f00 */ DWORD unknown001984; 169 /* 0x1f04 */ DWORD unknown001985; 170 /* 0x1f08 */ DWORD unknown001986; 171 /* 0x1f0c */ DWORD unknown001987; 172 /* 0x1f10 */ DWORD unknown001988; 173 /* 0x1f14 */ DWORD unknown001989; 174 /* 0x1f18 */ DWORD unknown001990; 175 /* 0x1f1c */ DWORD unknown001991; 176 /* 0x1f20 */ DWORD unknown001992; 177 /* 0x1f24 */ DWORD unknown001993; 178 /* 0x1f28 */ DWORD unknown001994; 179 /* 0x1f2c */ DWORD unknown001995; 180 /* 0x1f30 */ DWORD unknown001996; 181 /* 0x1f34 */ DWORD unknown001997; 182 /* 0x1f38 */ DWORD unknown001998; 183 /* 0x1f3c */ DWORD unknown001999; 184 /* 0x1f40 */ DWORD unknown002000; 185 /* 0x1f44 */ DWORD unknown002001; 186 } DIRECT3DDEVICE9_INT, FAR* LPDIRECT3DDEVICE9_INT; 187 188 /* Helper functions */ 189 LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface); 190 191 /* IUnknown interface */ 192 HRESULT WINAPI IDirect3DDevice9Base_QueryInterface(LPDIRECT3DDEVICE9 iface, REFIID riid, void** ppvObject); 193 ULONG WINAPI IDirect3DDevice9Base_AddRef(LPDIRECT3DDEVICE9 iface); 194 ULONG WINAPI IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface); 195 196 /* IDirect3DDevice9 public interface */ 197 HRESULT WINAPI IDirect3DDevice9Base_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface); 198 UINT WINAPI IDirect3DDevice9Base_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface); 199 HRESULT WINAPI IDirect3DDevice9Base_EvictManagedResources(LPDIRECT3DDEVICE9 iface); 200 HRESULT WINAPI IDirect3DDevice9Base_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9); 201 HRESULT WINAPI IDirect3DDevice9Base_GetDeviceCaps(LPDIRECT3DDEVICE9 iface, D3DCAPS9* pCaps); 202 HRESULT WINAPI IDirect3DDevice9Base_GetDisplayMode(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DDISPLAYMODE* pMode); 203 HRESULT WINAPI IDirect3DDevice9Base_GetCreationParameters(LPDIRECT3DDEVICE9 iface, D3DDEVICE_CREATION_PARAMETERS* pParameters); 204 HRESULT WINAPI IDirect3DDevice9Base_SetCursorProperties(LPDIRECT3DDEVICE9 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap); 205 VOID WINAPI IDirect3DDevice9Base_SetCursorPosition(LPDIRECT3DDEVICE9 iface, int X, int Y, DWORD Flags); 206 BOOL WINAPI IDirect3DDevice9Base_ShowCursor(LPDIRECT3DDEVICE9 iface, BOOL bShow); 207 HRESULT WINAPI IDirect3DDevice9Base_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** ppSwapChain); 208 HRESULT WINAPI IDirect3DDevice9Base_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSwapChain9** ppSwapChain); 209 UINT WINAPI IDirect3DDevice9Base_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface); 210 HRESULT WINAPI IDirect3DDevice9Base_Reset(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters); 211 HRESULT WINAPI IDirect3DDevice9Base_Present(LPDIRECT3DDEVICE9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion); 212 HRESULT WINAPI IDirect3DDevice9Base_GetBackBuffer(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer); 213 HRESULT WINAPI IDirect3DDevice9Base_GetRasterStatus(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus); 214 HRESULT WINAPI IDirect3DDevice9Base_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface, BOOL bEnableDialogs); 215 VOID WINAPI IDirect3DDevice9Base_SetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp); 216 VOID WINAPI IDirect3DDevice9Base_GetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DGAMMARAMP* pRamp); 217 HRESULT WINAPI IDirect3DDevice9Base_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle); 218 HRESULT WINAPI IDirect3DDevice9Base_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle); 219 HRESULT WINAPI IDirect3DDevice9Base_CreateCubeTexture(LPDIRECT3DDEVICE9 iface, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle); 220 HRESULT WINAPI IDirect3DDevice9Base_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle); 221 HRESULT WINAPI IDirect3DDevice9Base_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle); 222 HRESULT WINAPI IDirect3DDevice9Base_CreateRenderTarget(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); 223 HRESULT WINAPI IDirect3DDevice9Base_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); 224 HRESULT WINAPI IDirect3DDevice9Base_UpdateSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint); 225 HRESULT WINAPI IDirect3DDevice9Base_UpdateTexture(LPDIRECT3DDEVICE9 iface, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture); 226 HRESULT WINAPI IDirect3DDevice9Base_GetRenderTargetData(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface); 227 HRESULT WINAPI IDirect3DDevice9Base_GetFrontBufferData(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSurface9* pDestSurface); 228 HRESULT WINAPI IDirect3DDevice9Base_StretchRect(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter); 229 HRESULT WINAPI IDirect3DDevice9Base_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color); 230 HRESULT WINAPI IDirect3DDevice9Base_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle); 231 232 /* IDirect3DDevice9 private interface */ 233 VOID WINAPI IDirect3DDevice9Base_Destroy(LPDIRECT3DDEVICE9 iface); 234 VOID WINAPI IDirect3DDevice9Base_VirtualDestructor(LPDIRECT3DDEVICE9 iface); 235 236 #endif /* _D3D9_DEVICE_H_ */ 237