blob: ce34a9575dfb3af5261713b2c34ecd0b452cfbbb [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
Nicolas Capensee16f0d2015-07-16 17:40:10 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
Nicolas Capensee16f0d2015-07-16 17:40:10 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// http://www.apache.org/licenses/LICENSE-2.0
Nicolas Capensee16f0d2015-07-16 17:40:10 -04008//
Nicolas Capens0bac2852016-05-07 06:09:58 -04009// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
Nicolas Capensee16f0d2015-07-16 17:40:10 -040014
15#ifndef D3D9_Direct3DDevice9Ex_hpp
16#define D3D9_Direct3DDevice9Ex_hpp
17
18#include "Direct3DDevice9.hpp"
19
20#include "Direct3D9Ex.hpp"
21#include "Direct3DSwapChain9.hpp"
22
23#include "Stream.hpp"
24
25#include <d3d9.h>
26#include <map>
27#include <list>
28#include <vector>
29
30namespace sw
31{
32 class Renderer;
33 class Context;
34}
35
36namespace D3D9
37{
38 class Direct3DVertexDeclaration9;
39 class Direct3DStateBlock9;
40 class Direct3DSurface9;
41 class Direct3DPixelShader9;
42 class Direct3DVertexShader9;
43 class irect3DVertexDeclaration9;
44 class Direct3DVertexBuffer9;
45 class Direct3DIndexBuffer9;
46
47 class Direct3DDevice9Ex : public IDirect3DDevice9Ex, public Direct3DDevice9
48 {
49 public:
50 Direct3DDevice9Ex(const HINSTANCE instance, Direct3D9Ex *d3d9ex, unsigned int adapter, D3DDEVTYPE deviceType, HWND focusWindow, unsigned long behaviourFlags, D3DPRESENT_PARAMETERS *presentParameters);
51
52 virtual ~Direct3DDevice9Ex();
53
54 // IUnknown methods
55 long __stdcall QueryInterface(const IID &iid, void **object);
56 unsigned long __stdcall AddRef();
57 unsigned long __stdcall Release();
58
59 // IDirect3DDevice9 methods
60 long __stdcall TestCooperativeLevel();
61 unsigned int __stdcall GetAvailableTextureMem();
62 long __stdcall EvictManagedResources();
63 long __stdcall GetDirect3D(IDirect3D9 **D3D);
64 long __stdcall GetDeviceCaps(D3DCAPS9 *caps);
65 long __stdcall GetDisplayMode(unsigned int swapChain ,D3DDISPLAYMODE *mode);
66 long __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *parameters);
67 long __stdcall SetCursorProperties(unsigned int x, unsigned int y, IDirect3DSurface9 *cursorBitmap);
68 void __stdcall SetCursorPosition(int x, int y, unsigned long flags);
69 int __stdcall ShowCursor(int show);
70 long __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS *presentParameters, IDirect3DSwapChain9 **swapChain);
71 long __stdcall GetSwapChain(unsigned int index, IDirect3DSwapChain9 **swapChain);
72 unsigned int __stdcall GetNumberOfSwapChains();
73 long __stdcall Reset(D3DPRESENT_PARAMETERS *presentParameters);
74 long __stdcall Present(const RECT *sourceRect, const RECT *destRect, HWND destWindowOverride, const RGNDATA *dirtyRegion);
75 long __stdcall GetBackBuffer(unsigned int swapChain, unsigned int index, D3DBACKBUFFER_TYPE type, IDirect3DSurface9 **backBuffer);
76 long __stdcall GetRasterStatus(unsigned int swapChain, D3DRASTER_STATUS *rasterStatus);
77 long __stdcall SetDialogBoxMode(int enableDialogs);
78 void __stdcall SetGammaRamp(unsigned int swapChain, unsigned long flags, const D3DGAMMARAMP *ramp);
79 void __stdcall GetGammaRamp(unsigned int swapChain, D3DGAMMARAMP *ramp);
80 long __stdcall CreateTexture(unsigned int width, unsigned int height, unsigned int levels, unsigned long usage, D3DFORMAT format, D3DPOOL pool, IDirect3DTexture9 **texture, void **sharedHandle);
81 long __stdcall CreateVolumeTexture(unsigned int width, unsigned int height, unsigned int depth, unsigned int levels, unsigned long usage, D3DFORMAT format, D3DPOOL pool, IDirect3DVolumeTexture9 **volumeTexture, void **sharedHandle);
82 long __stdcall CreateCubeTexture(unsigned int edgeLength, unsigned int levels, unsigned long usage, D3DFORMAT format, D3DPOOL pool, IDirect3DCubeTexture9 **cubeTexture, void **sharedHandle);
83 long __stdcall CreateVertexBuffer(unsigned int length, unsigned long usage, unsigned long FVF, D3DPOOL, IDirect3DVertexBuffer9 **vertexBuffer, void **sharedHandle);
84 long __stdcall CreateIndexBuffer(unsigned int length, unsigned long usage, D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer9 **indexBuffer, void **sharedHandle);
85 long __stdcall CreateRenderTarget(unsigned int width, unsigned int height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multiSample, unsigned long multiSampleQuality, int lockable, IDirect3DSurface9 **surface, void **sharedHandle);
86 long __stdcall CreateDepthStencilSurface(unsigned int width, unsigned int height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multiSample, unsigned long multiSampleQuality, int discard, IDirect3DSurface9 **surface, void **sharedHandle);
87 long __stdcall UpdateSurface(IDirect3DSurface9 *sourceSurface, const RECT *sourceRect, IDirect3DSurface9 *destinationSurface, const POINT *destPoint);
88 long __stdcall UpdateTexture(IDirect3DBaseTexture9 *sourceTexture, IDirect3DBaseTexture9 *destinationTexture);
89 long __stdcall GetRenderTargetData(IDirect3DSurface9 *renderTarget, IDirect3DSurface9 *destSurface);
90 long __stdcall GetFrontBufferData(unsigned int swapChain, IDirect3DSurface9 *destSurface);
91 long __stdcall StretchRect(IDirect3DSurface9 *sourceSurface, const RECT *sourceRect, IDirect3DSurface9 *destSurface, const RECT *destRect, D3DTEXTUREFILTERTYPE filter);
92 long __stdcall ColorFill(IDirect3DSurface9 *surface, const RECT *rect, D3DCOLOR color);
93 long __stdcall CreateOffscreenPlainSurface(unsigned int width, unsigned int height, D3DFORMAT format, D3DPOOL pool, IDirect3DSurface9 **surface, void **sharedHandle);
94 long __stdcall SetRenderTarget(unsigned long index, IDirect3DSurface9 *renderTarget);
95 long __stdcall GetRenderTarget(unsigned long index, IDirect3DSurface9 **renderTarget);
96 long __stdcall SetDepthStencilSurface(IDirect3DSurface9 *newDepthStencil);
97 long __stdcall GetDepthStencilSurface(IDirect3DSurface9 **depthStencilSurface);
98 long __stdcall BeginScene();
99 long __stdcall EndScene();
100 long __stdcall Clear(unsigned long Count, const D3DRECT *rects, unsigned long Flags, unsigned long Color, float Z, unsigned long Stencil);
101 long __stdcall SetTransform(D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix);
102 long __stdcall GetTransform(D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix);
103 long __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix);
104 long __stdcall SetViewport(const D3DVIEWPORT9 *viewport);
105 long __stdcall GetViewport(D3DVIEWPORT9 *viewport);
106 long __stdcall SetMaterial(const D3DMATERIAL9 *material);
107 long __stdcall GetMaterial(D3DMATERIAL9 *material);
108 long __stdcall SetLight(unsigned long index, const D3DLIGHT9 *light);
109 long __stdcall GetLight(unsigned long index, D3DLIGHT9 *light);
110 long __stdcall LightEnable(unsigned long index, int enable);
111 long __stdcall GetLightEnable(unsigned long index , int *enable);
112 long __stdcall SetClipPlane(unsigned long index, const float *plane);
113 long __stdcall GetClipPlane(unsigned long index, float *plane);
114 long __stdcall SetRenderState(D3DRENDERSTATETYPE state, unsigned long value);
115 long __stdcall GetRenderState(D3DRENDERSTATETYPE State, unsigned long *value);
116 long __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE type, IDirect3DStateBlock9 **stateBlock);
117 long __stdcall BeginStateBlock();
118 long __stdcall EndStateBlock(IDirect3DStateBlock9 **stateBlock);
119 long __stdcall SetClipStatus(const D3DCLIPSTATUS9 *clipStatus);
120 long __stdcall GetClipStatus(D3DCLIPSTATUS9 *clipStatus);
121 long __stdcall GetTexture(unsigned long sampler, IDirect3DBaseTexture9 **texture);
122 long __stdcall SetTexture(unsigned long sampler, IDirect3DBaseTexture9 *texture);
123 long __stdcall GetTextureStageState(unsigned long stage, D3DTEXTURESTAGESTATETYPE type, unsigned long *value);
124 long __stdcall SetTextureStageState(unsigned long stage, D3DTEXTURESTAGESTATETYPE type, unsigned long value);
125 long __stdcall GetSamplerState(unsigned long sampler, D3DSAMPLERSTATETYPE state, unsigned long *value);
126 long __stdcall SetSamplerState(unsigned long sampler, D3DSAMPLERSTATETYPE state, unsigned long value);
127 long __stdcall ValidateDevice(unsigned long *numPasses);
128 long __stdcall SetPaletteEntries(unsigned int paletteNumber, const PALETTEENTRY *entries);
129 long __stdcall GetPaletteEntries(unsigned int paletteNumber, PALETTEENTRY *entries);
130 long __stdcall SetCurrentTexturePalette(unsigned int paletteNumber);
131 long __stdcall GetCurrentTexturePalette(unsigned int *paletteNumber);
132 long __stdcall SetScissorRect(const RECT *rect);
133 long __stdcall GetScissorRect(RECT *rect);
134 long __stdcall SetSoftwareVertexProcessing(int software);
135 int __stdcall GetSoftwareVertexProcessing();
136 long __stdcall SetNPatchMode(float segments);
137 float __stdcall GetNPatchMode();
138 long __stdcall DrawPrimitive(D3DPRIMITIVETYPE primitiveType, unsigned int startVertex, unsigned int primiveCount);
139 long __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE type, int baseVertexIndex, unsigned int minIndex, unsigned int numVertices, unsigned int startIndex, unsigned int primitiveCount);
140 long __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE primitiveType, unsigned int primitiveCount, const void *vertexStreamZeroData, unsigned int vertexStreamZeroStride);
141 long __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE type, unsigned int minVertexIndex, unsigned int numVertexIndices, unsigned int PrimitiveCount, const void *indexData, D3DFORMAT indexDataFormat, const void *vertexStreamZeroData, unsigned int VertexStreamZeroStride);
142 long __stdcall ProcessVertices(unsigned int srcStartIndex, unsigned int destIndex, unsigned int vertexCount, IDirect3DVertexBuffer9 *destBuffer, IDirect3DVertexDeclaration9 *vertexDeclaration, unsigned long flags);
143 long __stdcall CreateVertexDeclaration(const D3DVERTEXELEMENT9 *vertexElements, IDirect3DVertexDeclaration9 **declaration);
144 long __stdcall SetVertexDeclaration(IDirect3DVertexDeclaration9 *declaration);
145 long __stdcall GetVertexDeclaration(IDirect3DVertexDeclaration9 **declaration);
146 long __stdcall SetFVF(unsigned long FVF);
147 long __stdcall GetFVF(unsigned long *FVF);
148 long __stdcall CreateVertexShader(const unsigned long *function, IDirect3DVertexShader9 **shader);
149 long __stdcall SetVertexShader(IDirect3DVertexShader9 *shader);
150 long __stdcall GetVertexShader(IDirect3DVertexShader9 **shader);
151 long __stdcall SetVertexShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);
152 long __stdcall GetVertexShaderConstantF(unsigned int startRegister, float *constantData, unsigned int count);
153 long __stdcall SetVertexShaderConstantI(unsigned int startRegister, const int *constantData, unsigned int count);
154 long __stdcall GetVertexShaderConstantI(unsigned int startRegister, int *constantData, unsigned int count);
155 long __stdcall SetVertexShaderConstantB(unsigned int startRegister, const int *constantData, unsigned int count);
156 long __stdcall GetVertexShaderConstantB(unsigned int startRegister, int *constantData, unsigned int count);
157 long __stdcall SetStreamSource(unsigned int stream, IDirect3DVertexBuffer9 *data, unsigned int offset, unsigned int stride);
158 long __stdcall GetStreamSource(unsigned int streamNumber, IDirect3DVertexBuffer9 **streamData, unsigned int *offset, unsigned int *stride);
159 long __stdcall SetStreamSourceFreq(unsigned int streamNumber, unsigned int divider);
160 long __stdcall GetStreamSourceFreq(unsigned int streamNumber, unsigned int *divider);
161 long __stdcall SetIndices(IDirect3DIndexBuffer9 *indexData);
162 long __stdcall GetIndices(IDirect3DIndexBuffer9 **indexData);
163 long __stdcall CreatePixelShader(const unsigned long *function, IDirect3DPixelShader9 **shader);
164 long __stdcall SetPixelShader(IDirect3DPixelShader9 *shader);
165 long __stdcall GetPixelShader(IDirect3DPixelShader9 **shader);
166 long __stdcall SetPixelShaderConstantI(unsigned int startRegister, const int *constantData, unsigned int count);
167 long __stdcall GetPixelShaderConstantI(unsigned int startRegister, int *constantData, unsigned int count);
168 long __stdcall SetPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);
169 long __stdcall GetPixelShaderConstantF(unsigned int startRegister, float *constantData, unsigned int count);
170 long __stdcall SetPixelShaderConstantB(unsigned int startRegister, const int *constantData, unsigned int count);
171 long __stdcall GetPixelShaderConstantB(unsigned int startRegister, int *constantData, unsigned int count);
172 long __stdcall DrawRectPatch(unsigned int handle, const float *numSegs, const D3DRECTPATCH_INFO *rectPatchInfo);
173 long __stdcall DrawTriPatch(unsigned int handle, const float *numSegs, const D3DTRIPATCH_INFO *triPatchInfo);
174 long __stdcall DeletePatch(unsigned int handle);
175 long __stdcall CreateQuery(D3DQUERYTYPE type, IDirect3DQuery9 **query);
176
177 // IDirect3DDevice9Ex methods
178 long __stdcall SetConvolutionMonoKernel(UINT,UINT,float *,float *);
179 long __stdcall ComposeRects(IDirect3DSurface9 *,IDirect3DSurface9 *,IDirect3DVertexBuffer9 *,UINT,IDirect3DVertexBuffer9 *,D3DCOMPOSERECTSOP,int,int);
180 long __stdcall PresentEx(const RECT *,const RECT *,HWND,const RGNDATA *,DWORD);
181 long __stdcall GetGPUThreadPriority(int *priority);
182 long __stdcall SetGPUThreadPriority(int priority);
183 long __stdcall WaitForVBlank(unsigned int swapChain);
184 long __stdcall CheckResourceResidency(IDirect3DResource9 **resourceArray, unsigned int numResources);
185 long __stdcall SetMaximumFrameLatency(unsigned int maxLatency);
186 long __stdcall GetMaximumFrameLatency(unsigned int *maxLatency);
187 long __stdcall CheckDeviceState(HWND destinationWindow);
188 long __stdcall CreateRenderTargetEx(unsigned int width, unsigned int height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multiSampleType, unsigned long multiSampleQuality, int lockable, IDirect3DSurface9 **surface, void **sharedHandle, unsigned long usage);
189 long __stdcall CreateOffscreenPlainSurfaceEx(unsigned int width, unsigned int height, D3DFORMAT format, D3DPOOL pool, IDirect3DSurface9 **surface, void **sharedHandle, unsigned long usage);
190 long __stdcall CreateDepthStencilSurfaceEx(unsigned int width, unsigned int height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multiSampleType, unsigned long multiSampleQuality, int discard, IDirect3DSurface9 **surface, void **sharedHandle, unsigned long usage);
191 long __stdcall ResetEx(D3DPRESENT_PARAMETERS *presentParameters, D3DDISPLAYMODEEX *fullscreenDisplayMode);
192 long __stdcall GetDisplayModeEx(unsigned int swapChain, D3DDISPLAYMODEEX *mode, D3DDISPLAYROTATION *rotation);
193
194 private:
195 Direct3D9Ex *const d3d9ex;
196 };
197}
198
199#endif // D3D9_Direct3DDevice9Ex_hpp