2 * IDirect3D8 implementation
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
36 #include "d3d8_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(d3d8
);
40 /* IDirect3D IUnknown parts follow: */
41 static HRESULT WINAPI
IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface
, REFIID riid
,LPVOID
*ppobj
)
43 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
45 if (IsEqualGUID(riid
, &IID_IUnknown
)
46 || IsEqualGUID(riid
, &IID_IDirect3D8
)) {
47 IUnknown_AddRef(iface
);
52 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
),ppobj
);
57 static ULONG WINAPI
IDirect3D8Impl_AddRef(LPDIRECT3D8 iface
) {
58 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
59 ULONG ref
= InterlockedIncrement(&This
->ref
);
61 TRACE("(%p) : AddRef from %d\n", This
, ref
- 1);
66 static ULONG WINAPI
IDirect3D8Impl_Release(LPDIRECT3D8 iface
) {
67 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
68 ULONG ref
= InterlockedDecrement(&This
->ref
);
70 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
73 TRACE("Releasing wined3d %p\n", This
->WineD3D
);
74 IWineD3D_Release(This
->WineD3D
);
75 HeapFree(GetProcessHeap(), 0, This
);
81 /* IDirect3D8 Interface follow: */
82 static HRESULT WINAPI
IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface
, void* pInitializeFunction
) {
83 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
85 TRACE("(%p)->(%p)\n", This
, pInitializeFunction
);
87 EnterCriticalSection(&d3d8_cs
);
88 hr
= IWineD3D_RegisterSoftwareDevice(This
->WineD3D
, pInitializeFunction
);
89 LeaveCriticalSection(&d3d8_cs
);
93 static UINT WINAPI
IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface
) {
94 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
96 TRACE("(%p)\n", This
);
98 EnterCriticalSection(&d3d8_cs
);
99 hr
= IWineD3D_GetAdapterCount(This
->WineD3D
);
100 LeaveCriticalSection(&d3d8_cs
);
104 static HRESULT WINAPI
IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface
,
105 UINT Adapter
, DWORD Flags
, D3DADAPTER_IDENTIFIER8
* pIdentifier
) {
106 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
107 WINED3DADAPTER_IDENTIFIER adapter_id
;
110 TRACE("(%p)->(%d,%08x, %p\n", This
, Adapter
, Flags
, pIdentifier
);
111 EnterCriticalSection(&d3d8_cs
);
112 /* dx8 and dx9 have different structures to be filled in, with incompatible
113 layouts so pass in pointers to the places to be filled via an internal
115 adapter_id
.Driver
= pIdentifier
->Driver
;
116 adapter_id
.Description
= pIdentifier
->Description
;
117 adapter_id
.DeviceName
= NULL
; /* d3d9 only */
118 adapter_id
.DriverVersion
= &pIdentifier
->DriverVersion
;
119 adapter_id
.VendorId
= &pIdentifier
->VendorId
;
120 adapter_id
.DeviceId
= &pIdentifier
->DeviceId
;
121 adapter_id
.SubSysId
= &pIdentifier
->SubSysId
;
122 adapter_id
.Revision
= &pIdentifier
->Revision
;
123 adapter_id
.DeviceIdentifier
= &pIdentifier
->DeviceIdentifier
;
124 adapter_id
.WHQLLevel
= &pIdentifier
->WHQLLevel
;
126 hr
= IWineD3D_GetAdapterIdentifier(This
->WineD3D
, Adapter
, Flags
, &adapter_id
);
127 LeaveCriticalSection(&d3d8_cs
);
131 static UINT WINAPI
IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface
,UINT Adapter
) {
132 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
134 TRACE("(%p)->(%d)\n", This
, Adapter
);
136 EnterCriticalSection(&d3d8_cs
);
137 hr
= IWineD3D_GetAdapterModeCount(This
->WineD3D
, Adapter
, 0 /* format */);
138 LeaveCriticalSection(&d3d8_cs
);
142 static HRESULT WINAPI
IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface
, UINT Adapter
, UINT Mode
, D3DDISPLAYMODE
* pMode
) {
143 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
145 TRACE("(%p)->(%d, %d, %p)\n", This
, Adapter
, Mode
, pMode
);
147 EnterCriticalSection(&d3d8_cs
);
148 hr
= IWineD3D_EnumAdapterModes(This
->WineD3D
, Adapter
, WINED3DFMT_UNKNOWN
, Mode
, (WINED3DDISPLAYMODE
*) pMode
);
149 LeaveCriticalSection(&d3d8_cs
);
153 static HRESULT WINAPI
IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface
, UINT Adapter
, D3DDISPLAYMODE
* pMode
) {
154 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
156 TRACE("(%p)->(%d,%p)\n", This
, Adapter
, pMode
);
158 EnterCriticalSection(&d3d8_cs
);
159 hr
= IWineD3D_GetAdapterDisplayMode(This
->WineD3D
, Adapter
, (WINED3DDISPLAYMODE
*) pMode
);
160 LeaveCriticalSection(&d3d8_cs
);
164 static HRESULT WINAPI
IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface
,
165 UINT Adapter
, D3DDEVTYPE CheckType
, D3DFORMAT DisplayFormat
,
166 D3DFORMAT BackBufferFormat
, BOOL Windowed
) {
167 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
169 TRACE("(%p)->(%d, %d, %d, %d, %s)\n", This
, Adapter
, CheckType
, DisplayFormat
, BackBufferFormat
, Windowed
? "true" : "false");
171 EnterCriticalSection(&d3d8_cs
);
172 hr
= IWineD3D_CheckDeviceType(This
->WineD3D
, Adapter
, CheckType
, DisplayFormat
,
173 BackBufferFormat
, Windowed
);
174 LeaveCriticalSection(&d3d8_cs
);
178 static HRESULT WINAPI
IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface
,
179 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
180 DWORD Usage
, D3DRESOURCETYPE RType
, D3DFORMAT CheckFormat
) {
181 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
183 TRACE("(%p)->(%d, %d, %d, %08x, %d, %d)\n", This
, Adapter
, DeviceType
, AdapterFormat
, Usage
, RType
, CheckFormat
);
185 EnterCriticalSection(&d3d8_cs
);
186 hr
= IWineD3D_CheckDeviceFormat(This
->WineD3D
, Adapter
, DeviceType
, AdapterFormat
,
187 Usage
, RType
, CheckFormat
);
188 LeaveCriticalSection(&d3d8_cs
);
192 static HRESULT WINAPI
IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface
,
193 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT SurfaceFormat
,
194 BOOL Windowed
, D3DMULTISAMPLE_TYPE MultiSampleType
) {
195 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
197 TRACE("(%p)-<(%d, %d, %d, %s, %d)\n", This
, Adapter
, DeviceType
, SurfaceFormat
, Windowed
? "true" : "false", MultiSampleType
);
199 EnterCriticalSection(&d3d8_cs
);
200 hr
= IWineD3D_CheckDeviceMultiSampleType(This
->WineD3D
, Adapter
, DeviceType
, SurfaceFormat
,
201 Windowed
, (WINED3DMULTISAMPLE_TYPE
) MultiSampleType
, NULL
);
202 LeaveCriticalSection(&d3d8_cs
);
206 static HRESULT WINAPI
IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface
,
207 UINT Adapter
, D3DDEVTYPE DeviceType
, D3DFORMAT AdapterFormat
,
208 D3DFORMAT RenderTargetFormat
, D3DFORMAT DepthStencilFormat
) {
209 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
211 TRACE("(%p)-<(%d, %d, %d, %d, %d)\n", This
, Adapter
, DeviceType
, AdapterFormat
, RenderTargetFormat
, DepthStencilFormat
);
213 EnterCriticalSection(&d3d8_cs
);
214 hr
= IWineD3D_CheckDepthStencilMatch(This
->WineD3D
, Adapter
, DeviceType
, AdapterFormat
,
215 RenderTargetFormat
, DepthStencilFormat
);
216 LeaveCriticalSection(&d3d8_cs
);
220 static HRESULT WINAPI
IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, D3DCAPS8
* pCaps
) {
221 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
222 HRESULT hrc
= D3D_OK
;
223 WINED3DCAPS
*pWineCaps
;
225 TRACE("(%p) Relay %d %u %p\n", This
, Adapter
, DeviceType
, pCaps
);
228 return D3DERR_INVALIDCALL
;
230 pWineCaps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINED3DCAPS
));
231 if(pWineCaps
== NULL
){
232 return D3DERR_INVALIDCALL
; /*well this is what MSDN says to return*/
234 EnterCriticalSection(&d3d8_cs
);
235 hrc
= IWineD3D_GetDeviceCaps(This
->WineD3D
, Adapter
, DeviceType
, pWineCaps
);
236 LeaveCriticalSection(&d3d8_cs
);
237 WINECAPSTOD3D8CAPS(pCaps
, pWineCaps
)
238 HeapFree(GetProcessHeap(), 0, pWineCaps
);
240 /* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
241 if(pCaps
->PixelShaderVersion
> D3DPS_VERSION(1,4)){
242 pCaps
->PixelShaderVersion
= D3DPS_VERSION(1,4);
244 if(pCaps
->VertexShaderVersion
> D3DVS_VERSION(1,1)){
245 pCaps
->VertexShaderVersion
= D3DVS_VERSION(1,1);
248 TRACE("(%p) returning %p\n", This
, pCaps
);
252 static HMONITOR WINAPI
IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface
, UINT Adapter
) {
253 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
255 TRACE("(%p)->(%d)\n", This
, Adapter
);
257 EnterCriticalSection(&d3d8_cs
);
258 ret
= IWineD3D_GetAdapterMonitor(This
->WineD3D
, Adapter
);
259 LeaveCriticalSection(&d3d8_cs
);
263 /* Internal function called back during the CreateDevice to create a render target */
264 HRESULT WINAPI
D3D8CB_CreateRenderTarget(IUnknown
*device
, IUnknown
*pSuperior
, UINT Width
, UINT Height
,
265 WINED3DFORMAT Format
, WINED3DMULTISAMPLE_TYPE MultiSample
,
266 DWORD MultisampleQuality
, BOOL Lockable
,
267 IWineD3DSurface
** ppSurface
, HANDLE
* pSharedHandle
) {
268 HRESULT res
= D3D_OK
;
269 IDirect3DSurface8Impl
*d3dSurface
= NULL
;
271 TRACE("(%p) call back\n", device
);
272 res
= IDirect3DDevice8_CreateRenderTarget((IDirect3DDevice8
*)device
, Width
, Height
,
273 (D3DFORMAT
)Format
, MultiSample
, Lockable
,
274 (IDirect3DSurface8
**)&d3dSurface
);
276 if (SUCCEEDED(res
)) {
277 *ppSurface
= d3dSurface
->wineD3DSurface
;
278 d3dSurface
->container
= device
;
279 d3dSurface
->isImplicit
= TRUE
;
280 /* Implicit surfaces are created with an refcount of 0 */
281 IUnknown_Release((IUnknown
*)d3dSurface
);
288 ULONG WINAPI
D3D8CB_DestroyRenderTarget(IWineD3DSurface
*pSurface
) {
289 IDirect3DSurface8Impl
* surfaceParent
;
290 TRACE("(%p) call back\n", pSurface
);
292 IWineD3DSurface_GetParent(pSurface
, (IUnknown
**) &surfaceParent
);
293 surfaceParent
->isImplicit
= FALSE
;
294 /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
295 return IDirect3DSurface8_Release((IDirect3DSurface8
*) surfaceParent
);
298 /* Callback for creating the implicit swapchain when the device is created */
299 static HRESULT WINAPI
D3D8CB_CreateAdditionalSwapChain(IUnknown
*device
,
300 WINED3DPRESENT_PARAMETERS
* pPresentationParameters
,
301 IWineD3DSwapChain
** ppSwapChain
){
302 HRESULT res
= D3D_OK
;
303 IDirect3DSwapChain8Impl
*d3dSwapChain
= NULL
;
304 D3DPRESENT_PARAMETERS localParameters
;
305 TRACE("(%p) call back\n", device
);
307 /* Copy the presentation parameters */
308 localParameters
.BackBufferWidth
= pPresentationParameters
->BackBufferWidth
;
309 localParameters
.BackBufferHeight
= pPresentationParameters
->BackBufferHeight
;
310 localParameters
.BackBufferFormat
= pPresentationParameters
->BackBufferFormat
;
311 localParameters
.BackBufferCount
= pPresentationParameters
->BackBufferCount
;
312 localParameters
.MultiSampleType
= pPresentationParameters
->MultiSampleType
;
313 localParameters
.SwapEffect
= pPresentationParameters
->SwapEffect
;
314 localParameters
.hDeviceWindow
= pPresentationParameters
->hDeviceWindow
;
315 localParameters
.Windowed
= pPresentationParameters
->Windowed
;
316 localParameters
.EnableAutoDepthStencil
= pPresentationParameters
->EnableAutoDepthStencil
;
317 localParameters
.AutoDepthStencilFormat
= pPresentationParameters
->AutoDepthStencilFormat
;
318 localParameters
.Flags
= pPresentationParameters
->Flags
;
319 localParameters
.FullScreen_RefreshRateInHz
= pPresentationParameters
->FullScreen_RefreshRateInHz
;
320 localParameters
.FullScreen_PresentationInterval
= pPresentationParameters
->PresentationInterval
;
322 res
= IDirect3DDevice8_CreateAdditionalSwapChain((IDirect3DDevice8
*)device
, &localParameters
, (IDirect3DSwapChain8
**)&d3dSwapChain
);
324 /* Copy back the presentation parameters */
325 pPresentationParameters
->BackBufferWidth
= localParameters
.BackBufferWidth
;
326 pPresentationParameters
->BackBufferHeight
= localParameters
.BackBufferHeight
;
327 pPresentationParameters
->BackBufferFormat
= localParameters
.BackBufferFormat
;
328 pPresentationParameters
->BackBufferCount
= localParameters
.BackBufferCount
;
329 pPresentationParameters
->MultiSampleType
= localParameters
.MultiSampleType
;
330 pPresentationParameters
->SwapEffect
= localParameters
.SwapEffect
;
331 pPresentationParameters
->hDeviceWindow
= localParameters
.hDeviceWindow
;
332 pPresentationParameters
->Windowed
= localParameters
.Windowed
;
333 pPresentationParameters
->EnableAutoDepthStencil
= localParameters
.EnableAutoDepthStencil
;
334 pPresentationParameters
->AutoDepthStencilFormat
= localParameters
.AutoDepthStencilFormat
;
335 pPresentationParameters
->Flags
= localParameters
.Flags
;
336 pPresentationParameters
->FullScreen_RefreshRateInHz
= localParameters
.FullScreen_RefreshRateInHz
;
337 pPresentationParameters
->PresentationInterval
= localParameters
.FullScreen_PresentationInterval
;
339 if (SUCCEEDED(res
)) {
340 *ppSwapChain
= d3dSwapChain
->wineD3DSwapChain
;
341 IUnknown_Release(d3dSwapChain
->parentDevice
);
342 d3dSwapChain
->parentDevice
= NULL
;
350 ULONG WINAPI
D3D8CB_DestroySwapChain(IWineD3DSwapChain
*pSwapChain
) {
351 IUnknown
* swapChainParent
;
352 TRACE("(%p) call back\n", pSwapChain
);
354 IWineD3DSwapChain_GetParent(pSwapChain
, &swapChainParent
);
355 IUnknown_Release(swapChainParent
);
356 return IUnknown_Release(swapChainParent
);
359 /* Internal function called back during the CreateDevice to create a render target */
360 HRESULT WINAPI
D3D8CB_CreateDepthStencilSurface(IUnknown
*device
, IUnknown
*pSuperior
, UINT Width
, UINT Height
,
361 WINED3DFORMAT Format
, WINED3DMULTISAMPLE_TYPE MultiSample
,
362 DWORD MultisampleQuality
, BOOL Discard
,
363 IWineD3DSurface
** ppSurface
, HANDLE
* pSharedHandle
) {
364 HRESULT res
= D3D_OK
;
365 IDirect3DSurface8Impl
*d3dSurface
= NULL
;
366 TRACE("(%p) call back\n", device
);
368 res
= IDirect3DDevice8_CreateDepthStencilSurface((IDirect3DDevice8
*)device
, Width
, Height
,
369 (D3DFORMAT
)Format
, MultiSample
, (IDirect3DSurface8
**)&d3dSurface
);
370 if (SUCCEEDED(res
)) {
371 *ppSurface
= d3dSurface
->wineD3DSurface
;
372 d3dSurface
->container
= device
;
373 d3dSurface
->isImplicit
= TRUE
;
374 /* Implicit surfaces are created with an refcount of 0 */
375 IUnknown_Release((IUnknown
*)d3dSurface
);
380 ULONG WINAPI
D3D8CB_DestroyDepthStencilSurface(IWineD3DSurface
*pSurface
) {
381 IDirect3DSurface8Impl
* surfaceParent
;
382 TRACE("(%p) call back\n", pSurface
);
384 IWineD3DSurface_GetParent(pSurface
, (IUnknown
**) &surfaceParent
);
385 surfaceParent
->isImplicit
= FALSE
;
386 /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
387 return IDirect3DSurface8_Release((IDirect3DSurface8
*) surfaceParent
);
390 static HRESULT WINAPI
IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface
, UINT Adapter
, D3DDEVTYPE DeviceType
, HWND hFocusWindow
,
391 DWORD BehaviourFlags
, D3DPRESENT_PARAMETERS
* pPresentationParameters
,
392 IDirect3DDevice8
** ppReturnedDeviceInterface
) {
394 IDirect3D8Impl
*This
= (IDirect3D8Impl
*)iface
;
395 IDirect3DDevice8Impl
*object
= NULL
;
396 WINED3DPRESENT_PARAMETERS localParameters
;
398 TRACE("(%p) Relay\n", This
);
400 /* Check the validity range of the adapter parameter */
401 if (Adapter
>= IDirect3D8Impl_GetAdapterCount(iface
)) {
402 *ppReturnedDeviceInterface
= NULL
;
403 return D3DERR_INVALIDCALL
;
406 /* Allocate the storage for the device object */
407 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DDevice8Impl
));
408 if (NULL
== object
) {
409 FIXME("Allocation of memory failed\n");
410 *ppReturnedDeviceInterface
= NULL
;
411 return D3DERR_OUTOFVIDEOMEMORY
;
414 object
->lpVtbl
= &Direct3DDevice8_Vtbl
;
416 object
->shader_handles
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, INITIAL_SHADER_HANDLE_TABLE_SIZE
* sizeof(shader_handle
));
417 object
->shader_handle_table_size
= INITIAL_SHADER_HANDLE_TABLE_SIZE
;
418 *ppReturnedDeviceInterface
= (IDirect3DDevice8
*)object
;
420 /* Allocate an associated WineD3DDevice object */
421 EnterCriticalSection(&d3d8_cs
);
422 hr
=IWineD3D_CreateDevice(This
->WineD3D
, Adapter
, DeviceType
, hFocusWindow
, BehaviourFlags
, &object
->WineD3DDevice
, (IUnknown
*)object
);
425 HeapFree(GetProcessHeap(), 0, object
);
426 *ppReturnedDeviceInterface
= NULL
;
427 LeaveCriticalSection(&d3d8_cs
);
431 TRACE("(%p) : Created Device %p\n", This
, object
);
433 localParameters
.BackBufferWidth
= pPresentationParameters
->BackBufferWidth
;
434 localParameters
.BackBufferHeight
= pPresentationParameters
->BackBufferHeight
;
435 localParameters
.BackBufferFormat
= pPresentationParameters
->BackBufferFormat
;
436 localParameters
.BackBufferCount
= pPresentationParameters
->BackBufferCount
;
437 localParameters
.MultiSampleType
= pPresentationParameters
->MultiSampleType
;
438 localParameters
.MultiSampleQuality
= 0; /* d3d9 only */
439 localParameters
.SwapEffect
= pPresentationParameters
->SwapEffect
;
440 localParameters
.hDeviceWindow
= pPresentationParameters
->hDeviceWindow
;
441 localParameters
.Windowed
= pPresentationParameters
->Windowed
;
442 localParameters
.EnableAutoDepthStencil
= pPresentationParameters
->EnableAutoDepthStencil
;
443 localParameters
.AutoDepthStencilFormat
= pPresentationParameters
->AutoDepthStencilFormat
;
444 localParameters
.Flags
= pPresentationParameters
->Flags
;
445 localParameters
.FullScreen_RefreshRateInHz
= pPresentationParameters
->FullScreen_RefreshRateInHz
;
446 localParameters
.PresentationInterval
= pPresentationParameters
->FullScreen_PresentationInterval
;
448 if(BehaviourFlags
& D3DCREATE_MULTITHREADED
) {
449 IWineD3DDevice_SetMultithreaded(object
->WineD3DDevice
);
452 hr
= IWineD3DDevice_Init3D(object
->WineD3DDevice
, &localParameters
, D3D8CB_CreateAdditionalSwapChain
);
453 LeaveCriticalSection(&d3d8_cs
);
455 pPresentationParameters
->BackBufferWidth
= localParameters
.BackBufferWidth
;
456 pPresentationParameters
->BackBufferHeight
= localParameters
.BackBufferHeight
;
457 pPresentationParameters
->BackBufferFormat
= localParameters
.BackBufferFormat
;
458 pPresentationParameters
->BackBufferCount
= localParameters
.BackBufferCount
;
459 pPresentationParameters
->MultiSampleType
= localParameters
.MultiSampleType
;
460 pPresentationParameters
->SwapEffect
= localParameters
.SwapEffect
;
461 pPresentationParameters
->hDeviceWindow
= localParameters
.hDeviceWindow
;
462 pPresentationParameters
->Windowed
= localParameters
.Windowed
;
463 pPresentationParameters
->EnableAutoDepthStencil
= localParameters
.EnableAutoDepthStencil
;
464 pPresentationParameters
->AutoDepthStencilFormat
= localParameters
.AutoDepthStencilFormat
;
465 pPresentationParameters
->Flags
= localParameters
.Flags
;
466 pPresentationParameters
->FullScreen_RefreshRateInHz
= localParameters
.FullScreen_RefreshRateInHz
;
467 pPresentationParameters
->FullScreen_PresentationInterval
= localParameters
.PresentationInterval
;
470 FIXME("(%p) D3D Initialization failed for WineD3DDevice %p\n", This
, object
->WineD3DDevice
);
471 HeapFree(GetProcessHeap(), 0, object
);
472 *ppReturnedDeviceInterface
= NULL
;
475 object
->declArraySize
= 16;
476 object
->decls
= HeapAlloc(GetProcessHeap(), 0, object
->declArraySize
* sizeof(*object
->decls
));
478 ERR("Out of memory\n");
479 IWineD3DDevice_Release(object
->WineD3DDevice
);
480 HeapFree(GetProcessHeap(), 0, object
);
481 *ppReturnedDeviceInterface
= NULL
;
487 const IDirect3D8Vtbl Direct3D8_Vtbl
=
490 IDirect3D8Impl_QueryInterface
,
491 IDirect3D8Impl_AddRef
,
492 IDirect3D8Impl_Release
,
494 IDirect3D8Impl_RegisterSoftwareDevice
,
495 IDirect3D8Impl_GetAdapterCount
,
496 IDirect3D8Impl_GetAdapterIdentifier
,
497 IDirect3D8Impl_GetAdapterModeCount
,
498 IDirect3D8Impl_EnumAdapterModes
,
499 IDirect3D8Impl_GetAdapterDisplayMode
,
500 IDirect3D8Impl_CheckDeviceType
,
501 IDirect3D8Impl_CheckDeviceFormat
,
502 IDirect3D8Impl_CheckDeviceMultiSampleType
,
503 IDirect3D8Impl_CheckDepthStencilMatch
,
504 IDirect3D8Impl_GetDeviceCaps
,
505 IDirect3D8Impl_GetAdapterMonitor
,
506 IDirect3D8Impl_CreateDevice