VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/directx.c@ 30585

Last change on this file since 30585 was 25949, checked in by vboxsync, 15 years ago

crOpenGL: update to wine 1.1.36 and disable unnecessary fbo state poll

  • Property svn:eol-style set to native
File size: 21.0 KB
Line 
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
34WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
35
36/* IDirect3D9 IUnknown parts follow: */
37static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9EX iface, REFIID riid, LPVOID* ppobj)
38{
39 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
40
41 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
42
43 if (IsEqualGUID(riid, &IID_IUnknown)
44 || IsEqualGUID(riid, &IID_IDirect3D9)) {
45 IDirect3D9Ex_AddRef(iface);
46 *ppobj = This;
47 TRACE("Returning IDirect3D9 interface at %p\n", *ppobj);
48 return S_OK;
49 } else if(IsEqualGUID(riid, &IID_IDirect3D9Ex)) {
50 if(This->extended) {
51 *ppobj = This;
52 TRACE("Returning IDirect3D9Ex interface at %p\n", *ppobj);
53 IDirect3D9Ex_AddRef((IDirect3D9Ex *)*ppobj);
54 } else {
55 WARN("Application asks for IDirect3D9Ex, but this instance wasn't created with Direct3DCreate9Ex\n");
56 WARN("Returning E_NOINTERFACE\n");
57 *ppobj = NULL;
58 return E_NOINTERFACE;
59 }
60 }
61
62 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
63 *ppobj = NULL;
64 return E_NOINTERFACE;
65}
66
67static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9EX iface) {
68 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
69 ULONG ref = InterlockedIncrement(&This->ref);
70
71 TRACE("%p increasing refcount to %u.\n", iface, ref);
72
73 return ref;
74}
75
76static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9EX iface) {
77 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
78 ULONG ref = InterlockedDecrement(&This->ref);
79
80 TRACE("%p decreasing refcount to %u.\n", iface, ref);
81
82 if (ref == 0) {
83 wined3d_mutex_lock();
84 IWineD3D_Release(This->WineD3D);
85 wined3d_mutex_unlock();
86
87 HeapFree(GetProcessHeap(), 0, This);
88 }
89
90 return ref;
91}
92
93/* IDirect3D9 Interface follow: */
94static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9EX iface, void* pInitializeFunction) {
95 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
96 HRESULT hr;
97
98 TRACE("iface %p, init_function %p.\n", iface, pInitializeFunction);
99
100 wined3d_mutex_lock();
101 hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
102 wined3d_mutex_unlock();
103
104 return hr;
105}
106
107static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9EX iface) {
108 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
109 HRESULT hr;
110
111 TRACE("iface %p.\n", iface);
112
113 wined3d_mutex_lock();
114 hr = IWineD3D_GetAdapterCount(This->WineD3D);
115 wined3d_mutex_unlock();
116
117 return hr;
118}
119
120static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
121 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
122 WINED3DADAPTER_IDENTIFIER adapter_id;
123 HRESULT hr;
124
125 TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n",
126 iface, Adapter, Flags, pIdentifier);
127
128 adapter_id.driver = pIdentifier->Driver;
129 adapter_id.driver_size = sizeof(pIdentifier->Driver);
130 adapter_id.description = pIdentifier->Description;
131 adapter_id.description_size = sizeof(pIdentifier->Description);
132 adapter_id.device_name = pIdentifier->DeviceName;
133 adapter_id.device_name_size = sizeof(pIdentifier->DeviceName);
134
135 wined3d_mutex_lock();
136 hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
137 wined3d_mutex_unlock();
138
139 pIdentifier->DriverVersion = adapter_id.driver_version;
140 pIdentifier->VendorId = adapter_id.vendor_id;
141 pIdentifier->DeviceId = adapter_id.device_id;
142 pIdentifier->SubSysId = adapter_id.subsystem_id;
143 pIdentifier->Revision = adapter_id.revision;
144 memcpy(&pIdentifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(pIdentifier->DeviceIdentifier));
145 pIdentifier->WHQLLevel = adapter_id.whql_level;
146
147 return hr;
148}
149
150static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format) {
151 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
152 HRESULT hr;
153
154 TRACE("iface %p, adapter %u, format %#x.\n", iface, Adapter, Format);
155
156 /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out */
157 if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5) {
158 return 0;
159 }
160
161 wined3d_mutex_lock();
162 hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format));
163 wined3d_mutex_unlock();
164
165 return hr;
166}
167
168static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
169 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
170 HRESULT hr;
171
172 TRACE("iface %p, adapter %u, format %#x, mode_idx %u, mode %p.\n",
173 iface, Adapter, Format, Mode, pMode);
174
175 /* We can't pass this to WineD3D, otherwise it'll think it came from D3D8 or DDraw.
176 It's supposed to fail anyway, so no harm returning failure. */
177 if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5)
178 return D3DERR_INVALIDCALL;
179
180 wined3d_mutex_lock();
181 hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format),
182 Mode, (WINED3DDISPLAYMODE *) pMode);
183 wined3d_mutex_unlock();
184
185 if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
186
187 return hr;
188}
189
190static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
191 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
192 HRESULT hr;
193
194 TRACE("iface %p, adapter %u, mode %p.\n", iface, Adapter, pMode);
195
196 wined3d_mutex_lock();
197 hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
198 wined3d_mutex_unlock();
199
200 if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
201
202 return hr;
203}
204
205static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(IDirect3D9Ex *iface, UINT Adapter,
206 D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
207{
208 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
209 HRESULT hr;
210
211 TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
212 iface, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed);
213
214 wined3d_mutex_lock();
215 hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
216 wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
217 wined3d_mutex_unlock();
218
219 return hr;
220}
221
222static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT Adapter, D3DDEVTYPE DeviceType,
223 D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
224{
225 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
226 HRESULT hr;
227 WINED3DRESOURCETYPE WineD3DRType;
228
229 TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
230 iface, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
231
232 /* This format is nothing special and it is supported perfectly.
233 * However, ati and nvidia driver on windows do not mark this format as
234 * supported (tested with the dxCapsViewer) and pretending to
235 * support this format uncovers a bug in Battlefield 1942 (fonts are missing)
236 * So do the same as Windows drivers and pretend not to support it on dx8 and 9
237 */
238 if(CheckFormat == D3DFMT_R8G8B8)
239 {
240 WARN("D3DFMT_R8G8B8 is not available on windows, returning D3DERR_NOTAVAILABLE\n");
241 return D3DERR_NOTAVAILABLE;
242 }
243
244 switch(RType) {
245 case D3DRTYPE_VERTEXBUFFER:
246 case D3DRTYPE_INDEXBUFFER:
247 WineD3DRType = WINED3DRTYPE_BUFFER;
248 break;
249
250 default:
251 WineD3DRType = RType;
252 break;
253 }
254
255 wined3d_mutex_lock();
256 hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
257 Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
258 wined3d_mutex_unlock();
259
260 return hr;
261}
262
263static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(IDirect3D9Ex *iface, UINT Adapter,
264 D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType,
265 DWORD *pQualityLevels)
266{
267 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
268 HRESULT hr;
269
270 TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x, levels %p.\n",
271 iface, Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels);
272
273 wined3d_mutex_lock();
274 hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
275 wined3dformat_from_d3dformat(SurfaceFormat), Windowed, MultiSampleType, pQualityLevels);
276 wined3d_mutex_unlock();
277
278 return hr;
279}
280
281static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(IDirect3D9Ex *iface, UINT Adapter,
282 D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
283{
284 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
285 HRESULT hr;
286
287 TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
288 iface, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
289
290 wined3d_mutex_lock();
291 hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
292 wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
293 wined3dformat_from_d3dformat(DepthStencilFormat));
294 wined3d_mutex_unlock();
295
296 return hr;
297}
298
299static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
300 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
301 HRESULT hr;
302
303 TRACE("iface %p, adapter %u, device_type %#x, src_format %#x, dst_format %#x.\n",
304 iface, Adapter, DeviceType, SourceFormat, TargetFormat);
305
306 wined3d_mutex_lock();
307 hr = IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType,
308 wined3dformat_from_d3dformat(SourceFormat), wined3dformat_from_d3dformat(TargetFormat));
309 wined3d_mutex_unlock();
310
311 return hr;
312}
313
314void filter_caps(D3DCAPS9* pCaps)
315{
316
317 DWORD textureFilterCaps =
318 D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR | D3DPTFILTERCAPS_MINFANISOTROPIC |
319 D3DPTFILTERCAPS_MINFPYRAMIDALQUAD | D3DPTFILTERCAPS_MINFGAUSSIANQUAD|
320 D3DPTFILTERCAPS_MIPFPOINT | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT |
321 D3DPTFILTERCAPS_MAGFLINEAR |D3DPTFILTERCAPS_MAGFANISOTROPIC|D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD|
322 D3DPTFILTERCAPS_MAGFGAUSSIANQUAD;
323 pCaps->TextureFilterCaps &= textureFilterCaps;
324 pCaps->CubeTextureFilterCaps &= textureFilterCaps;
325 pCaps->VolumeTextureFilterCaps &= textureFilterCaps;
326
327 pCaps->DevCaps &=
328 D3DDEVCAPS_EXECUTESYSTEMMEMORY | D3DDEVCAPS_EXECUTEVIDEOMEMORY | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY |
329 D3DDEVCAPS_TLVERTEXVIDEOMEMORY | D3DDEVCAPS_TEXTURESYSTEMMEMORY| D3DDEVCAPS_TEXTUREVIDEOMEMORY |
330 D3DDEVCAPS_DRAWPRIMTLVERTEX | D3DDEVCAPS_CANRENDERAFTERFLIP | D3DDEVCAPS_TEXTURENONLOCALVIDMEM|
331 D3DDEVCAPS_DRAWPRIMITIVES2 | D3DDEVCAPS_SEPARATETEXTUREMEMORIES |
332 D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWTRANSFORMANDLIGHT| D3DDEVCAPS_CANBLTSYSTONONLOCAL |
333 D3DDEVCAPS_HWRASTERIZATION | D3DDEVCAPS_PUREDEVICE | D3DDEVCAPS_QUINTICRTPATCHES |
334 D3DDEVCAPS_RTPATCHES | D3DDEVCAPS_RTPATCHHANDLEZERO | D3DDEVCAPS_NPATCHES;
335
336 pCaps->ShadeCaps &=
337 D3DPSHADECAPS_COLORGOURAUDRGB | D3DPSHADECAPS_SPECULARGOURAUDRGB |
338 D3DPSHADECAPS_ALPHAGOURAUDBLEND | D3DPSHADECAPS_FOGGOURAUD;
339
340 pCaps->RasterCaps &=
341 D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_ZTEST | D3DPRASTERCAPS_FOGVERTEX |
342 D3DPRASTERCAPS_FOGTABLE | D3DPRASTERCAPS_MIPMAPLODBIAS | D3DPRASTERCAPS_ZBUFFERLESSHSR |
343 D3DPRASTERCAPS_FOGRANGE | D3DPRASTERCAPS_ANISOTROPY | D3DPRASTERCAPS_WBUFFER |
344 D3DPRASTERCAPS_WFOG | D3DPRASTERCAPS_ZFOG | D3DPRASTERCAPS_COLORPERSPECTIVE |
345 D3DPRASTERCAPS_SCISSORTEST | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
346 D3DPRASTERCAPS_DEPTHBIAS | D3DPRASTERCAPS_MULTISAMPLE_TOGGLE;
347
348 pCaps->DevCaps2 &=
349 D3DDEVCAPS2_STREAMOFFSET | D3DDEVCAPS2_DMAPNPATCH | D3DDEVCAPS2_ADAPTIVETESSRTPATCH |
350 D3DDEVCAPS2_ADAPTIVETESSNPATCH | D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES |
351 D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH| D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
352
353 pCaps->Caps2 &=
354 D3DCAPS2_FULLSCREENGAMMA | D3DCAPS2_CANCALIBRATEGAMMA | D3DCAPS2_RESERVED |
355 D3DCAPS2_CANMANAGERESOURCE | D3DCAPS2_DYNAMICTEXTURES | D3DCAPS2_CANAUTOGENMIPMAP;
356
357 pCaps->VertexProcessingCaps &=
358 D3DVTXPCAPS_TEXGEN | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_DIRECTIONALLIGHTS |
359 D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_LOCALVIEWER | D3DVTXPCAPS_TWEENING |
360 D3DVTXPCAPS_TEXGEN_SPHEREMAP | D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER;
361
362 pCaps->TextureCaps &=
363 D3DPTEXTURECAPS_PERSPECTIVE | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_ALPHA |
364 D3DPTEXTURECAPS_SQUAREONLY | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |
365 D3DPTEXTURECAPS_ALPHAPALETTE | D3DPTEXTURECAPS_NONPOW2CONDITIONAL |
366 D3DPTEXTURECAPS_PROJECTED | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_VOLUMEMAP |
367 D3DPTEXTURECAPS_MIPMAP | D3DPTEXTURECAPS_MIPVOLUMEMAP | D3DPTEXTURECAPS_MIPCUBEMAP |
368 D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_VOLUMEMAP_POW2| D3DPTEXTURECAPS_NOPROJECTEDBUMPENV;
369
370 pCaps->MaxVertexShaderConst = min(D3D9_MAX_VERTEX_SHADER_CONSTANTF, pCaps->MaxVertexShaderConst);
371 pCaps->NumSimultaneousRTs = min(D3D9_MAX_SIMULTANEOUS_RENDERTARGETS, pCaps->NumSimultaneousRTs);
372}
373
374static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
375 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
376 HRESULT hrc = D3D_OK;
377 WINED3DCAPS *pWineCaps;
378
379 TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, Adapter, DeviceType, pCaps);
380
381 if(NULL == pCaps){
382 return D3DERR_INVALIDCALL;
383 }
384 pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
385 if(pWineCaps == NULL){
386 return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
387 }
388 memset(pCaps, 0, sizeof(*pCaps));
389
390 wined3d_mutex_lock();
391 hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
392 wined3d_mutex_unlock();
393
394 WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
395 HeapFree(GetProcessHeap(), 0, pWineCaps);
396
397 /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
398 pCaps->DevCaps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
399
400 filter_caps(pCaps);
401
402 TRACE("(%p) returning %p\n", This, pCaps);
403 return hrc;
404}
405
406static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UINT Adapter) {
407 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
408 HMONITOR ret;
409
410 TRACE("iface %p, adapter %u.\n", iface, Adapter);
411
412 wined3d_mutex_lock();
413 ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
414 wined3d_mutex_unlock();
415
416 return ret;
417}
418
419static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9Impl_CreateDevice(IDirect3D9Ex *iface, UINT adapter,
420 D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
421 IDirect3DDevice9 **device)
422{
423 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
424 IDirect3DDevice9Impl *object;
425 HRESULT hr;
426
427 TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n",
428 iface, adapter, device_type, focus_window, flags, parameters, device);
429
430 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
431 if (!object)
432 {
433 ERR("Failed to allocate device memory.\n");
434 return E_OUTOFMEMORY;
435 }
436
437 hr = device_init(object, This->WineD3D, adapter, device_type, focus_window, flags, parameters);
438 if (FAILED(hr))
439 {
440 WARN("Failed to initialize device, hr %#x.\n", hr);
441 HeapFree(GetProcessHeap(), 0, object);
442 return hr;
443 }
444
445 TRACE("Created device %p.\n", object);
446 *device = (IDirect3DDevice9 *)object;
447
448 return D3D_OK;
449}
450
451static UINT WINAPI IDirect3D9ExImpl_GetAdapterModeCountEx(IDirect3D9Ex *iface,
452 UINT adapter, const D3DDISPLAYMODEFILTER *filter)
453{
454 FIXME("iface %p, adapter %u, filter %p stub!\n", iface, adapter, filter);
455
456 return D3DERR_DRIVERINTERNALERROR;
457}
458
459static HRESULT WINAPI IDirect3D9ExImpl_EnumAdapterModesEx(IDirect3D9Ex *iface,
460 UINT adapter, const D3DDISPLAYMODEFILTER *filter, UINT mode_idx, D3DDISPLAYMODEEX *mode)
461{
462 FIXME("iface %p, adapter %u, filter %p, mode_idx %u, mode %p stub!\n",
463 iface, adapter, filter, mode_idx, mode);
464
465 return D3DERR_DRIVERINTERNALERROR;
466}
467
468static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex *iface,
469 UINT adapter, D3DDISPLAYMODEEX *mode, D3DDISPLAYROTATION *rotation)
470{
471 FIXME("iface %p, adapter %u, mode %p, rotation %p stub!\n",
472 iface, adapter, mode, rotation);
473
474 return D3DERR_DRIVERINTERNALERROR;
475}
476
477static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface,
478 UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags,
479 D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode, IDirect3DDevice9Ex **device)
480{
481 FIXME("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x,\n"
482 "parameters %p, mode %p, device %p stub!\n",
483 iface, adapter, device_type, focus_window, flags,
484 parameters, mode, device);
485
486 *device = NULL;
487
488 return D3DERR_DRIVERINTERNALERROR;
489}
490
491static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUID *luid)
492{
493 IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
494 WINED3DADAPTER_IDENTIFIER adapter_id;
495 HRESULT hr;
496
497 TRACE("iface %p, adapter %u, luid %p.\n", iface, adapter, luid);
498
499 adapter_id.driver_size = 0;
500 adapter_id.description_size = 0;
501 adapter_id.device_name_size = 0;
502
503 wined3d_mutex_lock();
504 hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, adapter, 0, &adapter_id);
505 wined3d_mutex_unlock();
506
507 memcpy(luid, &adapter_id.adapter_luid, sizeof(*luid));
508
509 return hr;
510}
511
512
513const IDirect3D9ExVtbl Direct3D9_Vtbl =
514{
515 /* IUnknown */
516 IDirect3D9Impl_QueryInterface,
517 IDirect3D9Impl_AddRef,
518 IDirect3D9Impl_Release,
519 /* IDirect3D9 */
520 IDirect3D9Impl_RegisterSoftwareDevice,
521 IDirect3D9Impl_GetAdapterCount,
522 IDirect3D9Impl_GetAdapterIdentifier,
523 IDirect3D9Impl_GetAdapterModeCount,
524 IDirect3D9Impl_EnumAdapterModes,
525 IDirect3D9Impl_GetAdapterDisplayMode,
526 IDirect3D9Impl_CheckDeviceType,
527 IDirect3D9Impl_CheckDeviceFormat,
528 IDirect3D9Impl_CheckDeviceMultiSampleType,
529 IDirect3D9Impl_CheckDepthStencilMatch,
530 IDirect3D9Impl_CheckDeviceFormatConversion,
531 IDirect3D9Impl_GetDeviceCaps,
532 IDirect3D9Impl_GetAdapterMonitor,
533 IDirect3D9Impl_CreateDevice,
534 /* IDirect3D9Ex */
535 IDirect3D9ExImpl_GetAdapterModeCountEx,
536 IDirect3D9ExImpl_EnumAdapterModesEx,
537 IDirect3D9ExImpl_GetAdapterDisplayModeEx,
538 IDirect3D9ExImpl_CreateDeviceEx,
539 IDirect3D9ExImpl_GetAdapterLUID
540
541};
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette