1 | /*
|
---|
2 | * IDirect3D9 implementation
|
---|
3 | *
|
---|
4 | * Copyright 2002 Jason Edmeades
|
---|
5 | * Copyright 2005 Oliver Stieber
|
---|
6 | *
|
---|
7 | * This library is free software; you can redistribute it and/or
|
---|
8 | * modify it under the terms of the GNU Lesser General Public
|
---|
9 | * License as published by the Free Software Foundation; either
|
---|
10 | * version 2.1 of the License, or (at your option) any later version.
|
---|
11 | *
|
---|
12 | * This library is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | * Lesser General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU Lesser General Public
|
---|
18 | * License along with this library; if not, write to the Free Software
|
---|
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
20 | */
|
---|
21 |
|
---|
22 | /*
|
---|
23 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
24 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
25 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
26 | * a choice of LGPL license versions is made available with the language indicating
|
---|
27 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
28 | * of the LGPL is applied is otherwise unspecified.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #include "config.h"
|
---|
32 | #include "d3d9_private.h"
|
---|
33 |
|
---|
34 | WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
|
---|
35 |
|
---|
36 | /* IDirect3D9 IUnknown parts follow: */
|
---|
37 | static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9EX iface, REFIID riid, LPVOID* ppobj)
|
---|
38 | {
|
---|
39 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
40 |
|
---|
41 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
42 | || IsEqualGUID(riid, &IID_IDirect3D9)) {
|
---|
43 | IDirect3D9Ex_AddRef(iface);
|
---|
44 | *ppobj = This;
|
---|
45 | TRACE("Returning IDirect3D9 interface at %p\n", *ppobj);
|
---|
46 | return S_OK;
|
---|
47 | } else if(IsEqualGUID(riid, &IID_IDirect3D9Ex)) {
|
---|
48 | if(This->extended) {
|
---|
49 | *ppobj = This;
|
---|
50 | TRACE("Returning IDirect3D9Ex interface at %p\n", *ppobj);
|
---|
51 | IDirect3D9Ex_AddRef((IDirect3D9Ex *)*ppobj);
|
---|
52 | } else {
|
---|
53 | WARN("Application asks for IDirect3D9Ex, but this instance wasn't created with Direct3DCreate9Ex\n");
|
---|
54 | WARN("Returning E_NOINTERFACE\n");
|
---|
55 | *ppobj = NULL;
|
---|
56 | return E_NOINTERFACE;
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
---|
61 | *ppobj = NULL;
|
---|
62 | return E_NOINTERFACE;
|
---|
63 | }
|
---|
64 |
|
---|
65 | static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9EX iface) {
|
---|
66 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
67 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
68 |
|
---|
69 | TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
---|
70 |
|
---|
71 | return ref;
|
---|
72 | }
|
---|
73 |
|
---|
74 | static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9EX iface) {
|
---|
75 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
76 | ULONG ref = InterlockedDecrement(&This->ref);
|
---|
77 |
|
---|
78 | TRACE("(%p) : ReleaseRef to %d\n", This, ref);
|
---|
79 |
|
---|
80 | if (ref == 0) {
|
---|
81 | EnterCriticalSection(&d3d9_cs);
|
---|
82 | IWineD3D_Release(This->WineD3D);
|
---|
83 | LeaveCriticalSection(&d3d9_cs);
|
---|
84 | HeapFree(GetProcessHeap(), 0, This);
|
---|
85 | }
|
---|
86 |
|
---|
87 | return ref;
|
---|
88 | }
|
---|
89 |
|
---|
90 | /* IDirect3D9 Interface follow: */
|
---|
91 | static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9EX iface, void* pInitializeFunction) {
|
---|
92 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
93 | HRESULT hr;
|
---|
94 | TRACE("(%p)->(%p)\n", This, pInitializeFunction);
|
---|
95 |
|
---|
96 | EnterCriticalSection(&d3d9_cs);
|
---|
97 | hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
|
---|
98 | LeaveCriticalSection(&d3d9_cs);
|
---|
99 | return hr;
|
---|
100 | }
|
---|
101 |
|
---|
102 | static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9EX iface) {
|
---|
103 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
104 | HRESULT hr;
|
---|
105 | TRACE("%p\n", This);
|
---|
106 |
|
---|
107 | EnterCriticalSection(&d3d9_cs);
|
---|
108 | hr = IWineD3D_GetAdapterCount(This->WineD3D);
|
---|
109 | LeaveCriticalSection(&d3d9_cs);
|
---|
110 | return hr;
|
---|
111 | }
|
---|
112 |
|
---|
113 | static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
|
---|
114 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
115 | WINED3DADAPTER_IDENTIFIER adapter_id;
|
---|
116 | HRESULT hr;
|
---|
117 |
|
---|
118 | adapter_id.driver = pIdentifier->Driver;
|
---|
119 | adapter_id.driver_size = sizeof(pIdentifier->Driver);
|
---|
120 | adapter_id.description = pIdentifier->Description;
|
---|
121 | adapter_id.description_size = sizeof(pIdentifier->Description);
|
---|
122 | adapter_id.device_name = pIdentifier->DeviceName;
|
---|
123 | adapter_id.device_name_size = sizeof(pIdentifier->DeviceName);
|
---|
124 |
|
---|
125 | EnterCriticalSection(&d3d9_cs);
|
---|
126 | hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
|
---|
127 | LeaveCriticalSection(&d3d9_cs);
|
---|
128 |
|
---|
129 | pIdentifier->DriverVersion = adapter_id.driver_version;
|
---|
130 | pIdentifier->VendorId = adapter_id.vendor_id;
|
---|
131 | pIdentifier->DeviceId = adapter_id.device_id;
|
---|
132 | pIdentifier->SubSysId = adapter_id.subsystem_id;
|
---|
133 | pIdentifier->Revision = adapter_id.revision;
|
---|
134 | memcpy(&pIdentifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(pIdentifier->DeviceIdentifier));
|
---|
135 | pIdentifier->WHQLLevel = adapter_id.whql_level;
|
---|
136 |
|
---|
137 | return hr;
|
---|
138 | }
|
---|
139 |
|
---|
140 | static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format) {
|
---|
141 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
142 | HRESULT hr;
|
---|
143 | TRACE("(%p)->(%d, %d\n", This, Adapter, Format);
|
---|
144 |
|
---|
145 | /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out */
|
---|
146 | if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5) {
|
---|
147 | return 0;
|
---|
148 | }
|
---|
149 |
|
---|
150 | EnterCriticalSection(&d3d9_cs);
|
---|
151 | hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format));
|
---|
152 | LeaveCriticalSection(&d3d9_cs);
|
---|
153 | return hr;
|
---|
154 | }
|
---|
155 |
|
---|
156 | static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
|
---|
157 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
158 | HRESULT hr;
|
---|
159 | TRACE("(%p)->(%d, %d, %d, %p)\n", This, Adapter, Format, Mode, pMode);
|
---|
160 | /* We can't pass this to WineD3D, otherwise it'll think it came from D3D8 or DDraw.
|
---|
161 | It's supposed to fail anyway, so no harm returning failure. */
|
---|
162 | if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5)
|
---|
163 | return D3DERR_INVALIDCALL;
|
---|
164 |
|
---|
165 | EnterCriticalSection(&d3d9_cs);
|
---|
166 | hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format),
|
---|
167 | Mode, (WINED3DDISPLAYMODE *) pMode);
|
---|
168 | LeaveCriticalSection(&d3d9_cs);
|
---|
169 |
|
---|
170 | if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
---|
171 |
|
---|
172 | return hr;
|
---|
173 | }
|
---|
174 |
|
---|
175 | static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
|
---|
176 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
177 | HRESULT hr;
|
---|
178 |
|
---|
179 | EnterCriticalSection(&d3d9_cs);
|
---|
180 | hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
|
---|
181 | LeaveCriticalSection(&d3d9_cs);
|
---|
182 |
|
---|
183 | if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
---|
184 |
|
---|
185 | return hr;
|
---|
186 | }
|
---|
187 |
|
---|
188 | static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9EX iface,
|
---|
189 | UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
|
---|
190 | D3DFORMAT BackBufferFormat, BOOL Windowed) {
|
---|
191 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
192 | HRESULT hr;
|
---|
193 | TRACE("(%p)->(%d, %d, %d, %d, %s\n", This, Adapter, CheckType, DisplayFormat,
|
---|
194 | BackBufferFormat, Windowed ? "true" : "false");
|
---|
195 |
|
---|
196 | EnterCriticalSection(&d3d9_cs);
|
---|
197 | hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
|
---|
198 | wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
|
---|
199 | LeaveCriticalSection(&d3d9_cs);
|
---|
200 | return hr;
|
---|
201 | }
|
---|
202 |
|
---|
203 | static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9EX iface,
|
---|
204 | UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
|
---|
205 | DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
|
---|
206 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
207 | HRESULT hr;
|
---|
208 | WINED3DRESOURCETYPE WineD3DRType;
|
---|
209 | TRACE("%p\n", This);
|
---|
210 |
|
---|
211 | switch(RType) {
|
---|
212 | case D3DRTYPE_VERTEXBUFFER:
|
---|
213 | case D3DRTYPE_INDEXBUFFER:
|
---|
214 | WineD3DRType = WINED3DRTYPE_BUFFER;
|
---|
215 | break;
|
---|
216 |
|
---|
217 | default:
|
---|
218 | WineD3DRType = RType;
|
---|
219 | break;
|
---|
220 | }
|
---|
221 |
|
---|
222 | EnterCriticalSection(&d3d9_cs);
|
---|
223 | hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
|
---|
224 | Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
|
---|
225 | LeaveCriticalSection(&d3d9_cs);
|
---|
226 | return hr;
|
---|
227 | }
|
---|
228 |
|
---|
229 | static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9EX iface,
|
---|
230 | UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
|
---|
231 | BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
|
---|
232 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
233 | HRESULT hr;
|
---|
234 | TRACE("%p\n", This);
|
---|
235 |
|
---|
236 | EnterCriticalSection(&d3d9_cs);
|
---|
237 | hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
|
---|
238 | wined3dformat_from_d3dformat(SurfaceFormat), Windowed, MultiSampleType, pQualityLevels);
|
---|
239 | LeaveCriticalSection(&d3d9_cs);
|
---|
240 | return hr;
|
---|
241 | }
|
---|
242 |
|
---|
243 | static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9EX iface,
|
---|
244 | UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
|
---|
245 | D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
|
---|
246 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
247 | HRESULT hr;
|
---|
248 | TRACE("%p\n", This);
|
---|
249 |
|
---|
250 | EnterCriticalSection(&d3d9_cs);
|
---|
251 | hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
|
---|
252 | wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
|
---|
253 | wined3dformat_from_d3dformat(DepthStencilFormat));
|
---|
254 | LeaveCriticalSection(&d3d9_cs);
|
---|
255 | return hr;
|
---|
256 | }
|
---|
257 |
|
---|
258 | static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
|
---|
259 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
260 | HRESULT hr;
|
---|
261 | TRACE("%p\n", This);
|
---|
262 |
|
---|
263 | EnterCriticalSection(&d3d9_cs);
|
---|
264 | hr = IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType,
|
---|
265 | wined3dformat_from_d3dformat(SourceFormat), wined3dformat_from_d3dformat(TargetFormat));
|
---|
266 | LeaveCriticalSection(&d3d9_cs);
|
---|
267 | return hr;
|
---|
268 | }
|
---|
269 |
|
---|
270 | void filter_caps(D3DCAPS9* pCaps)
|
---|
271 | {
|
---|
272 |
|
---|
273 | DWORD textureFilterCaps =
|
---|
274 | D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR | D3DPTFILTERCAPS_MINFANISOTROPIC |
|
---|
275 | D3DPTFILTERCAPS_MINFPYRAMIDALQUAD | D3DPTFILTERCAPS_MINFGAUSSIANQUAD|
|
---|
276 | D3DPTFILTERCAPS_MIPFPOINT | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT |
|
---|
277 | D3DPTFILTERCAPS_MAGFLINEAR |D3DPTFILTERCAPS_MAGFANISOTROPIC|D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD|
|
---|
278 | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD;
|
---|
279 | pCaps->TextureFilterCaps &= textureFilterCaps;
|
---|
280 | pCaps->CubeTextureFilterCaps &= textureFilterCaps;
|
---|
281 | pCaps->VolumeTextureFilterCaps &= textureFilterCaps;
|
---|
282 |
|
---|
283 | pCaps->DevCaps &=
|
---|
284 | D3DDEVCAPS_EXECUTESYSTEMMEMORY | D3DDEVCAPS_EXECUTEVIDEOMEMORY | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY |
|
---|
285 | D3DDEVCAPS_TLVERTEXVIDEOMEMORY | D3DDEVCAPS_TEXTURESYSTEMMEMORY| D3DDEVCAPS_TEXTUREVIDEOMEMORY |
|
---|
286 | D3DDEVCAPS_DRAWPRIMTLVERTEX | D3DDEVCAPS_CANRENDERAFTERFLIP | D3DDEVCAPS_TEXTURENONLOCALVIDMEM|
|
---|
287 | D3DDEVCAPS_DRAWPRIMITIVES2 | D3DDEVCAPS_SEPARATETEXTUREMEMORIES |
|
---|
288 | D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWTRANSFORMANDLIGHT| D3DDEVCAPS_CANBLTSYSTONONLOCAL |
|
---|
289 | D3DDEVCAPS_HWRASTERIZATION | D3DDEVCAPS_PUREDEVICE | D3DDEVCAPS_QUINTICRTPATCHES |
|
---|
290 | D3DDEVCAPS_RTPATCHES | D3DDEVCAPS_RTPATCHHANDLEZERO | D3DDEVCAPS_NPATCHES;
|
---|
291 |
|
---|
292 | pCaps->ShadeCaps &=
|
---|
293 | D3DPSHADECAPS_COLORGOURAUDRGB | D3DPSHADECAPS_SPECULARGOURAUDRGB |
|
---|
294 | D3DPSHADECAPS_ALPHAGOURAUDBLEND | D3DPSHADECAPS_FOGGOURAUD;
|
---|
295 |
|
---|
296 | pCaps->RasterCaps &=
|
---|
297 | D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_ZTEST | D3DPRASTERCAPS_FOGVERTEX |
|
---|
298 | D3DPRASTERCAPS_FOGTABLE | D3DPRASTERCAPS_MIPMAPLODBIAS | D3DPRASTERCAPS_ZBUFFERLESSHSR |
|
---|
299 | D3DPRASTERCAPS_FOGRANGE | D3DPRASTERCAPS_ANISOTROPY | D3DPRASTERCAPS_WBUFFER |
|
---|
300 | D3DPRASTERCAPS_WFOG | D3DPRASTERCAPS_ZFOG | D3DPRASTERCAPS_COLORPERSPECTIVE |
|
---|
301 | D3DPRASTERCAPS_SCISSORTEST | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
|
---|
302 | D3DPRASTERCAPS_DEPTHBIAS | D3DPRASTERCAPS_MULTISAMPLE_TOGGLE;
|
---|
303 |
|
---|
304 | pCaps->DevCaps2 &=
|
---|
305 | D3DDEVCAPS2_STREAMOFFSET | D3DDEVCAPS2_DMAPNPATCH | D3DDEVCAPS2_ADAPTIVETESSRTPATCH |
|
---|
306 | D3DDEVCAPS2_ADAPTIVETESSNPATCH | D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES |
|
---|
307 | D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH| D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
|
---|
308 |
|
---|
309 | pCaps->Caps2 &=
|
---|
310 | D3DCAPS2_FULLSCREENGAMMA | D3DCAPS2_CANCALIBRATEGAMMA | D3DCAPS2_RESERVED |
|
---|
311 | D3DCAPS2_CANMANAGERESOURCE | D3DCAPS2_DYNAMICTEXTURES | D3DCAPS2_CANAUTOGENMIPMAP;
|
---|
312 |
|
---|
313 | pCaps->VertexProcessingCaps &=
|
---|
314 | D3DVTXPCAPS_TEXGEN | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_DIRECTIONALLIGHTS |
|
---|
315 | D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_LOCALVIEWER | D3DVTXPCAPS_TWEENING |
|
---|
316 | D3DVTXPCAPS_TEXGEN_SPHEREMAP | D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER;
|
---|
317 |
|
---|
318 | pCaps->TextureCaps &=
|
---|
319 | D3DPTEXTURECAPS_PERSPECTIVE | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_ALPHA |
|
---|
320 | D3DPTEXTURECAPS_SQUAREONLY | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |
|
---|
321 | D3DPTEXTURECAPS_ALPHAPALETTE | D3DPTEXTURECAPS_NONPOW2CONDITIONAL |
|
---|
322 | D3DPTEXTURECAPS_PROJECTED | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_VOLUMEMAP |
|
---|
323 | D3DPTEXTURECAPS_MIPMAP | D3DPTEXTURECAPS_MIPVOLUMEMAP | D3DPTEXTURECAPS_MIPCUBEMAP |
|
---|
324 | D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_VOLUMEMAP_POW2| D3DPTEXTURECAPS_NOPROJECTEDBUMPENV;
|
---|
325 |
|
---|
326 | pCaps->MaxVertexShaderConst = min(D3D9_MAX_VERTEX_SHADER_CONSTANTF, pCaps->MaxVertexShaderConst);
|
---|
327 | }
|
---|
328 |
|
---|
329 | static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
|
---|
330 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
331 | HRESULT hrc = D3D_OK;
|
---|
332 | WINED3DCAPS *pWineCaps;
|
---|
333 |
|
---|
334 | TRACE("(%p) Relay %d %u %p\n", This, Adapter, DeviceType, pCaps);
|
---|
335 |
|
---|
336 | if(NULL == pCaps){
|
---|
337 | return D3DERR_INVALIDCALL;
|
---|
338 | }
|
---|
339 | pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
|
---|
340 | if(pWineCaps == NULL){
|
---|
341 | return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
|
---|
342 | }
|
---|
343 | memset(pCaps, 0, sizeof(*pCaps));
|
---|
344 | EnterCriticalSection(&d3d9_cs);
|
---|
345 | hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
|
---|
346 | LeaveCriticalSection(&d3d9_cs);
|
---|
347 | WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
|
---|
348 | HeapFree(GetProcessHeap(), 0, pWineCaps);
|
---|
349 |
|
---|
350 | /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
|
---|
351 | pCaps->DevCaps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
|
---|
352 |
|
---|
353 | filter_caps(pCaps);
|
---|
354 |
|
---|
355 | TRACE("(%p) returning %p\n", This, pCaps);
|
---|
356 | return hrc;
|
---|
357 | }
|
---|
358 |
|
---|
359 | static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UINT Adapter) {
|
---|
360 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
361 | HMONITOR ret;
|
---|
362 | TRACE("%p\n", This);
|
---|
363 |
|
---|
364 | EnterCriticalSection(&d3d9_cs);
|
---|
365 | ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
|
---|
366 | LeaveCriticalSection(&d3d9_cs);
|
---|
367 | return ret;
|
---|
368 | }
|
---|
369 |
|
---|
370 | ULONG WINAPI D3D9CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
|
---|
371 | IDirect3DSurface9Impl* surfaceParent;
|
---|
372 | TRACE("(%p) call back\n", pSurface);
|
---|
373 |
|
---|
374 | IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
|
---|
375 | surfaceParent->isImplicit = FALSE;
|
---|
376 | /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
|
---|
377 | return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
|
---|
378 | }
|
---|
379 |
|
---|
380 | ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
|
---|
381 | IDirect3DSwapChain9Impl* swapChainParent;
|
---|
382 | TRACE("(%p) call back\n", pSwapChain);
|
---|
383 |
|
---|
384 | IWineD3DSwapChain_GetParent(pSwapChain,(IUnknown **) &swapChainParent);
|
---|
385 | swapChainParent->isImplicit = FALSE;
|
---|
386 | /* Swap chain had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
|
---|
387 | return IDirect3DSwapChain9_Release((IDirect3DSwapChain9*) swapChainParent);
|
---|
388 | }
|
---|
389 |
|
---|
390 | ULONG WINAPI D3D9CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {
|
---|
391 | IDirect3DSurface9Impl* surfaceParent;
|
---|
392 | TRACE("(%p) call back\n", pSurface);
|
---|
393 |
|
---|
394 | IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
|
---|
395 | surfaceParent->isImplicit = FALSE;
|
---|
396 | /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
|
---|
397 | return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
|
---|
398 | }
|
---|
399 |
|
---|
400 | static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType,
|
---|
401 | HWND hFocusWindow, DWORD BehaviourFlags,
|
---|
402 | D3DPRESENT_PARAMETERS* pPresentationParameters,
|
---|
403 | IDirect3DDevice9** ppReturnedDeviceInterface) {
|
---|
404 |
|
---|
405 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
406 | IDirect3DDevice9Impl *object = NULL;
|
---|
407 | WINED3DPRESENT_PARAMETERS *localParameters;
|
---|
408 | UINT i, count = 1;
|
---|
409 | HRESULT hr;
|
---|
410 | TRACE("(%p) Relay\n", This);
|
---|
411 |
|
---|
412 | /* Check the validity range of the adapter parameter */
|
---|
413 | if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) {
|
---|
414 | *ppReturnedDeviceInterface = NULL;
|
---|
415 | return D3DERR_INVALIDCALL;
|
---|
416 | }
|
---|
417 |
|
---|
418 | /* Allocate the storage for the device object */
|
---|
419 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl));
|
---|
420 | if (NULL == object) {
|
---|
421 | FIXME("Allocation of memory failed\n");
|
---|
422 | *ppReturnedDeviceInterface = NULL;
|
---|
423 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
424 | }
|
---|
425 |
|
---|
426 | object->lpVtbl = &Direct3DDevice9_Vtbl;
|
---|
427 | object->device_parent_vtbl = &d3d9_wined3d_device_parent_vtbl;
|
---|
428 | object->ref = 1;
|
---|
429 | *ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
|
---|
430 |
|
---|
431 | /* Allocate an associated WineD3DDevice object */
|
---|
432 | EnterCriticalSection(&d3d9_cs);
|
---|
433 | hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags,
|
---|
434 | (IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice);
|
---|
435 | if (hr != D3D_OK) {
|
---|
436 | HeapFree(GetProcessHeap(), 0, object);
|
---|
437 | *ppReturnedDeviceInterface = NULL;
|
---|
438 | LeaveCriticalSection(&d3d9_cs);
|
---|
439 | return hr;
|
---|
440 | }
|
---|
441 |
|
---|
442 | TRACE("(%p) : Created Device %p\n", This, object);
|
---|
443 |
|
---|
444 | if (BehaviourFlags & D3DCREATE_ADAPTERGROUP_DEVICE)
|
---|
445 | {
|
---|
446 | WINED3DCAPS caps;
|
---|
447 |
|
---|
448 | IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, &caps);
|
---|
449 | count = caps.NumberOfAdaptersInGroup;
|
---|
450 | }
|
---|
451 |
|
---|
452 | if(BehaviourFlags & D3DCREATE_MULTITHREADED) {
|
---|
453 | IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);
|
---|
454 | }
|
---|
455 |
|
---|
456 | localParameters = HeapAlloc(GetProcessHeap(), 0, sizeof(*localParameters) * count);
|
---|
457 | for (i = 0; i < count; ++i)
|
---|
458 | {
|
---|
459 | localParameters[i].BackBufferWidth = pPresentationParameters[i].BackBufferWidth;
|
---|
460 | localParameters[i].BackBufferHeight = pPresentationParameters[i].BackBufferHeight;
|
---|
461 | localParameters[i].BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters[i].BackBufferFormat);
|
---|
462 | localParameters[i].BackBufferCount = pPresentationParameters[i].BackBufferCount;
|
---|
463 | localParameters[i].MultiSampleType = pPresentationParameters[i].MultiSampleType;
|
---|
464 | localParameters[i].MultiSampleQuality = pPresentationParameters[i].MultiSampleQuality;
|
---|
465 | localParameters[i].SwapEffect = pPresentationParameters[i].SwapEffect;
|
---|
466 | localParameters[i].hDeviceWindow = pPresentationParameters[i].hDeviceWindow;
|
---|
467 | localParameters[i].Windowed = pPresentationParameters[i].Windowed;
|
---|
468 | localParameters[i].EnableAutoDepthStencil = pPresentationParameters[i].EnableAutoDepthStencil;
|
---|
469 | localParameters[i].AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters[i].AutoDepthStencilFormat);
|
---|
470 | localParameters[i].Flags = pPresentationParameters[i].Flags;
|
---|
471 | localParameters[i].FullScreen_RefreshRateInHz = pPresentationParameters[i].FullScreen_RefreshRateInHz;
|
---|
472 | localParameters[i].PresentationInterval = pPresentationParameters[i].PresentationInterval;
|
---|
473 | localParameters[i].AutoRestoreDisplayMode = TRUE;
|
---|
474 | }
|
---|
475 |
|
---|
476 | hr = IWineD3DDevice_Init3D(object->WineD3DDevice, localParameters);
|
---|
477 | if (hr != D3D_OK) {
|
---|
478 | FIXME("(%p) D3D Initialization failed for WineD3DDevice %p\n", This, object->WineD3DDevice);
|
---|
479 | HeapFree(GetProcessHeap(), 0, object);
|
---|
480 | *ppReturnedDeviceInterface = NULL;
|
---|
481 | }
|
---|
482 |
|
---|
483 | for (i = 0; i < count; ++i)
|
---|
484 | {
|
---|
485 | pPresentationParameters[i].BackBufferWidth = localParameters[i].BackBufferWidth;
|
---|
486 | pPresentationParameters[i].BackBufferHeight = localParameters[i].BackBufferHeight;
|
---|
487 | pPresentationParameters[i].BackBufferFormat = d3dformat_from_wined3dformat(localParameters[i].BackBufferFormat);
|
---|
488 | pPresentationParameters[i].BackBufferCount = localParameters[i].BackBufferCount;
|
---|
489 | pPresentationParameters[i].MultiSampleType = localParameters[i].MultiSampleType;
|
---|
490 | pPresentationParameters[i].MultiSampleQuality = localParameters[i].MultiSampleQuality;
|
---|
491 | pPresentationParameters[i].SwapEffect = localParameters[i].SwapEffect;
|
---|
492 | pPresentationParameters[i].hDeviceWindow = localParameters[i].hDeviceWindow;
|
---|
493 | pPresentationParameters[i].Windowed = localParameters[i].Windowed;
|
---|
494 | pPresentationParameters[i].EnableAutoDepthStencil = localParameters[i].EnableAutoDepthStencil;
|
---|
495 | pPresentationParameters[i].AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters[i].AutoDepthStencilFormat);
|
---|
496 | pPresentationParameters[i].Flags = localParameters[i].Flags;
|
---|
497 | pPresentationParameters[i].FullScreen_RefreshRateInHz = localParameters[i].FullScreen_RefreshRateInHz;
|
---|
498 | pPresentationParameters[i].PresentationInterval = localParameters[i].PresentationInterval;
|
---|
499 | }
|
---|
500 | HeapFree(GetProcessHeap(), 0, localParameters);
|
---|
501 |
|
---|
502 | /* Initialize the converted declaration array. This creates a valid pointer and when adding decls HeapReAlloc
|
---|
503 | * can be used without further checking
|
---|
504 | */
|
---|
505 | object->convertedDecls = HeapAlloc(GetProcessHeap(), 0, 0);
|
---|
506 | LeaveCriticalSection(&d3d9_cs);
|
---|
507 |
|
---|
508 | return hr;
|
---|
509 | }
|
---|
510 |
|
---|
511 | static UINT WINAPI IDirect3D9ExImpl_GetAdapterModeCountEx(IDirect3D9Ex *iface, UINT Adapter, CONST D3DDISPLAYMODEFILTER *pFilter) {
|
---|
512 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
513 | FIXME("(%p)->(%d, %p): Stub!\n", This, Adapter, pFilter);
|
---|
514 | return D3DERR_DRIVERINTERNALERROR;
|
---|
515 | }
|
---|
516 |
|
---|
517 | static HRESULT WINAPI IDirect3D9ExImpl_EnumAdapterModesEx(IDirect3D9Ex *iface, UINT Adapter, CONST D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX* pMode) {
|
---|
518 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
519 | FIXME("(%p)->(%d, %p, %p): Stub!\n", This, Adapter, pFilter, pMode);
|
---|
520 | return D3DERR_DRIVERINTERNALERROR;
|
---|
521 | }
|
---|
522 |
|
---|
523 | static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex *iface, UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation) {
|
---|
524 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
525 | FIXME("(%p)->(%d, %p, %p): Stub!\n", This, Adapter, pMode, pRotation);
|
---|
526 | return D3DERR_DRIVERINTERNALERROR;
|
---|
527 | }
|
---|
528 |
|
---|
529 | static HRESULT WINAPI IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, struct IDirect3DDevice9Ex **ppReturnedDeviceInterface) {
|
---|
530 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
531 | FIXME("(%p)->(%d, %d, %p, 0x%08x, %p, %p, %p): Stub!\n", This, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface);
|
---|
532 | *ppReturnedDeviceInterface = NULL;
|
---|
533 | return D3DERR_DRIVERINTERNALERROR;
|
---|
534 | }
|
---|
535 |
|
---|
536 | static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT Adapter, LUID *pLUID) {
|
---|
537 | IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
---|
538 | FIXME("(%p)->(%d, %p)\n", This, Adapter, pLUID);
|
---|
539 | return D3DERR_DRIVERINTERNALERROR;
|
---|
540 | }
|
---|
541 |
|
---|
542 |
|
---|
543 | const IDirect3D9ExVtbl Direct3D9_Vtbl =
|
---|
544 | {
|
---|
545 | /* IUnknown */
|
---|
546 | IDirect3D9Impl_QueryInterface,
|
---|
547 | IDirect3D9Impl_AddRef,
|
---|
548 | IDirect3D9Impl_Release,
|
---|
549 | /* IDirect3D9 */
|
---|
550 | IDirect3D9Impl_RegisterSoftwareDevice,
|
---|
551 | IDirect3D9Impl_GetAdapterCount,
|
---|
552 | IDirect3D9Impl_GetAdapterIdentifier,
|
---|
553 | IDirect3D9Impl_GetAdapterModeCount,
|
---|
554 | IDirect3D9Impl_EnumAdapterModes,
|
---|
555 | IDirect3D9Impl_GetAdapterDisplayMode,
|
---|
556 | IDirect3D9Impl_CheckDeviceType,
|
---|
557 | IDirect3D9Impl_CheckDeviceFormat,
|
---|
558 | IDirect3D9Impl_CheckDeviceMultiSampleType,
|
---|
559 | IDirect3D9Impl_CheckDepthStencilMatch,
|
---|
560 | IDirect3D9Impl_CheckDeviceFormatConversion,
|
---|
561 | IDirect3D9Impl_GetDeviceCaps,
|
---|
562 | IDirect3D9Impl_GetAdapterMonitor,
|
---|
563 | IDirect3D9Impl_CreateDevice,
|
---|
564 | /* IDirect3D9Ex */
|
---|
565 | IDirect3D9ExImpl_GetAdapterModeCountEx,
|
---|
566 | IDirect3D9ExImpl_EnumAdapterModesEx,
|
---|
567 | IDirect3D9ExImpl_GetAdapterDisplayModeEx,
|
---|
568 | IDirect3D9ExImpl_CreateDeviceEx,
|
---|
569 | IDirect3D9ExImpl_GetAdapterLUID
|
---|
570 |
|
---|
571 | };
|
---|