2 * IDirect3D9 implementation
4 * Copyright 2002 Jason Edmeades
5 * Copyright 2005 Oliver Stieber
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.
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.
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
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9
);
27 /* IDirect3D9 IUnknown parts follow: */
28 static HRESULT WINAPI
IDirect3D9Impl_QueryInterface(LPDIRECT3D9EX iface
, REFIID riid
, LPVOID
* ppobj
)
30 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
32 if (IsEqualGUID(riid
, &IID_IUnknown
)
33 || IsEqualGUID(riid
, &IID_IDirect3D9
)) {
34 IDirect3D9Ex_AddRef(iface
);
36 TRACE("Returning IDirect3D9 interface at %p\n", *ppobj
);
38 } else if(IsEqualGUID(riid
, &IID_IDirect3D9Ex
)) {
41 TRACE("Returning IDirect3D9Ex interface at %p\n", *ppobj
);
42 IDirect3D9Ex_AddRef((IDirect3D9Ex
*)*ppobj
);
44 WARN("Application asks for IDirect3D9Ex, but this instance wasn't created with Direct3DCreate9Ex\n");
45 WARN("Returning E_NOINTERFACE\n");
51 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
56 static ULONG WINAPI
IDirect3D9Impl_AddRef(LPDIRECT3D9EX iface
) {
57 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
58 ULONG ref
= InterlockedIncrement(&This
->ref
);
60 TRACE("(%p) : AddRef from %d\n", This
, ref
- 1);
65 static ULONG WINAPI
IDirect3D9Impl_Release(LPDIRECT3D9EX iface
) {
66 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
67 ULONG ref
= InterlockedDecrement(&This
->ref
);
69 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
73 IWineD3D_Release(This
->WineD3D
);
74 wined3d_mutex_unlock();
76 HeapFree(GetProcessHeap(), 0, This
);
82 /* IDirect3D9 Interface follow: */
83 static HRESULT WINAPI
IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9EX iface
, void* pInitializeFunction
) {
84 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
86 TRACE("(%p)->(%p)\n", This
, pInitializeFunction
);
89 hr
= IWineD3D_RegisterSoftwareDevice(This
->WineD3D
, pInitializeFunction
);
90 wined3d_mutex_unlock();
95 static UINT WINAPI
IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9EX iface
) {
96 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
100 wined3d_mutex_lock();
101 hr
= IWineD3D_GetAdapterCount(This
->WineD3D
);
102 wined3d_mutex_unlock();
107 static HRESULT WINAPI
IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface
, UINT Adapter
, DWORD Flags
, D3DADAPTER_IDENTIFIER9
* pIdentifier
) {
108 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
109 WINED3DADAPTER_IDENTIFIER adapter_id
;
112 adapter_id
.driver
= pIdentifier
->Driver
;
113 adapter_id
.driver_size
= sizeof(pIdentifier
->Driver
);
114 adapter_id
.description
= pIdentifier
->Description
;
115 adapter_id
.description_size
= sizeof(pIdentifier
->Description
);
116 adapter_id
.device_name
= pIdentifier
->DeviceName
;
117 adapter_id
.device_name_size
= sizeof(pIdentifier
->DeviceName
);
119 wined3d_mutex_lock();
120 hr
= IWineD3D_GetAdapterIdentifier(This
->WineD3D
, Adapter
, Flags
, &adapter_id
);
121 wined3d_mutex_unlock();
123 pIdentifier
->DriverVersion
= adapter_id
.driver_version
;
124 pIdentifier
->VendorId
= adapter_id
.vendor_id
;
125 pIdentifier
->DeviceId
= adapter_id
.device_id
;
126 pIdentifier
->SubSysId
= adapter_id
.subsystem_id
;
127 pIdentifier
->Revision
= adapter_id
.revision
;
128 memcpy(&pIdentifier
->DeviceIdentifier
, &adapter_id
.device_identifier
, sizeof(pIdentifier
->DeviceIdentifier
));
129 pIdentifier
->WHQLLevel
= adapter_id
.whql_level
;
134 static UINT WINAPI
IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface
, UINT Adapter
, D3DFORMAT Format
) {
135 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
137 TRACE("(%p)->(%d, %d\n", This
, Adapter
, Format
);
139 /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out */
140 if(Format
!= D3DFMT_X8R8G8B8
&& Format
!= D3DFMT_R5G6B5
) {
144 wined3d_mutex_lock();
145 hr
= IWineD3D_GetAdapterModeCount(This
->WineD3D
, Adapter
, wined3dformat_from_d3dformat(Format
));
146 wined3d_mutex_unlock();
151 static HRESULT WINAPI
IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface
, UINT Adapter
, D3DFORMAT Format
, UINT Mode
, D3DDISPLAYMODE
* pMode
) {
152 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
154 TRACE("(%p)->(%d, %d, %d, %p)\n", This
, Adapter
, Format
, Mode
, pMode
);
155 /* We can't pass this to WineD3D, otherwise it'll think it came from D3D8 or DDraw.
156 It's supposed to fail anyway, so no harm returning failure. */
157 if(Format
!= D3DFMT_X8R8G8B8
&& Format
!= D3DFMT_R5G6B5
)
158 return D3DERR_INVALIDCALL
;
160 wined3d_mutex_lock();
161 hr
= IWineD3D_EnumAdapterModes(This
->WineD3D
, Adapter
, wined3dformat_from_d3dformat(Format
),
162 Mode
, (WINED3DDISPLAYMODE
*) pMode
);
163 wined3d_mutex_unlock();
165 if (SUCCEEDED(hr
)) pMode
->Format
= d3dformat_from_wined3dformat(pMode
->Format
);
170 static HRESULT WINAPI
IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface
, UINT Adapter
, D3DDISPLAYMODE
* pMode
) {
171 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
174 wined3d_mutex_lock();
175 hr
= IWineD3D_GetAdapterDisplayMode(This
->WineD3D
, Adapter
, (WINED3DDISPLAYMODE
*) pMode
);
176 wined3d_mutex_unlock();
178 if (SUCCEEDED(hr
)) pMode
->Format
= d3dformat_from_wined3dformat(pMode
->Format
);
183 static HRESULT WINAPI
IDirect3D9Impl_CheckDeviceType(IDirect3D9Ex
*iface
, UINT Adapter
,
184 D3DDEVTYPE CheckType
, D3DFORMAT DisplayFormat
, D3DFORMAT BackBufferFormat
, BOOL Windowed
)
186 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
188 TRACE("(%p)->(%d, %d, %d, %d, %s\n", This
, Adapter
, CheckType
, DisplayFormat
,
189 BackBufferFormat
, Windowed
? "true" : "false");
191 wined3d_mutex_lock();
192 hr
= IWineD3D_CheckDeviceType(This
->WineD3D
, Adapter
, CheckType
, wined3dformat_from_d3dformat(DisplayFormat
),
193 wined3dformat_from_d3dformat(BackBufferFormat
), Windowed
);
194 wined3d_mutex_unlock();
199 static HRESULT WINAPI
IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex
*iface
, UINT Adapter
, D3DDEVTYPE DeviceType
,
200 D3DFORMAT AdapterFormat
, DWORD Usage
, D3DRESOURCETYPE RType
, D3DFORMAT CheckFormat
)
202 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
204 WINED3DRESOURCETYPE WineD3DRType
;
207 /* This format is nothing special and it is supported perfectly.
208 * However, ati and nvidia driver on windows do not mark this format as
209 * supported (tested with the dxCapsViewer) and pretending to
210 * support this format uncovers a bug in Battlefield 1942 (fonts are missing)
211 * So do the same as Windows drivers and pretend not to support it on dx8 and 9
213 if(CheckFormat
== D3DFMT_R8G8B8
)
215 WARN("D3DFMT_R8G8B8 is not available on windows, returning D3DERR_NOTAVAILABLE\n");
216 return D3DERR_NOTAVAILABLE
;
220 case D3DRTYPE_VERTEXBUFFER
:
221 case D3DRTYPE_INDEXBUFFER
:
222 WineD3DRType
= WINED3DRTYPE_BUFFER
;
226 WineD3DRType
= RType
;
230 wined3d_mutex_lock();
231 hr
= IWineD3D_CheckDeviceFormat(This
->WineD3D
, Adapter
, DeviceType
, wined3dformat_from_d3dformat(AdapterFormat
),
232 Usage
, WineD3DRType
, wined3dformat_from_d3dformat(CheckFormat
), SURFACE_OPENGL
);
233 wined3d_mutex_unlock();
238 static HRESULT WINAPI
IDirect3D9Impl_CheckDeviceMultiSampleType(IDirect3D9Ex
*iface
, UINT Adapter
,
239 D3DDEVTYPE DeviceType
, D3DFORMAT SurfaceFormat
, BOOL Windowed
, D3DMULTISAMPLE_TYPE MultiSampleType
,
240 DWORD
*pQualityLevels
)
242 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
246 wined3d_mutex_lock();
247 hr
= IWineD3D_CheckDeviceMultiSampleType(This
->WineD3D
, Adapter
, DeviceType
,
248 wined3dformat_from_d3dformat(SurfaceFormat
), Windowed
, MultiSampleType
, pQualityLevels
);
249 wined3d_mutex_unlock();
254 static HRESULT WINAPI
IDirect3D9Impl_CheckDepthStencilMatch(IDirect3D9Ex
*iface
, UINT Adapter
,
255 D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
, D3DFORMAT RenderTargetFormat
, D3DFORMAT DepthStencilFormat
)
257 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
261 wined3d_mutex_lock();
262 hr
= IWineD3D_CheckDepthStencilMatch(This
->WineD3D
, Adapter
, DeviceType
,
263 wined3dformat_from_d3dformat(AdapterFormat
), wined3dformat_from_d3dformat(RenderTargetFormat
),
264 wined3dformat_from_d3dformat(DepthStencilFormat
));
265 wined3d_mutex_unlock();
270 static HRESULT WINAPI
IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9EX iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT SourceFormat
, D3DFORMAT TargetFormat
) {
271 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
275 wined3d_mutex_lock();
276 hr
= IWineD3D_CheckDeviceFormatConversion(This
->WineD3D
, Adapter
, DeviceType
,
277 wined3dformat_from_d3dformat(SourceFormat
), wined3dformat_from_d3dformat(TargetFormat
));
278 wined3d_mutex_unlock();
283 void filter_caps(D3DCAPS9
* pCaps
)
286 DWORD textureFilterCaps
=
287 D3DPTFILTERCAPS_MINFPOINT
| D3DPTFILTERCAPS_MINFLINEAR
| D3DPTFILTERCAPS_MINFANISOTROPIC
|
288 D3DPTFILTERCAPS_MINFPYRAMIDALQUAD
| D3DPTFILTERCAPS_MINFGAUSSIANQUAD
|
289 D3DPTFILTERCAPS_MIPFPOINT
| D3DPTFILTERCAPS_MIPFLINEAR
| D3DPTFILTERCAPS_MAGFPOINT
|
290 D3DPTFILTERCAPS_MAGFLINEAR
|D3DPTFILTERCAPS_MAGFANISOTROPIC
|D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD
|
291 D3DPTFILTERCAPS_MAGFGAUSSIANQUAD
;
292 pCaps
->TextureFilterCaps
&= textureFilterCaps
;
293 pCaps
->CubeTextureFilterCaps
&= textureFilterCaps
;
294 pCaps
->VolumeTextureFilterCaps
&= textureFilterCaps
;
297 D3DDEVCAPS_EXECUTESYSTEMMEMORY
| D3DDEVCAPS_EXECUTEVIDEOMEMORY
| D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
298 D3DDEVCAPS_TLVERTEXVIDEOMEMORY
| D3DDEVCAPS_TEXTURESYSTEMMEMORY
| D3DDEVCAPS_TEXTUREVIDEOMEMORY
|
299 D3DDEVCAPS_DRAWPRIMTLVERTEX
| D3DDEVCAPS_CANRENDERAFTERFLIP
| D3DDEVCAPS_TEXTURENONLOCALVIDMEM
|
300 D3DDEVCAPS_DRAWPRIMITIVES2
| D3DDEVCAPS_SEPARATETEXTUREMEMORIES
|
301 D3DDEVCAPS_DRAWPRIMITIVES2EX
| D3DDEVCAPS_HWTRANSFORMANDLIGHT
| D3DDEVCAPS_CANBLTSYSTONONLOCAL
|
302 D3DDEVCAPS_HWRASTERIZATION
| D3DDEVCAPS_PUREDEVICE
| D3DDEVCAPS_QUINTICRTPATCHES
|
303 D3DDEVCAPS_RTPATCHES
| D3DDEVCAPS_RTPATCHHANDLEZERO
| D3DDEVCAPS_NPATCHES
;
306 D3DPSHADECAPS_COLORGOURAUDRGB
| D3DPSHADECAPS_SPECULARGOURAUDRGB
|
307 D3DPSHADECAPS_ALPHAGOURAUDBLEND
| D3DPSHADECAPS_FOGGOURAUD
;
310 D3DPRASTERCAPS_DITHER
| D3DPRASTERCAPS_ZTEST
| D3DPRASTERCAPS_FOGVERTEX
|
311 D3DPRASTERCAPS_FOGTABLE
| D3DPRASTERCAPS_MIPMAPLODBIAS
| D3DPRASTERCAPS_ZBUFFERLESSHSR
|
312 D3DPRASTERCAPS_FOGRANGE
| D3DPRASTERCAPS_ANISOTROPY
| D3DPRASTERCAPS_WBUFFER
|
313 D3DPRASTERCAPS_WFOG
| D3DPRASTERCAPS_ZFOG
| D3DPRASTERCAPS_COLORPERSPECTIVE
|
314 D3DPRASTERCAPS_SCISSORTEST
| D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
315 D3DPRASTERCAPS_DEPTHBIAS
| D3DPRASTERCAPS_MULTISAMPLE_TOGGLE
;
318 D3DDEVCAPS2_STREAMOFFSET
| D3DDEVCAPS2_DMAPNPATCH
| D3DDEVCAPS2_ADAPTIVETESSRTPATCH
|
319 D3DDEVCAPS2_ADAPTIVETESSNPATCH
| D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
|
320 D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH
| D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
;
323 D3DCAPS2_FULLSCREENGAMMA
| D3DCAPS2_CANCALIBRATEGAMMA
| D3DCAPS2_RESERVED
|
324 D3DCAPS2_CANMANAGERESOURCE
| D3DCAPS2_DYNAMICTEXTURES
| D3DCAPS2_CANAUTOGENMIPMAP
;
326 pCaps
->VertexProcessingCaps
&=
327 D3DVTXPCAPS_TEXGEN
| D3DVTXPCAPS_MATERIALSOURCE7
| D3DVTXPCAPS_DIRECTIONALLIGHTS
|
328 D3DVTXPCAPS_POSITIONALLIGHTS
| D3DVTXPCAPS_LOCALVIEWER
| D3DVTXPCAPS_TWEENING
|
329 D3DVTXPCAPS_TEXGEN_SPHEREMAP
| D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER
;
331 pCaps
->TextureCaps
&=
332 D3DPTEXTURECAPS_PERSPECTIVE
| D3DPTEXTURECAPS_POW2
| D3DPTEXTURECAPS_ALPHA
|
333 D3DPTEXTURECAPS_SQUAREONLY
| D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE
|
334 D3DPTEXTURECAPS_ALPHAPALETTE
| D3DPTEXTURECAPS_NONPOW2CONDITIONAL
|
335 D3DPTEXTURECAPS_PROJECTED
| D3DPTEXTURECAPS_CUBEMAP
| D3DPTEXTURECAPS_VOLUMEMAP
|
336 D3DPTEXTURECAPS_MIPMAP
| D3DPTEXTURECAPS_MIPVOLUMEMAP
| D3DPTEXTURECAPS_MIPCUBEMAP
|
337 D3DPTEXTURECAPS_CUBEMAP_POW2
| D3DPTEXTURECAPS_VOLUMEMAP_POW2
| D3DPTEXTURECAPS_NOPROJECTEDBUMPENV
;
339 pCaps
->MaxVertexShaderConst
= min(D3D9_MAX_VERTEX_SHADER_CONSTANTF
, pCaps
->MaxVertexShaderConst
);
340 pCaps
->NumSimultaneousRTs
= min(D3D9_MAX_SIMULTANEOUS_RENDERTARGETS
, pCaps
->NumSimultaneousRTs
);
343 static HRESULT WINAPI
IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, D3DCAPS9
* pCaps
) {
344 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
345 HRESULT hrc
= D3D_OK
;
346 WINED3DCAPS
*pWineCaps
;
348 TRACE("(%p) Relay %d %u %p\n", This
, Adapter
, DeviceType
, pCaps
);
351 return D3DERR_INVALIDCALL
;
353 pWineCaps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINED3DCAPS
));
354 if(pWineCaps
== NULL
){
355 return D3DERR_INVALIDCALL
; /*well this is what MSDN says to return*/
357 memset(pCaps
, 0, sizeof(*pCaps
));
359 wined3d_mutex_lock();
360 hrc
= IWineD3D_GetDeviceCaps(This
->WineD3D
, Adapter
, DeviceType
, pWineCaps
);
361 wined3d_mutex_unlock();
363 WINECAPSTOD3D9CAPS(pCaps
, pWineCaps
)
364 HeapFree(GetProcessHeap(), 0, pWineCaps
);
366 /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
367 pCaps
->DevCaps2
|= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
;
371 TRACE("(%p) returning %p\n", This
, pCaps
);
375 static HMONITOR WINAPI
IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface
, UINT Adapter
) {
376 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
380 wined3d_mutex_lock();
381 ret
= IWineD3D_GetAdapterMonitor(This
->WineD3D
, Adapter
);
382 wined3d_mutex_unlock();
387 ULONG WINAPI
D3D9CB_DestroySwapChain(IWineD3DSwapChain
*pSwapChain
) {
388 IDirect3DSwapChain9Impl
* swapChainParent
;
389 TRACE("(%p) call back\n", pSwapChain
);
391 IWineD3DSwapChain_GetParent(pSwapChain
,(IUnknown
**) &swapChainParent
);
392 swapChainParent
->isImplicit
= FALSE
;
393 /* Swap chain had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
394 return IDirect3DSwapChain9_Release((IDirect3DSwapChain9
*) swapChainParent
);
397 static HRESULT WINAPI DECLSPEC_HOTPATCH
IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface
, UINT Adapter
, D3DDEVTYPE DeviceType
,
398 HWND hFocusWindow
, DWORD BehaviourFlags
,
399 D3DPRESENT_PARAMETERS
* pPresentationParameters
,
400 IDirect3DDevice9
** ppReturnedDeviceInterface
) {
402 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
403 IDirect3DDevice9Impl
*object
= NULL
;
404 WINED3DPRESENT_PARAMETERS
*localParameters
;
407 TRACE("(%p) Relay\n", This
);
409 /* Check the validity range of the adapter parameter */
410 if (Adapter
>= IDirect3D9Impl_GetAdapterCount(iface
)) {
411 *ppReturnedDeviceInterface
= NULL
;
412 return D3DERR_INVALIDCALL
;
415 /* Allocate the storage for the device object */
416 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DDevice9Impl
));
417 if (NULL
== object
) {
418 FIXME("Allocation of memory failed\n");
419 *ppReturnedDeviceInterface
= NULL
;
420 return D3DERR_OUTOFVIDEOMEMORY
;
423 object
->lpVtbl
= &Direct3DDevice9_Vtbl
;
424 object
->device_parent_vtbl
= &d3d9_wined3d_device_parent_vtbl
;
426 *ppReturnedDeviceInterface
= (IDirect3DDevice9
*)object
;
428 /* Allocate an associated WineD3DDevice object */
429 wined3d_mutex_lock();
430 hr
= IWineD3D_CreateDevice(This
->WineD3D
, Adapter
, DeviceType
, hFocusWindow
, BehaviourFlags
,
431 (IUnknown
*)object
, (IWineD3DDeviceParent
*)&object
->device_parent_vtbl
, &object
->WineD3DDevice
);
433 HeapFree(GetProcessHeap(), 0, object
);
434 *ppReturnedDeviceInterface
= NULL
;
435 wined3d_mutex_unlock();
440 TRACE("(%p) : Created Device %p\n", This
, object
);
442 if (BehaviourFlags
& D3DCREATE_ADAPTERGROUP_DEVICE
)
446 IWineD3D_GetDeviceCaps(This
->WineD3D
, Adapter
, DeviceType
, &caps
);
447 count
= caps
.NumberOfAdaptersInGroup
;
450 if(BehaviourFlags
& D3DCREATE_MULTITHREADED
) {
451 IWineD3DDevice_SetMultithreaded(object
->WineD3DDevice
);
454 localParameters
= HeapAlloc(GetProcessHeap(), 0, sizeof(*localParameters
) * count
);
455 for (i
= 0; i
< count
; ++i
)
457 localParameters
[i
].BackBufferWidth
= pPresentationParameters
[i
].BackBufferWidth
;
458 localParameters
[i
].BackBufferHeight
= pPresentationParameters
[i
].BackBufferHeight
;
459 localParameters
[i
].BackBufferFormat
= wined3dformat_from_d3dformat(pPresentationParameters
[i
].BackBufferFormat
);
460 localParameters
[i
].BackBufferCount
= pPresentationParameters
[i
].BackBufferCount
;
461 localParameters
[i
].MultiSampleType
= pPresentationParameters
[i
].MultiSampleType
;
462 localParameters
[i
].MultiSampleQuality
= pPresentationParameters
[i
].MultiSampleQuality
;
463 localParameters
[i
].SwapEffect
= pPresentationParameters
[i
].SwapEffect
;
464 localParameters
[i
].hDeviceWindow
= pPresentationParameters
[i
].hDeviceWindow
;
465 localParameters
[i
].Windowed
= pPresentationParameters
[i
].Windowed
;
466 localParameters
[i
].EnableAutoDepthStencil
= pPresentationParameters
[i
].EnableAutoDepthStencil
;
467 localParameters
[i
].AutoDepthStencilFormat
= wined3dformat_from_d3dformat(pPresentationParameters
[i
].AutoDepthStencilFormat
);
468 localParameters
[i
].Flags
= pPresentationParameters
[i
].Flags
;
469 localParameters
[i
].FullScreen_RefreshRateInHz
= pPresentationParameters
[i
].FullScreen_RefreshRateInHz
;
470 localParameters
[i
].PresentationInterval
= pPresentationParameters
[i
].PresentationInterval
;
471 localParameters
[i
].AutoRestoreDisplayMode
= TRUE
;
474 hr
= IWineD3DDevice_Init3D(object
->WineD3DDevice
, localParameters
);
476 FIXME("(%p) D3D Initialization failed for WineD3DDevice %p\n", This
, object
->WineD3DDevice
);
477 HeapFree(GetProcessHeap(), 0, object
);
478 *ppReturnedDeviceInterface
= NULL
;
481 for (i
= 0; i
< count
; ++i
)
483 pPresentationParameters
[i
].BackBufferWidth
= localParameters
[i
].BackBufferWidth
;
484 pPresentationParameters
[i
].BackBufferHeight
= localParameters
[i
].BackBufferHeight
;
485 pPresentationParameters
[i
].BackBufferFormat
= d3dformat_from_wined3dformat(localParameters
[i
].BackBufferFormat
);
486 pPresentationParameters
[i
].BackBufferCount
= localParameters
[i
].BackBufferCount
;
487 pPresentationParameters
[i
].MultiSampleType
= localParameters
[i
].MultiSampleType
;
488 pPresentationParameters
[i
].MultiSampleQuality
= localParameters
[i
].MultiSampleQuality
;
489 pPresentationParameters
[i
].SwapEffect
= localParameters
[i
].SwapEffect
;
490 pPresentationParameters
[i
].hDeviceWindow
= localParameters
[i
].hDeviceWindow
;
491 pPresentationParameters
[i
].Windowed
= localParameters
[i
].Windowed
;
492 pPresentationParameters
[i
].EnableAutoDepthStencil
= localParameters
[i
].EnableAutoDepthStencil
;
493 pPresentationParameters
[i
].AutoDepthStencilFormat
= d3dformat_from_wined3dformat(localParameters
[i
].AutoDepthStencilFormat
);
494 pPresentationParameters
[i
].Flags
= localParameters
[i
].Flags
;
495 pPresentationParameters
[i
].FullScreen_RefreshRateInHz
= localParameters
[i
].FullScreen_RefreshRateInHz
;
496 pPresentationParameters
[i
].PresentationInterval
= localParameters
[i
].PresentationInterval
;
498 HeapFree(GetProcessHeap(), 0, localParameters
);
500 /* Initialize the converted declaration array. This creates a valid pointer and when adding decls HeapReAlloc
501 * can be used without further checking
503 object
->convertedDecls
= HeapAlloc(GetProcessHeap(), 0, 0);
504 wined3d_mutex_unlock();
509 static UINT WINAPI
IDirect3D9ExImpl_GetAdapterModeCountEx(IDirect3D9Ex
*iface
, UINT Adapter
, CONST D3DDISPLAYMODEFILTER
*pFilter
) {
510 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
511 FIXME("(%p)->(%d, %p): Stub!\n", This
, Adapter
, pFilter
);
512 return D3DERR_DRIVERINTERNALERROR
;
515 static HRESULT WINAPI
IDirect3D9ExImpl_EnumAdapterModesEx(IDirect3D9Ex
*iface
, UINT Adapter
, CONST D3DDISPLAYMODEFILTER
*pFilter
, UINT Mode
, D3DDISPLAYMODEEX
* pMode
) {
516 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
517 FIXME("(%p)->(%d, %p, %p): Stub!\n", This
, Adapter
, pFilter
, pMode
);
518 return D3DERR_DRIVERINTERNALERROR
;
521 static HRESULT WINAPI
IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex
*iface
, UINT Adapter
, D3DDISPLAYMODEEX
*pMode
, D3DDISPLAYROTATION
*pRotation
) {
522 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
523 FIXME("(%p)->(%d, %p, %p): Stub!\n", This
, Adapter
, pMode
, pRotation
);
524 return D3DERR_DRIVERINTERNALERROR
;
527 static HRESULT WINAPI DECLSPEC_HOTPATCH
IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex
*iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, HWND hFocusWindow
, DWORD BehaviorFlags
, D3DPRESENT_PARAMETERS
* pPresentationParameters
, D3DDISPLAYMODEEX
* pFullscreenDisplayMode
, struct IDirect3DDevice9Ex
**ppReturnedDeviceInterface
) {
528 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
529 FIXME("(%p)->(%d, %d, %p, 0x%08x, %p, %p, %p): Stub!\n", This
, Adapter
, DeviceType
, hFocusWindow
, BehaviorFlags
, pPresentationParameters
, pFullscreenDisplayMode
, ppReturnedDeviceInterface
);
530 *ppReturnedDeviceInterface
= NULL
;
531 return D3DERR_DRIVERINTERNALERROR
;
534 static HRESULT WINAPI
IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex
*iface
, UINT Adapter
, LUID
*pLUID
) {
535 IDirect3D9Impl
*This
= (IDirect3D9Impl
*)iface
;
536 FIXME("(%p)->(%d, %p)\n", This
, Adapter
, pLUID
);
537 return D3DERR_DRIVERINTERNALERROR
;
541 const IDirect3D9ExVtbl Direct3D9_Vtbl
=
544 IDirect3D9Impl_QueryInterface
,
545 IDirect3D9Impl_AddRef
,
546 IDirect3D9Impl_Release
,
548 IDirect3D9Impl_RegisterSoftwareDevice
,
549 IDirect3D9Impl_GetAdapterCount
,
550 IDirect3D9Impl_GetAdapterIdentifier
,
551 IDirect3D9Impl_GetAdapterModeCount
,
552 IDirect3D9Impl_EnumAdapterModes
,
553 IDirect3D9Impl_GetAdapterDisplayMode
,
554 IDirect3D9Impl_CheckDeviceType
,
555 IDirect3D9Impl_CheckDeviceFormat
,
556 IDirect3D9Impl_CheckDeviceMultiSampleType
,
557 IDirect3D9Impl_CheckDepthStencilMatch
,
558 IDirect3D9Impl_CheckDeviceFormatConversion
,
559 IDirect3D9Impl_GetDeviceCaps
,
560 IDirect3D9Impl_GetAdapterMonitor
,
561 IDirect3D9Impl_CreateDevice
,
563 IDirect3D9ExImpl_GetAdapterModeCountEx
,
564 IDirect3D9ExImpl_EnumAdapterModesEx
,
565 IDirect3D9ExImpl_GetAdapterDisplayModeEx
,
566 IDirect3D9ExImpl_CreateDeviceEx
,
567 IDirect3D9ExImpl_GetAdapterLUID