2 * IDirect3DDevice9 implementation
4 * Copyright 2002-2005 Jason Edmeades
5 * Copyright 2002-2005 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
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
24 #include "d3d9_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d9
);
28 D3DFORMAT
d3dformat_from_wined3dformat(WINED3DFORMAT format
)
30 BYTE
*c
= (BYTE
*)&format
;
32 /* Don't translate FOURCC formats */
33 if (isprint(c
[0]) && isprint(c
[1]) && isprint(c
[2]) && isprint(c
[3])) return format
;
37 case WINED3DFMT_UNKNOWN
: return D3DFMT_UNKNOWN
;
38 case WINED3DFMT_B8G8R8_UNORM
: return D3DFMT_R8G8B8
;
39 case WINED3DFMT_B8G8R8A8_UNORM
: return D3DFMT_A8R8G8B8
;
40 case WINED3DFMT_B8G8R8X8_UNORM
: return D3DFMT_X8R8G8B8
;
41 case WINED3DFMT_B5G6R5_UNORM
: return D3DFMT_R5G6B5
;
42 case WINED3DFMT_B5G5R5X1_UNORM
: return D3DFMT_X1R5G5B5
;
43 case WINED3DFMT_B5G5R5A1_UNORM
: return D3DFMT_A1R5G5B5
;
44 case WINED3DFMT_B4G4R4A4_UNORM
: return D3DFMT_A4R4G4B4
;
45 case WINED3DFMT_B2G3R3_UNORM
: return D3DFMT_R3G3B2
;
46 case WINED3DFMT_A8_UNORM
: return D3DFMT_A8
;
47 case WINED3DFMT_B2G3R3A8_UNORM
: return D3DFMT_A8R3G3B2
;
48 case WINED3DFMT_B4G4R4X4_UNORM
: return D3DFMT_X4R4G4B4
;
49 case WINED3DFMT_R10G10B10A2_UNORM
: return D3DFMT_A2B10G10R10
;
50 case WINED3DFMT_R8G8B8A8_UNORM
: return D3DFMT_A8B8G8R8
;
51 case WINED3DFMT_R8G8B8X8_UNORM
: return D3DFMT_X8B8G8R8
;
52 case WINED3DFMT_R16G16_UNORM
: return D3DFMT_G16R16
;
53 case WINED3DFMT_B10G10R10A2_UNORM
: return D3DFMT_A2R10G10B10
;
54 case WINED3DFMT_R16G16B16A16_UNORM
: return D3DFMT_A16B16G16R16
;
55 case WINED3DFMT_P8_UINT_A8_UNORM
: return D3DFMT_A8P8
;
56 case WINED3DFMT_P8_UINT
: return D3DFMT_P8
;
57 case WINED3DFMT_L8_UNORM
: return D3DFMT_L8
;
58 case WINED3DFMT_L8A8_UNORM
: return D3DFMT_A8L8
;
59 case WINED3DFMT_L4A4_UNORM
: return D3DFMT_A4L4
;
60 case WINED3DFMT_R8G8_SNORM
: return D3DFMT_V8U8
;
61 case WINED3DFMT_R5G5_SNORM_L6_UNORM
: return D3DFMT_L6V5U5
;
62 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
: return D3DFMT_X8L8V8U8
;
63 case WINED3DFMT_R8G8B8A8_SNORM
: return D3DFMT_Q8W8V8U8
;
64 case WINED3DFMT_R16G16_SNORM
: return D3DFMT_V16U16
;
65 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM
: return D3DFMT_A2W10V10U10
;
66 case WINED3DFMT_D16_LOCKABLE
: return D3DFMT_D16_LOCKABLE
;
67 case WINED3DFMT_D32_UNORM
: return D3DFMT_D32
;
68 case WINED3DFMT_S1_UINT_D15_UNORM
: return D3DFMT_D15S1
;
69 case WINED3DFMT_D24_UNORM_S8_UINT
: return D3DFMT_D24S8
;
70 case WINED3DFMT_X8D24_UNORM
: return D3DFMT_D24X8
;
71 case WINED3DFMT_S4X4_UINT_D24_UNORM
: return D3DFMT_D24X4S4
;
72 case WINED3DFMT_D16_UNORM
: return D3DFMT_D16
;
73 case WINED3DFMT_L16_UNORM
: return D3DFMT_L16
;
74 case WINED3DFMT_D32_FLOAT
: return D3DFMT_D32F_LOCKABLE
;
75 case WINED3DFMT_S8_UINT_D24_FLOAT
: return D3DFMT_D24FS8
;
76 case WINED3DFMT_VERTEXDATA
: return D3DFMT_VERTEXDATA
;
77 case WINED3DFMT_R16_UINT
: return D3DFMT_INDEX16
;
78 case WINED3DFMT_R32_UINT
: return D3DFMT_INDEX32
;
79 case WINED3DFMT_R16G16B16A16_SNORM
: return D3DFMT_Q16W16V16U16
;
80 case WINED3DFMT_R16_FLOAT
: return D3DFMT_R16F
;
81 case WINED3DFMT_R16G16_FLOAT
: return D3DFMT_G16R16F
;
82 case WINED3DFMT_R16G16B16A16_FLOAT
: return D3DFMT_A16B16G16R16F
;
83 case WINED3DFMT_R32_FLOAT
: return D3DFMT_R32F
;
84 case WINED3DFMT_R32G32_FLOAT
: return D3DFMT_G32R32F
;
85 case WINED3DFMT_R32G32B32A32_FLOAT
: return D3DFMT_A32B32G32R32F
;
86 case WINED3DFMT_R8G8_SNORM_Cx
: return D3DFMT_CxV8U8
;
88 FIXME("Unhandled WINED3DFORMAT %#x\n", format
);
89 return D3DFMT_UNKNOWN
;
93 WINED3DFORMAT
wined3dformat_from_d3dformat(D3DFORMAT format
)
95 BYTE
*c
= (BYTE
*)&format
;
97 /* Don't translate FOURCC formats */
98 if (isprint(c
[0]) && isprint(c
[1]) && isprint(c
[2]) && isprint(c
[3])) return format
;
102 case D3DFMT_UNKNOWN
: return WINED3DFMT_UNKNOWN
;
103 case D3DFMT_R8G8B8
: return WINED3DFMT_B8G8R8_UNORM
;
104 case D3DFMT_A8R8G8B8
: return WINED3DFMT_B8G8R8A8_UNORM
;
105 case D3DFMT_X8R8G8B8
: return WINED3DFMT_B8G8R8X8_UNORM
;
106 case D3DFMT_R5G6B5
: return WINED3DFMT_B5G6R5_UNORM
;
107 case D3DFMT_X1R5G5B5
: return WINED3DFMT_B5G5R5X1_UNORM
;
108 case D3DFMT_A1R5G5B5
: return WINED3DFMT_B5G5R5A1_UNORM
;
109 case D3DFMT_A4R4G4B4
: return WINED3DFMT_B4G4R4A4_UNORM
;
110 case D3DFMT_R3G3B2
: return WINED3DFMT_B2G3R3_UNORM
;
111 case D3DFMT_A8
: return WINED3DFMT_A8_UNORM
;
112 case D3DFMT_A8R3G3B2
: return WINED3DFMT_B2G3R3A8_UNORM
;
113 case D3DFMT_X4R4G4B4
: return WINED3DFMT_B4G4R4X4_UNORM
;
114 case D3DFMT_A2B10G10R10
: return WINED3DFMT_R10G10B10A2_UNORM
;
115 case D3DFMT_A8B8G8R8
: return WINED3DFMT_R8G8B8A8_UNORM
;
116 case D3DFMT_X8B8G8R8
: return WINED3DFMT_R8G8B8X8_UNORM
;
117 case D3DFMT_G16R16
: return WINED3DFMT_R16G16_UNORM
;
118 case D3DFMT_A2R10G10B10
: return WINED3DFMT_B10G10R10A2_UNORM
;
119 case D3DFMT_A16B16G16R16
: return WINED3DFMT_R16G16B16A16_UNORM
;
120 case D3DFMT_A8P8
: return WINED3DFMT_P8_UINT_A8_UNORM
;
121 case D3DFMT_P8
: return WINED3DFMT_P8_UINT
;
122 case D3DFMT_L8
: return WINED3DFMT_L8_UNORM
;
123 case D3DFMT_A8L8
: return WINED3DFMT_L8A8_UNORM
;
124 case D3DFMT_A4L4
: return WINED3DFMT_L4A4_UNORM
;
125 case D3DFMT_V8U8
: return WINED3DFMT_R8G8_SNORM
;
126 case D3DFMT_L6V5U5
: return WINED3DFMT_R5G5_SNORM_L6_UNORM
;
127 case D3DFMT_X8L8V8U8
: return WINED3DFMT_R8G8_SNORM_L8X8_UNORM
;
128 case D3DFMT_Q8W8V8U8
: return WINED3DFMT_R8G8B8A8_SNORM
;
129 case D3DFMT_V16U16
: return WINED3DFMT_R16G16_SNORM
;
130 case D3DFMT_A2W10V10U10
: return WINED3DFMT_R10G10B10_SNORM_A2_UNORM
;
131 case D3DFMT_D16_LOCKABLE
: return WINED3DFMT_D16_LOCKABLE
;
132 case D3DFMT_D32
: return WINED3DFMT_D32_UNORM
;
133 case D3DFMT_D15S1
: return WINED3DFMT_S1_UINT_D15_UNORM
;
134 case D3DFMT_D24S8
: return WINED3DFMT_D24_UNORM_S8_UINT
;
135 case D3DFMT_D24X8
: return WINED3DFMT_X8D24_UNORM
;
136 case D3DFMT_D24X4S4
: return WINED3DFMT_S4X4_UINT_D24_UNORM
;
137 case D3DFMT_D16
: return WINED3DFMT_D16_UNORM
;
138 case D3DFMT_L16
: return WINED3DFMT_L16_UNORM
;
139 case D3DFMT_D32F_LOCKABLE
: return WINED3DFMT_D32_FLOAT
;
140 case D3DFMT_D24FS8
: return WINED3DFMT_S8_UINT_D24_FLOAT
;
141 case D3DFMT_VERTEXDATA
: return WINED3DFMT_VERTEXDATA
;
142 case D3DFMT_INDEX16
: return WINED3DFMT_R16_UINT
;
143 case D3DFMT_INDEX32
: return WINED3DFMT_R32_UINT
;
144 case D3DFMT_Q16W16V16U16
: return WINED3DFMT_R16G16B16A16_SNORM
;
145 case D3DFMT_R16F
: return WINED3DFMT_R16_FLOAT
;
146 case D3DFMT_G16R16F
: return WINED3DFMT_R16G16_FLOAT
;
147 case D3DFMT_A16B16G16R16F
: return WINED3DFMT_R16G16B16A16_FLOAT
;
148 case D3DFMT_R32F
: return WINED3DFMT_R32_FLOAT
;
149 case D3DFMT_G32R32F
: return WINED3DFMT_R32G32_FLOAT
;
150 case D3DFMT_A32B32G32R32F
: return WINED3DFMT_R32G32B32A32_FLOAT
;
151 case D3DFMT_CxV8U8
: return WINED3DFMT_R8G8_SNORM_Cx
;
153 FIXME("Unhandled D3DFORMAT %#x\n", format
);
154 return WINED3DFMT_UNKNOWN
;
158 static UINT
vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type
, UINT primitive_count
)
160 switch(primitive_type
)
162 case D3DPT_POINTLIST
:
163 return primitive_count
;
166 return primitive_count
* 2;
168 case D3DPT_LINESTRIP
:
169 return primitive_count
+ 1;
171 case D3DPT_TRIANGLELIST
:
172 return primitive_count
* 3;
174 case D3DPT_TRIANGLESTRIP
:
175 case D3DPT_TRIANGLEFAN
:
176 return primitive_count
+ 2;
179 FIXME("Unhandled primitive type %#x\n", primitive_type
);
184 static ULONG WINAPI
D3D9CB_DestroySwapChain(IWineD3DSwapChain
*swapchain
)
186 IDirect3DSwapChain9Impl
*parent
;
188 TRACE("swapchain %p.\n", swapchain
);
190 IWineD3DSwapChain_GetParent(swapchain
, (IUnknown
**)&parent
);
191 parent
->isImplicit
= FALSE
;
192 return IDirect3DSwapChain9_Release((IDirect3DSwapChain9
*)parent
);
195 /* IDirect3D IUnknown parts follow: */
196 static HRESULT WINAPI
IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX iface
, REFIID riid
, LPVOID
* ppobj
) {
197 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
199 IDirect3D9Impl
*d3dimpl
;
201 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), ppobj
);
203 if (IsEqualGUID(riid
, &IID_IUnknown
)
204 || IsEqualGUID(riid
, &IID_IDirect3DDevice9
)) {
205 IDirect3DDevice9Ex_AddRef(iface
);
207 TRACE("Returning IDirect3DDevice9 interface at %p\n", *ppobj
);
209 } else if(IsEqualGUID(riid
, &IID_IDirect3DDevice9Ex
)) {
210 /* Find out if the creating d3d9 interface was created with Direct3DCreate9Ex.
211 * It doesn't matter with which function the device was created.
213 IDirect3DDevice9_GetDirect3D(iface
, &d3d
);
214 d3dimpl
= (IDirect3D9Impl
*) d3d
;
216 if(d3dimpl
->extended
) {
218 IDirect3DDevice9Ex_AddRef((IDirect3DDevice9Ex
*) *ppobj
);
219 IDirect3D9_Release(d3d
);
220 TRACE("Returning IDirect3DDevice9Ex interface at %p\n", *ppobj
);
223 WARN("IDirect3D9 instance wasn't created with CreateDirect3D9Ex, returning E_NOINTERFACE\n");
224 IDirect3D9_Release(d3d
);
226 return E_NOINTERFACE
;
230 if (IsEqualGUID(riid
, &IID_IWineD3DDeviceParent
))
232 IUnknown_AddRef((IUnknown
*)&This
->device_parent_vtbl
);
233 *ppobj
= &This
->device_parent_vtbl
;
237 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
239 return E_NOINTERFACE
;
242 static ULONG WINAPI
IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9EX iface
) {
243 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
244 ULONG ref
= InterlockedIncrement(&This
->ref
);
246 TRACE("%p increasing refcount to %u.\n", iface
, ref
);
251 static ULONG WINAPI DECLSPEC_HOTPATCH
IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface
) {
252 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
255 if (This
->inDestruction
) return 0;
256 ref
= InterlockedDecrement(&This
->ref
);
258 TRACE("%p decreasing refcount to %u.\n", iface
, ref
);
262 This
->inDestruction
= TRUE
;
264 wined3d_mutex_lock();
265 for(i
= 0; i
< This
->numConvertedDecls
; i
++) {
266 /* Unless Wine is buggy or the app has a bug the refcount will be 0, because decls hold a reference to the
269 IDirect3DVertexDeclaration9Impl_Destroy(This
->convertedDecls
[i
]);
271 HeapFree(GetProcessHeap(), 0, This
->convertedDecls
);
273 IWineD3DDevice_Uninit3D(This
->WineD3DDevice
, D3D9CB_DestroySwapChain
);
274 IWineD3DDevice_Release(This
->WineD3DDevice
);
275 wined3d_mutex_unlock();
277 HeapFree(GetProcessHeap(), 0, This
);
282 /* IDirect3DDevice Interface follow: */
283 static HRESULT WINAPI
IDirect3DDevice9Impl_TestCooperativeLevel(IDirect3DDevice9Ex
*iface
)
285 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
287 TRACE("iface %p.\n", iface
);
291 TRACE("D3D9 device is marked not reset.\n");
292 return D3DERR_DEVICENOTRESET
;
298 static UINT WINAPI
IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9EX iface
) {
299 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
302 TRACE("iface %p.\n", iface
);
304 wined3d_mutex_lock();
305 hr
= IWineD3DDevice_GetAvailableTextureMem(This
->WineD3DDevice
);
306 wined3d_mutex_unlock();
311 static HRESULT WINAPI
IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9EX iface
) {
312 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
315 TRACE("iface %p.\n", iface
);
317 wined3d_mutex_lock();
318 hr
= IWineD3DDevice_EvictManagedResources(This
->WineD3DDevice
);
319 wined3d_mutex_unlock();
324 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface
, IDirect3D9
** ppD3D9
) {
325 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
329 TRACE("iface %p, d3d9 %p.\n", iface
, ppD3D9
);
331 if (NULL
== ppD3D9
) {
332 return D3DERR_INVALIDCALL
;
335 wined3d_mutex_lock();
336 hr
= IWineD3DDevice_GetDirect3D(This
->WineD3DDevice
, &pWineD3D
);
337 if (hr
== D3D_OK
&& pWineD3D
!= NULL
)
339 IWineD3D_GetParent(pWineD3D
,(IUnknown
**)ppD3D9
);
340 IWineD3D_Release(pWineD3D
);
342 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
345 TRACE("(%p) returning %p\n", This
, *ppD3D9
);
346 wined3d_mutex_unlock();
351 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9EX iface
, D3DCAPS9
* pCaps
) {
352 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
353 HRESULT hrc
= D3D_OK
;
354 WINED3DCAPS
*pWineCaps
;
356 TRACE("iface %p, caps %p.\n", iface
, pCaps
);
359 return D3DERR_INVALIDCALL
;
361 pWineCaps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINED3DCAPS
));
362 if(pWineCaps
== NULL
){
363 return D3DERR_INVALIDCALL
; /* well this is what MSDN says to return */
366 memset(pCaps
, 0, sizeof(*pCaps
));
368 wined3d_mutex_lock();
369 hrc
= IWineD3DDevice_GetDeviceCaps(This
->WineD3DDevice
, pWineCaps
);
370 wined3d_mutex_unlock();
372 WINECAPSTOD3D9CAPS(pCaps
, pWineCaps
)
373 HeapFree(GetProcessHeap(), 0, pWineCaps
);
375 /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
376 pCaps
->DevCaps2
|= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
;
380 TRACE("Returning %p %p\n", This
, pCaps
);
384 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DDISPLAYMODE
* pMode
) {
385 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
388 TRACE("iface %p, swapchain %u, mode %p.\n", iface
, iSwapChain
, pMode
);
390 wined3d_mutex_lock();
391 hr
= IWineD3DDevice_GetDisplayMode(This
->WineD3DDevice
, iSwapChain
, (WINED3DDISPLAYMODE
*) pMode
);
392 wined3d_mutex_unlock();
394 if (SUCCEEDED(hr
)) pMode
->Format
= d3dformat_from_wined3dformat(pMode
->Format
);
399 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9EX iface
, D3DDEVICE_CREATION_PARAMETERS
*pParameters
) {
400 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
403 TRACE("iface %p, parameters %p.\n", iface
, pParameters
);
405 wined3d_mutex_lock();
406 hr
= IWineD3DDevice_GetCreationParameters(This
->WineD3DDevice
, (WINED3DDEVICE_CREATION_PARAMETERS
*) pParameters
);
407 wined3d_mutex_unlock();
412 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9EX iface
, UINT XHotSpot
, UINT YHotSpot
, IDirect3DSurface9
* pCursorBitmap
) {
413 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
414 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pCursorBitmap
;
417 TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n",
418 iface
, XHotSpot
, YHotSpot
, pCursorBitmap
);
421 WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
422 return WINED3DERR_INVALIDCALL
;
425 wined3d_mutex_lock();
426 hr
= IWineD3DDevice_SetCursorProperties(This
->WineD3DDevice
, XHotSpot
, YHotSpot
, pSurface
->wineD3DSurface
);
427 wined3d_mutex_unlock();
432 static void WINAPI
IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9EX iface
, int XScreenSpace
, int YScreenSpace
, DWORD Flags
) {
433 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
435 TRACE("iface %p, x %u, y %u, flags %#x.\n", iface
, XScreenSpace
, YScreenSpace
, Flags
);
437 wined3d_mutex_lock();
438 IWineD3DDevice_SetCursorPosition(This
->WineD3DDevice
, XScreenSpace
, YScreenSpace
, Flags
);
439 wined3d_mutex_unlock();
442 static BOOL WINAPI
IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX iface
, BOOL bShow
) {
443 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
446 TRACE("iface %p, show %#x.\n", iface
, bShow
);
448 wined3d_mutex_lock();
449 ret
= IWineD3DDevice_ShowCursor(This
->WineD3DDevice
, bShow
);
450 wined3d_mutex_unlock();
455 static HRESULT WINAPI DECLSPEC_HOTPATCH
IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDevice9Ex
*iface
,
456 D3DPRESENT_PARAMETERS
*present_parameters
, IDirect3DSwapChain9
**swapchain
)
458 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
459 IDirect3DSwapChain9Impl
*object
;
462 TRACE("iface %p, present_parameters %p, swapchain %p.\n",
463 iface
, present_parameters
, swapchain
);
465 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
468 ERR("Failed to allocate swapchain memory.\n");
469 return E_OUTOFMEMORY
;
472 hr
= swapchain_init(object
, This
, present_parameters
);
475 WARN("Failed to initialize swapchain, hr %#x.\n", hr
);
476 HeapFree(GetProcessHeap(), 0, object
);
480 TRACE("Created swapchain %p.\n", object
);
481 *swapchain
= (IDirect3DSwapChain9
*)object
;
486 static HRESULT WINAPI
reset_enum_callback(IWineD3DResource
*resource
, void *data
) {
487 BOOL
*resources_ok
= data
;
488 D3DRESOURCETYPE type
;
490 WINED3DSURFACE_DESC surface_desc
;
491 WINED3DVOLUME_DESC volume_desc
;
492 D3DINDEXBUFFER_DESC index_desc
;
493 D3DVERTEXBUFFER_DESC vertex_desc
;
495 IDirect3DResource9
*parent
;
497 IWineD3DResource_GetParent(resource
, (IUnknown
**) &parent
);
498 type
= IDirect3DResource9_GetType(parent
);
500 case D3DRTYPE_SURFACE
:
501 IWineD3DSurface_GetDesc((IWineD3DSurface
*) resource
, &surface_desc
);
502 pool
= surface_desc
.pool
;
505 case D3DRTYPE_VOLUME
:
506 IWineD3DVolume_GetDesc((IWineD3DVolume
*) resource
, &volume_desc
);
507 pool
= volume_desc
.Pool
;
510 case D3DRTYPE_INDEXBUFFER
:
511 IDirect3DIndexBuffer9_GetDesc((IDirect3DIndexBuffer9
*) parent
, &index_desc
);
512 pool
= index_desc
.Pool
;
515 case D3DRTYPE_VERTEXBUFFER
:
516 IDirect3DVertexBuffer9_GetDesc((IDirect3DVertexBuffer9
*)parent
, &vertex_desc
);
517 pool
= vertex_desc
.Pool
;
520 /* No need to check for textures. If there is a D3DPOOL_DEFAULT texture, there
521 * is a D3DPOOL_DEFAULT surface or volume as well
524 pool
= WINED3DPOOL_SCRATCH
; /* a harmless pool */
528 if(pool
== WINED3DPOOL_DEFAULT
) {
529 if(IUnknown_Release(parent
) == 0) {
530 TRACE("Parent %p is an implicit resource with ref 0\n", parent
);
532 WARN("Resource %p(wineD3D %p) with pool D3DPOOL_DEFAULT blocks the Reset call\n", parent
, resource
);
534 *resources_ok
= FALSE
;
537 IUnknown_Release(parent
);
539 IWineD3DResource_Release(resource
);
544 static HRESULT WINAPI DECLSPEC_HOTPATCH
IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface
, D3DPRESENT_PARAMETERS
* pPresentationParameters
) {
545 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
546 WINED3DPRESENT_PARAMETERS localParameters
;
548 BOOL resources_ok
= TRUE
;
551 TRACE("iface %p, present_parameters %p.\n", iface
, pPresentationParameters
);
553 /* Reset states that hold a COM object. WineD3D holds an internal reference to set objects, because
554 * such objects can still be used for rendering after their external d3d9 object has been destroyed.
555 * These objects must not be enumerated. Unsetting them tells WineD3D that the application will not
556 * make use of the hidden reference and destroys the objects.
558 * Unsetting them is no problem, because the states are supposed to be reset anyway. If the validation
559 * below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
561 wined3d_mutex_lock();
562 IWineD3DDevice_SetIndexBuffer(This
->WineD3DDevice
, NULL
, WINED3DFMT_UNKNOWN
);
563 for(i
= 0; i
< 16; i
++) {
564 IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, i
, NULL
, 0, 0);
566 for(i
= 0; i
< 16; i
++) {
567 IWineD3DDevice_SetTexture(This
->WineD3DDevice
, i
, NULL
);
570 IWineD3DDevice_EnumResources(This
->WineD3DDevice
, reset_enum_callback
, &resources_ok
);
572 WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
573 This
->notreset
= TRUE
;
574 wined3d_mutex_unlock();
576 return WINED3DERR_INVALIDCALL
;
579 localParameters
.BackBufferWidth
= pPresentationParameters
->BackBufferWidth
;
580 localParameters
.BackBufferHeight
= pPresentationParameters
->BackBufferHeight
;
581 localParameters
.BackBufferFormat
= wined3dformat_from_d3dformat(pPresentationParameters
->BackBufferFormat
);
582 localParameters
.BackBufferCount
= pPresentationParameters
->BackBufferCount
;
583 localParameters
.MultiSampleType
= pPresentationParameters
->MultiSampleType
;
584 localParameters
.MultiSampleQuality
= pPresentationParameters
->MultiSampleQuality
;
585 localParameters
.SwapEffect
= pPresentationParameters
->SwapEffect
;
586 localParameters
.hDeviceWindow
= pPresentationParameters
->hDeviceWindow
;
587 localParameters
.Windowed
= pPresentationParameters
->Windowed
;
588 localParameters
.EnableAutoDepthStencil
= pPresentationParameters
->EnableAutoDepthStencil
;
589 localParameters
.AutoDepthStencilFormat
= wined3dformat_from_d3dformat(pPresentationParameters
->AutoDepthStencilFormat
);
590 localParameters
.Flags
= pPresentationParameters
->Flags
;
591 localParameters
.FullScreen_RefreshRateInHz
= pPresentationParameters
->FullScreen_RefreshRateInHz
;
592 localParameters
.PresentationInterval
= pPresentationParameters
->PresentationInterval
;
593 localParameters
.AutoRestoreDisplayMode
= TRUE
;
595 hr
= IWineD3DDevice_Reset(This
->WineD3DDevice
, &localParameters
);
597 This
->notreset
= TRUE
;
599 pPresentationParameters
->BackBufferWidth
= localParameters
.BackBufferWidth
;
600 pPresentationParameters
->BackBufferHeight
= localParameters
.BackBufferHeight
;
601 pPresentationParameters
->BackBufferFormat
= d3dformat_from_wined3dformat(localParameters
.BackBufferFormat
);
602 pPresentationParameters
->BackBufferCount
= localParameters
.BackBufferCount
;
603 pPresentationParameters
->MultiSampleType
= localParameters
.MultiSampleType
;
604 pPresentationParameters
->MultiSampleQuality
= localParameters
.MultiSampleQuality
;
605 pPresentationParameters
->SwapEffect
= localParameters
.SwapEffect
;
606 pPresentationParameters
->hDeviceWindow
= localParameters
.hDeviceWindow
;
607 pPresentationParameters
->Windowed
= localParameters
.Windowed
;
608 pPresentationParameters
->EnableAutoDepthStencil
= localParameters
.EnableAutoDepthStencil
;
609 pPresentationParameters
->AutoDepthStencilFormat
= d3dformat_from_wined3dformat(localParameters
.AutoDepthStencilFormat
);
610 pPresentationParameters
->Flags
= localParameters
.Flags
;
611 pPresentationParameters
->FullScreen_RefreshRateInHz
= localParameters
.FullScreen_RefreshRateInHz
;
612 pPresentationParameters
->PresentationInterval
= localParameters
.PresentationInterval
;
614 This
->notreset
= FALSE
;
617 wined3d_mutex_unlock();
622 static HRESULT WINAPI DECLSPEC_HOTPATCH
IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface
, CONST RECT
* pSourceRect
,CONST RECT
* pDestRect
,HWND hDestWindowOverride
,CONST RGNDATA
*
624 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
627 TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n",
628 iface
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
);
630 wined3d_mutex_lock();
631 hr
= IWineD3DDevice_Present(This
->WineD3DDevice
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
);
632 wined3d_mutex_unlock();
637 static HRESULT WINAPI
IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, UINT BackBuffer
, D3DBACKBUFFER_TYPE Type
, IDirect3DSurface9
** ppBackBuffer
) {
638 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
639 IWineD3DSurface
*retSurface
= NULL
;
642 TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
643 iface
, iSwapChain
, BackBuffer
, Type
, ppBackBuffer
);
645 wined3d_mutex_lock();
646 rc
= IWineD3DDevice_GetBackBuffer(This
->WineD3DDevice
, iSwapChain
, BackBuffer
, (WINED3DBACKBUFFER_TYPE
) Type
, &retSurface
);
647 if (rc
== D3D_OK
&& NULL
!= retSurface
&& NULL
!= ppBackBuffer
) {
648 IWineD3DSurface_GetParent(retSurface
, (IUnknown
**)ppBackBuffer
);
649 IWineD3DSurface_Release(retSurface
);
651 wined3d_mutex_unlock();
655 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DRASTER_STATUS
* pRasterStatus
) {
656 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
659 TRACE("iface %p, swapchain %u, raster_status %p.\n", iface
, iSwapChain
, pRasterStatus
);
661 wined3d_mutex_lock();
662 hr
= IWineD3DDevice_GetRasterStatus(This
->WineD3DDevice
, iSwapChain
, (WINED3DRASTER_STATUS
*) pRasterStatus
);
663 wined3d_mutex_unlock();
668 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9EX iface
, BOOL bEnableDialogs
) {
669 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
672 TRACE("iface %p, enable %#x.\n", iface
, bEnableDialogs
);
674 wined3d_mutex_lock();
675 hr
= IWineD3DDevice_SetDialogBoxMode(This
->WineD3DDevice
, bEnableDialogs
);
676 wined3d_mutex_unlock();
681 static void WINAPI
IDirect3DDevice9Impl_SetGammaRamp(IDirect3DDevice9Ex
*iface
, UINT iSwapChain
,
682 DWORD Flags
, const D3DGAMMARAMP
*pRamp
)
684 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
686 TRACE("iface %p, swapchain %u, flags %#x, ramp %p.\n", iface
, iSwapChain
, Flags
, pRamp
);
688 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
689 wined3d_mutex_lock();
690 IWineD3DDevice_SetGammaRamp(This
->WineD3DDevice
, iSwapChain
, Flags
, (CONST WINED3DGAMMARAMP
*)pRamp
);
691 wined3d_mutex_unlock();
694 static void WINAPI
IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DGAMMARAMP
* pRamp
) {
695 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
697 TRACE("iface %p, swapchain %u, ramp %p.\n", iface
, iSwapChain
, pRamp
);
699 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
700 wined3d_mutex_lock();
701 IWineD3DDevice_GetGammaRamp(This
->WineD3DDevice
, iSwapChain
, (WINED3DGAMMARAMP
*) pRamp
);
702 wined3d_mutex_unlock();
705 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateTexture(IDirect3DDevice9Ex
*iface
,
706 UINT width
, UINT height
, UINT levels
, DWORD usage
, D3DFORMAT format
,
707 D3DPOOL pool
, IDirect3DTexture9
**texture
, HANDLE
*shared_handle
)
709 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
710 IDirect3DTexture9Impl
*object
;
713 TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
714 iface
, width
, height
, levels
, usage
, format
, pool
, texture
, shared_handle
);
716 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
719 ERR("Failed to allocate texture memory.\n");
720 return D3DERR_OUTOFVIDEOMEMORY
;
723 hr
= texture_init(object
, This
, width
, height
, levels
, usage
, format
, pool
);
726 WARN("Failed to initialize texture, hr %#x.\n", hr
);
727 HeapFree(GetProcessHeap(), 0, object
);
731 TRACE("Created texture %p.\n", object
);
732 *texture
= (IDirect3DTexture9
*)object
;
737 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9Ex
*iface
,
738 UINT width
, UINT height
, UINT depth
, UINT levels
, DWORD usage
, D3DFORMAT format
,
739 D3DPOOL pool
, IDirect3DVolumeTexture9
**texture
, HANDLE
*shared_handle
)
741 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
742 IDirect3DVolumeTexture9Impl
*object
;
745 TRACE("iface %p, width %u, height %u, depth %u, levels %u\n",
746 iface
, width
, height
, depth
, levels
);
747 TRACE("usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
748 usage
, format
, pool
, texture
, shared_handle
);
750 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
753 ERR("Failed to allocate volume texture memory.\n");
754 return D3DERR_OUTOFVIDEOMEMORY
;
757 hr
= volumetexture_init(object
, This
, width
, height
, depth
, levels
, usage
, format
, pool
);
760 WARN("Failed to initialize volume texture, hr %#x.\n", hr
);
761 HeapFree(GetProcessHeap(), 0, object
);
765 TRACE("Created volume texture %p.\n", object
);
766 *texture
= (IDirect3DVolumeTexture9
*)object
;
771 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateCubeTexture(IDirect3DDevice9Ex
*iface
,
772 UINT edge_length
, UINT levels
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
,
773 IDirect3DCubeTexture9
**texture
, HANDLE
*shared_handle
)
775 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
776 IDirect3DCubeTexture9Impl
*object
;
779 TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
780 iface
, edge_length
, levels
, usage
, format
, pool
, texture
, shared_handle
);
782 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
785 ERR("Failed to allocate cube texture memory.\n");
786 return D3DERR_OUTOFVIDEOMEMORY
;
789 hr
= cubetexture_init(object
, This
, edge_length
, levels
, usage
, format
, pool
);
792 WARN("Failed to initialize cube texture, hr %#x.\n", hr
);
793 HeapFree(GetProcessHeap(), 0, object
);
797 TRACE("Created cube texture %p.\n", object
);
798 *texture
= (IDirect3DCubeTexture9
*)object
;
803 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex
*iface
, UINT size
, DWORD usage
,
804 DWORD fvf
, D3DPOOL pool
, IDirect3DVertexBuffer9
**buffer
, HANDLE
*shared_handle
)
806 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
807 IDirect3DVertexBuffer9Impl
*object
;
810 TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p, shared_handle %p.\n",
811 iface
, size
, usage
, fvf
, pool
, buffer
, shared_handle
);
813 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
816 ERR("Failed to allocate buffer memory.\n");
817 return D3DERR_OUTOFVIDEOMEMORY
;
820 hr
= vertexbuffer_init(object
, This
, size
, usage
, fvf
, pool
);
823 WARN("Failed to initialize vertex buffer, hr %#x.\n", hr
);
824 HeapFree(GetProcessHeap(), 0, object
);
828 TRACE("Created vertex buffer %p.\n", object
);
829 *buffer
= (IDirect3DVertexBuffer9
*)object
;
834 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateIndexBuffer(IDirect3DDevice9Ex
*iface
, UINT size
, DWORD usage
,
835 D3DFORMAT format
, D3DPOOL pool
, IDirect3DIndexBuffer9
**buffer
, HANDLE
*shared_handle
)
837 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
838 IDirect3DIndexBuffer9Impl
*object
;
841 TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p, shared_handle %p.\n",
842 iface
, size
, usage
, format
, pool
, buffer
, shared_handle
);
844 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
847 ERR("Failed to allocate buffer memory.\n");
848 return D3DERR_OUTOFVIDEOMEMORY
;
851 hr
= indexbuffer_init(object
, This
, size
, usage
, format
, pool
);
854 WARN("Failed to initialize index buffer, hr %#x.\n", hr
);
855 HeapFree(GetProcessHeap(), 0, object
);
859 TRACE("Created index buffer %p.\n", object
);
860 *buffer
= (IDirect3DIndexBuffer9
*)object
;
865 static HRESULT
IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
866 D3DFORMAT Format
, BOOL Lockable
, BOOL Discard
, UINT Level
, IDirect3DSurface9
**ppSurface
,
867 UINT Usage
, D3DPOOL Pool
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultisampleQuality
)
869 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
870 IDirect3DSurface9Impl
*object
;
873 TRACE("iface %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p.\n"
874 "usage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
875 iface
, Width
, Height
, Format
, Lockable
, Discard
, Level
, ppSurface
,
876 Usage
, Pool
, MultiSample
, MultisampleQuality
);
878 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DSurface9Impl
));
881 FIXME("Failed to allocate surface memory.\n");
882 return D3DERR_OUTOFVIDEOMEMORY
;
885 hr
= surface_init(object
, This
, Width
, Height
, Format
, Lockable
, Discard
,
886 Level
, Usage
, Pool
, MultiSample
, MultisampleQuality
);
889 WARN("Failed to initialize surface, hr %#x.\n", hr
);
890 HeapFree(GetProcessHeap(), 0, object
);
894 TRACE("Created surface %p.\n", object
);
895 *ppSurface
= (IDirect3DSurface9
*)object
;
900 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateRenderTarget(IDirect3DDevice9Ex
*iface
, UINT Width
, UINT Height
,
901 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultisampleQuality
, BOOL Lockable
,
902 IDirect3DSurface9
**ppSurface
, HANDLE
*pSharedHandle
)
906 TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
907 "lockable %#x, surface %p, shared_handle %p.\n",
908 iface
, Width
, Height
, Format
, MultiSample
, MultisampleQuality
,
909 Lockable
, ppSurface
, pSharedHandle
);
911 hr
= IDirect3DDevice9Impl_CreateSurface(iface
, Width
, Height
, Format
, Lockable
, FALSE
/* Discard */,
912 0 /* Level */, ppSurface
, D3DUSAGE_RENDERTARGET
, D3DPOOL_DEFAULT
, MultiSample
, MultisampleQuality
);
917 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
918 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
919 DWORD MultisampleQuality
, BOOL Discard
,
920 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
923 TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
924 "discard %#x, surface %p, shared_handle %p.\n",
925 iface
, Width
, Height
, Format
, MultiSample
, MultisampleQuality
,
926 Discard
, ppSurface
, pSharedHandle
);
928 hr
= IDirect3DDevice9Impl_CreateSurface(iface
, Width
, Height
, Format
, TRUE
/* Lockable */, Discard
,
929 0 /* Level */, ppSurface
, D3DUSAGE_DEPTHSTENCIL
, D3DPOOL_DEFAULT
, MultiSample
, MultisampleQuality
);
935 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestinationSurface
, CONST POINT
* pDestPoint
) {
936 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
939 TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n",
940 iface
, pSourceSurface
, pSourceRect
, pDestinationSurface
, pDestPoint
);
942 wined3d_mutex_lock();
943 hr
= IWineD3DDevice_UpdateSurface(This
->WineD3DDevice
, ((IDirect3DSurface9Impl
*)pSourceSurface
)->wineD3DSurface
, pSourceRect
, ((IDirect3DSurface9Impl
*)pDestinationSurface
)->wineD3DSurface
, pDestPoint
);
944 wined3d_mutex_unlock();
949 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9EX iface
, IDirect3DBaseTexture9
* pSourceTexture
, IDirect3DBaseTexture9
* pDestinationTexture
) {
950 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
953 TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface
, pSourceTexture
, pDestinationTexture
);
955 wined3d_mutex_lock();
956 hr
= IWineD3DDevice_UpdateTexture(This
->WineD3DDevice
, ((IDirect3DBaseTexture9Impl
*)pSourceTexture
)->wineD3DBaseTexture
, ((IDirect3DBaseTexture9Impl
*)pDestinationTexture
)->wineD3DBaseTexture
);
957 wined3d_mutex_unlock();
962 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTargetData(IDirect3DDevice9Ex
*iface
,
963 IDirect3DSurface9
*pRenderTarget
, IDirect3DSurface9
*pDestSurface
)
965 IDirect3DSurface9Impl
*renderTarget
= (IDirect3DSurface9Impl
*)pRenderTarget
;
966 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
969 TRACE("iface %p, render_target %p, dst_surface %p.\n", iface
, pRenderTarget
, pDestSurface
);
971 wined3d_mutex_lock();
972 hr
= IWineD3DSurface_BltFast(destSurface
->wineD3DSurface
, 0, 0, renderTarget
->wineD3DSurface
, NULL
, WINEDDBLTFAST_NOCOLORKEY
);
973 wined3d_mutex_unlock();
978 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, IDirect3DSurface9
* pDestSurface
) {
979 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
980 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
983 TRACE("iface %p, swapchain %u, dst_surface %p.\n", iface
, iSwapChain
, pDestSurface
);
985 wined3d_mutex_lock();
986 hr
= IWineD3DDevice_GetFrontBufferData(This
->WineD3DDevice
, iSwapChain
, destSurface
->wineD3DSurface
);
987 wined3d_mutex_unlock();
992 static HRESULT WINAPI
IDirect3DDevice9Impl_StretchRect(IDirect3DDevice9Ex
*iface
, IDirect3DSurface9
*pSourceSurface
,
993 const RECT
*pSourceRect
, IDirect3DSurface9
*pDestSurface
, const RECT
*pDestRect
, D3DTEXTUREFILTERTYPE Filter
)
995 IDirect3DSurface9Impl
*src
= (IDirect3DSurface9Impl
*) pSourceSurface
;
996 IDirect3DSurface9Impl
*dst
= (IDirect3DSurface9Impl
*) pDestSurface
;
999 TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_rect %p, filter %#x.\n",
1000 iface
, pSourceSurface
, pSourceRect
, pDestSurface
, pDestRect
, Filter
);
1002 wined3d_mutex_lock();
1003 hr
= IWineD3DSurface_Blt(dst
->wineD3DSurface
, pDestRect
, src
->wineD3DSurface
, pSourceRect
, 0, NULL
, Filter
);
1004 wined3d_mutex_unlock();
1009 static HRESULT WINAPI
IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSurface
, CONST RECT
* pRect
, D3DCOLOR color
) {
1010 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1011 IDirect3DSurface9Impl
*surface
= (IDirect3DSurface9Impl
*)pSurface
;
1013 WINED3DRESOURCETYPE restype
;
1015 WINED3DSURFACE_DESC desc
;
1018 TRACE("iface %p, surface %p, rect %p, color 0x%08x.\n", iface
, pSurface
, pRect
, color
);
1020 wined3d_mutex_lock();
1022 IWineD3DSurface_GetDesc(surface
->wineD3DSurface
, &desc
);
1025 restype
= desc
.resource_type
;
1027 /* This method is only allowed with surfaces that are render targets, or offscreen plain surfaces
1028 * in D3DPOOL_DEFAULT
1030 if(!(usage
& WINED3DUSAGE_RENDERTARGET
) && (pool
!= WINED3DPOOL_DEFAULT
|| restype
!= WINED3DRTYPE_SURFACE
)) {
1031 wined3d_mutex_unlock();
1032 WARN("Surface is not a render target, or not a stand-alone D3DPOOL_DEFAULT surface\n");
1033 return D3DERR_INVALIDCALL
;
1036 /* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
1037 /* Note: D3DRECT is compatible with WINED3DRECT */
1038 hr
= IWineD3DDevice_ColorFill(This
->WineD3DDevice
, surface
->wineD3DSurface
, (CONST WINED3DRECT
*)pRect
, color
);
1040 wined3d_mutex_unlock();
1045 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
1048 TRACE("iface %p, width %u, height %u, format %#x, pool %#x, surface %p, shared_handle %p.\n",
1049 iface
, Width
, Height
, Format
, Pool
, ppSurface
, pSharedHandle
);
1051 if(Pool
== D3DPOOL_MANAGED
){
1052 FIXME("Attempting to create a managed offscreen plain surface\n");
1053 return D3DERR_INVALIDCALL
;
1056 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
1058 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
1059 Why, their always lockable?
1060 should I change the usage to dynamic?
1062 hr
= IDirect3DDevice9Impl_CreateSurface(iface
, Width
, Height
, Format
, TRUE
/* Lockable */, FALSE
/* Discard */,
1063 0 /* Level */, ppSurface
, 0 /* Usage (undefined/none) */, (WINED3DPOOL
)Pool
, D3DMULTISAMPLE_NONE
,
1064 0 /* MultisampleQuality */);
1069 /* TODO: move to wineD3D */
1070 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
* pRenderTarget
) {
1071 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1072 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pRenderTarget
;
1075 TRACE("iface %p, idx %u, surface %p.\n", iface
, RenderTargetIndex
, pRenderTarget
);
1077 if (RenderTargetIndex
>= D3D9_MAX_SIMULTANEOUS_RENDERTARGETS
)
1079 WARN("Invalid index %u specified.\n", RenderTargetIndex
);
1080 return D3DERR_INVALIDCALL
;
1083 wined3d_mutex_lock();
1084 hr
= IWineD3DDevice_SetRenderTarget(This
->WineD3DDevice
, RenderTargetIndex
, pSurface
? pSurface
->wineD3DSurface
: NULL
, TRUE
);
1085 wined3d_mutex_unlock();
1090 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
**ppRenderTarget
) {
1091 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1092 IWineD3DSurface
*pRenderTarget
;
1095 TRACE("iface %p, idx %u, surface %p.\n", iface
, RenderTargetIndex
, ppRenderTarget
);
1097 if (ppRenderTarget
== NULL
) {
1098 return D3DERR_INVALIDCALL
;
1101 if (RenderTargetIndex
>= D3D9_MAX_SIMULTANEOUS_RENDERTARGETS
)
1103 WARN("Invalid index %u specified.\n", RenderTargetIndex
);
1104 return D3DERR_INVALIDCALL
;
1107 wined3d_mutex_lock();
1109 hr
=IWineD3DDevice_GetRenderTarget(This
->WineD3DDevice
,RenderTargetIndex
,&pRenderTarget
);
1113 FIXME("Call to IWineD3DDevice_GetRenderTarget failed, hr %#x\n", hr
);
1115 else if (!pRenderTarget
)
1117 *ppRenderTarget
= NULL
;
1121 IWineD3DSurface_GetParent(pRenderTarget
, (IUnknown
**)ppRenderTarget
);
1122 IWineD3DSurface_Release(pRenderTarget
);
1125 wined3d_mutex_unlock();
1130 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pZStencilSurface
) {
1131 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1132 IDirect3DSurface9Impl
*pSurface
;
1135 TRACE("iface %p, depth_stencil %p.\n", iface
, pZStencilSurface
);
1137 pSurface
= (IDirect3DSurface9Impl
*)pZStencilSurface
;
1139 wined3d_mutex_lock();
1140 hr
= IWineD3DDevice_SetDepthStencilSurface(This
->WineD3DDevice
, NULL
==pSurface
? NULL
: pSurface
->wineD3DSurface
);
1141 wined3d_mutex_unlock();
1146 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
**ppZStencilSurface
) {
1147 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1148 HRESULT hr
= D3D_OK
;
1149 IWineD3DSurface
*pZStencilSurface
;
1151 TRACE("iface %p, depth_stencil %p.\n", iface
, ppZStencilSurface
);
1153 if(ppZStencilSurface
== NULL
){
1154 return D3DERR_INVALIDCALL
;
1157 wined3d_mutex_lock();
1158 hr
= IWineD3DDevice_GetDepthStencilSurface(This
->WineD3DDevice
,&pZStencilSurface
);
1159 if (hr
== WINED3D_OK
) {
1160 IWineD3DSurface_GetParent(pZStencilSurface
,(IUnknown
**)ppZStencilSurface
);
1161 IWineD3DSurface_Release(pZStencilSurface
);
1163 if (hr
!= WINED3DERR_NOTFOUND
)
1164 WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr
);
1165 *ppZStencilSurface
= NULL
;
1167 wined3d_mutex_unlock();
1172 static HRESULT WINAPI
IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX iface
) {
1173 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1176 TRACE("iface %p.\n", iface
);
1178 wined3d_mutex_lock();
1179 hr
= IWineD3DDevice_BeginScene(This
->WineD3DDevice
);
1180 wined3d_mutex_unlock();
1185 static HRESULT WINAPI DECLSPEC_HOTPATCH
IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface
) {
1186 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1189 TRACE("iface %p.\n", iface
);
1191 wined3d_mutex_lock();
1192 hr
= IWineD3DDevice_EndScene(This
->WineD3DDevice
);
1193 wined3d_mutex_unlock();
1198 static HRESULT WINAPI
IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9EX iface
, DWORD Count
, CONST D3DRECT
* pRects
, DWORD Flags
, D3DCOLOR Color
, float Z
, DWORD Stencil
) {
1199 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1202 TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %u.\n",
1203 iface
, Count
, pRects
, Flags
, Color
, Z
, Stencil
);
1205 /* Note: D3DRECT is compatible with WINED3DRECT */
1206 wined3d_mutex_lock();
1207 hr
= IWineD3DDevice_Clear(This
->WineD3DDevice
, Count
, (CONST WINED3DRECT
*) pRects
, Flags
, Color
, Z
, Stencil
);
1208 wined3d_mutex_unlock();
1213 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* lpMatrix
) {
1214 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1217 TRACE("iface %p, state %#x, matrix %p.\n", iface
, State
, lpMatrix
);
1219 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
1220 wined3d_mutex_lock();
1221 hr
= IWineD3DDevice_SetTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) lpMatrix
);
1222 wined3d_mutex_unlock();
1227 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, D3DMATRIX
* pMatrix
) {
1228 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1231 TRACE("iface %p, state %#x, matrix %p.\n", iface
, State
, pMatrix
);
1233 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
1234 wined3d_mutex_lock();
1235 hr
= IWineD3DDevice_GetTransform(This
->WineD3DDevice
, State
, (WINED3DMATRIX
*) pMatrix
);
1236 wined3d_mutex_unlock();
1241 static HRESULT WINAPI
IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* pMatrix
) {
1242 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1245 TRACE("iface %p, state %#x, matrix %p.\n", iface
, State
, pMatrix
);
1247 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
1248 wined3d_mutex_lock();
1249 hr
= IWineD3DDevice_MultiplyTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) pMatrix
);
1250 wined3d_mutex_unlock();
1255 static HRESULT WINAPI
IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9EX iface
, CONST D3DVIEWPORT9
* pViewport
) {
1256 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1259 TRACE("iface %p, viewport %p.\n", iface
, pViewport
);
1261 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
1262 wined3d_mutex_lock();
1263 hr
= IWineD3DDevice_SetViewport(This
->WineD3DDevice
, (const WINED3DVIEWPORT
*)pViewport
);
1264 wined3d_mutex_unlock();
1269 static HRESULT WINAPI
IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9EX iface
, D3DVIEWPORT9
* pViewport
) {
1270 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1273 TRACE("iface %p, viewport %p.\n", iface
, pViewport
);
1275 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
1276 wined3d_mutex_lock();
1277 hr
= IWineD3DDevice_GetViewport(This
->WineD3DDevice
, (WINED3DVIEWPORT
*)pViewport
);
1278 wined3d_mutex_unlock();
1283 static HRESULT WINAPI
IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9EX iface
, CONST D3DMATERIAL9
* pMaterial
) {
1284 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1287 TRACE("iface %p, material %p.\n", iface
, pMaterial
);
1289 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
1290 wined3d_mutex_lock();
1291 hr
= IWineD3DDevice_SetMaterial(This
->WineD3DDevice
, (const WINED3DMATERIAL
*)pMaterial
);
1292 wined3d_mutex_unlock();
1297 static HRESULT WINAPI
IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9EX iface
, D3DMATERIAL9
* pMaterial
) {
1298 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1301 TRACE("iface %p, material %p.\n", iface
, pMaterial
);
1303 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
1304 wined3d_mutex_lock();
1305 hr
= IWineD3DDevice_GetMaterial(This
->WineD3DDevice
, (WINED3DMATERIAL
*)pMaterial
);
1306 wined3d_mutex_unlock();
1311 static HRESULT WINAPI
IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST D3DLIGHT9
* pLight
) {
1312 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1315 TRACE("iface %p, index %u, light %p.\n", iface
, Index
, pLight
);
1317 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
1318 wined3d_mutex_lock();
1319 hr
= IWineD3DDevice_SetLight(This
->WineD3DDevice
, Index
, (const WINED3DLIGHT
*)pLight
);
1320 wined3d_mutex_unlock();
1325 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, D3DLIGHT9
* pLight
) {
1326 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1329 TRACE("iface %p, index %u, light %p.\n", iface
, Index
, pLight
);
1331 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
1332 wined3d_mutex_lock();
1333 hr
= IWineD3DDevice_GetLight(This
->WineD3DDevice
, Index
, (WINED3DLIGHT
*)pLight
);
1334 wined3d_mutex_unlock();
1339 static HRESULT WINAPI
IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL Enable
) {
1340 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1343 TRACE("iface %p, index %u, enable %#x.\n", iface
, Index
, Enable
);
1345 wined3d_mutex_lock();
1346 hr
= IWineD3DDevice_SetLightEnable(This
->WineD3DDevice
, Index
, Enable
);
1347 wined3d_mutex_unlock();
1352 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL
* pEnable
) {
1353 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1356 TRACE("iface %p, index %u, enable %p.\n", iface
, Index
, pEnable
);
1358 wined3d_mutex_lock();
1359 hr
= IWineD3DDevice_GetLightEnable(This
->WineD3DDevice
, Index
, pEnable
);
1360 wined3d_mutex_unlock();
1365 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST
float* pPlane
) {
1366 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1369 TRACE("iface %p, index %u, plane %p.\n", iface
, Index
, pPlane
);
1371 wined3d_mutex_lock();
1372 hr
= IWineD3DDevice_SetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
1373 wined3d_mutex_unlock();
1378 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, float* pPlane
) {
1379 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1382 TRACE("iface %p, index %u, plane %p.\n", iface
, Index
, pPlane
);
1384 wined3d_mutex_lock();
1385 hr
= IWineD3DDevice_GetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
1386 wined3d_mutex_unlock();
1391 static HRESULT WINAPI DECLSPEC_HOTPATCH
IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD Value
) {
1392 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1395 TRACE("iface %p, state %#x, value %#x.\n", iface
, State
, Value
);
1397 wined3d_mutex_lock();
1398 hr
= IWineD3DDevice_SetRenderState(This
->WineD3DDevice
, State
, Value
);
1399 wined3d_mutex_unlock();
1404 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD
* pValue
) {
1405 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1408 TRACE("iface %p, state %#x, value %p.\n", iface
, State
, pValue
);
1410 wined3d_mutex_lock();
1411 hr
= IWineD3DDevice_GetRenderState(This
->WineD3DDevice
, State
, pValue
);
1412 wined3d_mutex_unlock();
1417 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex
*iface
,
1418 D3DSTATEBLOCKTYPE type
, IDirect3DStateBlock9
**stateblock
)
1420 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1421 IDirect3DStateBlock9Impl
*object
;
1424 TRACE("iface %p, type %#x, stateblock %p.\n", iface
, type
, stateblock
);
1426 if (type
!= D3DSBT_ALL
&& type
!= D3DSBT_PIXELSTATE
&& type
!= D3DSBT_VERTEXSTATE
)
1428 WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL.\n");
1429 return D3DERR_INVALIDCALL
;
1432 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
1435 ERR("Failed to allocate stateblock memory.\n");
1436 return E_OUTOFMEMORY
;
1439 hr
= stateblock_init(object
, This
, type
, NULL
);
1442 WARN("Failed to initialize stateblock, hr %#x.\n", hr
);
1443 HeapFree(GetProcessHeap(), 0, object
);
1447 TRACE("Created stateblock %p.\n", object
);
1448 *stateblock
= (IDirect3DStateBlock9
*)object
;
1453 static HRESULT WINAPI
IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex
*iface
)
1455 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1458 TRACE("iface %p.\n", iface
);
1460 wined3d_mutex_lock();
1461 hr
= IWineD3DDevice_BeginStateBlock(This
->WineD3DDevice
);
1462 wined3d_mutex_unlock();
1467 static HRESULT WINAPI
IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex
*iface
, IDirect3DStateBlock9
**stateblock
)
1469 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1470 IWineD3DStateBlock
*wined3d_stateblock
;
1471 IDirect3DStateBlock9Impl
*object
;
1474 TRACE("iface %p, stateblock %p.\n", iface
, stateblock
);
1476 wined3d_mutex_lock();
1477 hr
= IWineD3DDevice_EndStateBlock(This
->WineD3DDevice
, &wined3d_stateblock
);
1478 wined3d_mutex_unlock();
1481 WARN("IWineD3DDevice_EndStateBlock() failed, hr %#x.\n", hr
);
1485 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
1488 ERR("Failed to allocate stateblock memory.\n");
1489 IWineD3DStateBlock_Release(wined3d_stateblock
);
1490 return E_OUTOFMEMORY
;
1493 hr
= stateblock_init(object
, This
, 0, wined3d_stateblock
);
1496 WARN("Failed to initialize stateblock, hr %#x.\n", hr
);
1497 IWineD3DStateBlock_Release(wined3d_stateblock
);
1498 HeapFree(GetProcessHeap(), 0, object
);
1502 TRACE("Created stateblock %p.\n", object
);
1503 *stateblock
= (IDirect3DStateBlock9
*)object
;
1508 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX iface
, CONST D3DCLIPSTATUS9
* pClipStatus
) {
1509 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1512 TRACE("iface %p, clip_status %p.\n", iface
, pClipStatus
);
1514 wined3d_mutex_lock();
1515 hr
= IWineD3DDevice_SetClipStatus(This
->WineD3DDevice
, (const WINED3DCLIPSTATUS
*)pClipStatus
);
1516 wined3d_mutex_unlock();
1521 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9EX iface
, D3DCLIPSTATUS9
* pClipStatus
) {
1522 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1525 TRACE("iface %p, clip_status %p.\n", iface
, pClipStatus
);
1527 wined3d_mutex_lock();
1528 hr
= IWineD3DDevice_GetClipStatus(This
->WineD3DDevice
, (WINED3DCLIPSTATUS
*)pClipStatus
);
1529 wined3d_mutex_unlock();
1534 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
**ppTexture
) {
1535 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1536 IWineD3DBaseTexture
*retTexture
= NULL
;
1537 HRESULT rc
= D3D_OK
;
1539 TRACE("iface %p, stage %u, texture %p.\n", iface
, Stage
, ppTexture
);
1541 if(ppTexture
== NULL
){
1542 return D3DERR_INVALIDCALL
;
1545 wined3d_mutex_lock();
1546 rc
= IWineD3DDevice_GetTexture(This
->WineD3DDevice
, Stage
, &retTexture
);
1547 if (SUCCEEDED(rc
) && NULL
!= retTexture
) {
1548 IWineD3DBaseTexture_GetParent(retTexture
, (IUnknown
**)ppTexture
);
1549 IWineD3DBaseTexture_Release(retTexture
);
1552 WARN("Call to get texture (%d) failed (%p)\n", Stage
, retTexture
);
1556 wined3d_mutex_unlock();
1561 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
* pTexture
) {
1562 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1565 TRACE("iface %p, stage %u, texture %p.\n", iface
, Stage
, pTexture
);
1567 wined3d_mutex_lock();
1568 hr
= IWineD3DDevice_SetTexture(This
->WineD3DDevice
, Stage
,
1569 pTexture
==NULL
? NULL
:((IDirect3DBaseTexture9Impl
*)pTexture
)->wineD3DBaseTexture
);
1570 wined3d_mutex_unlock();
1575 static const WINED3DTEXTURESTAGESTATETYPE tss_lookup
[] =
1577 WINED3DTSS_FORCE_DWORD
, /* 0, unused */
1578 WINED3DTSS_COLOROP
, /* 1, D3DTSS_COLOROP */
1579 WINED3DTSS_COLORARG1
, /* 2, D3DTSS_COLORARG1 */
1580 WINED3DTSS_COLORARG2
, /* 3, D3DTSS_COLORARG2 */
1581 WINED3DTSS_ALPHAOP
, /* 4, D3DTSS_ALPHAOP */
1582 WINED3DTSS_ALPHAARG1
, /* 5, D3DTSS_ALPHAARG1 */
1583 WINED3DTSS_ALPHAARG2
, /* 6, D3DTSS_ALPHAARG2 */
1584 WINED3DTSS_BUMPENVMAT00
, /* 7, D3DTSS_BUMPENVMAT00 */
1585 WINED3DTSS_BUMPENVMAT01
, /* 8, D3DTSS_BUMPENVMAT01 */
1586 WINED3DTSS_BUMPENVMAT10
, /* 9, D3DTSS_BUMPENVMAT10 */
1587 WINED3DTSS_BUMPENVMAT11
, /* 10, D3DTSS_BUMPENVMAT11 */
1588 WINED3DTSS_TEXCOORDINDEX
, /* 11, D3DTSS_TEXCOORDINDEX */
1589 WINED3DTSS_FORCE_DWORD
, /* 12, unused */
1590 WINED3DTSS_FORCE_DWORD
, /* 13, unused */
1591 WINED3DTSS_FORCE_DWORD
, /* 14, unused */
1592 WINED3DTSS_FORCE_DWORD
, /* 15, unused */
1593 WINED3DTSS_FORCE_DWORD
, /* 16, unused */
1594 WINED3DTSS_FORCE_DWORD
, /* 17, unused */
1595 WINED3DTSS_FORCE_DWORD
, /* 18, unused */
1596 WINED3DTSS_FORCE_DWORD
, /* 19, unused */
1597 WINED3DTSS_FORCE_DWORD
, /* 20, unused */
1598 WINED3DTSS_FORCE_DWORD
, /* 21, unused */
1599 WINED3DTSS_BUMPENVLSCALE
, /* 22, D3DTSS_BUMPENVLSCALE */
1600 WINED3DTSS_BUMPENVLOFFSET
, /* 23, D3DTSS_BUMPENVLOFFSET */
1601 WINED3DTSS_TEXTURETRANSFORMFLAGS
, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
1602 WINED3DTSS_FORCE_DWORD
, /* 25, unused */
1603 WINED3DTSS_COLORARG0
, /* 26, D3DTSS_COLORARG0 */
1604 WINED3DTSS_ALPHAARG0
, /* 27, D3DTSS_ALPHAARG0 */
1605 WINED3DTSS_RESULTARG
, /* 28, D3DTSS_RESULTARG */
1606 WINED3DTSS_FORCE_DWORD
, /* 29, unused */
1607 WINED3DTSS_FORCE_DWORD
, /* 30, unused */
1608 WINED3DTSS_FORCE_DWORD
, /* 31, unused */
1609 WINED3DTSS_CONSTANT
, /* 32, D3DTSS_CONSTANT */
1612 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD
* pValue
) {
1613 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1616 TRACE("iface %p, stage %u, state %#x, value %p.\n", iface
, Stage
, Type
, pValue
);
1618 wined3d_mutex_lock();
1619 hr
= IWineD3DDevice_GetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], pValue
);
1620 wined3d_mutex_unlock();
1625 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD Value
) {
1626 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1629 TRACE("iface %p, stage %u, state %#x, value %#x.\n", iface
, Stage
, Type
, Value
);
1631 wined3d_mutex_lock();
1632 hr
= IWineD3DDevice_SetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], Value
);
1633 wined3d_mutex_unlock();
1638 static HRESULT WINAPI
IDirect3DDevice9Impl_GetSamplerState(IDirect3DDevice9Ex
*iface
, DWORD Sampler
,
1639 D3DSAMPLERSTATETYPE Type
, DWORD
*pValue
)
1641 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1644 TRACE("iface %p, sampler %u, state %#x, value %p.\n", iface
, Sampler
, Type
, pValue
);
1646 wined3d_mutex_lock();
1647 hr
= IWineD3DDevice_GetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, pValue
);
1648 wined3d_mutex_unlock();
1653 static HRESULT WINAPI DECLSPEC_HOTPATCH
IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD Value
) {
1654 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1657 TRACE("iface %p, sampler %u, state %#x, value %#x.\n", iface
, Sampler
, Type
, Value
);
1659 wined3d_mutex_lock();
1660 hr
= IWineD3DDevice_SetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, Value
);
1661 wined3d_mutex_unlock();
1666 static HRESULT WINAPI
IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9EX iface
, DWORD
* pNumPasses
) {
1667 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1670 TRACE("iface %p, pass_count %p.\n", iface
, pNumPasses
);
1672 wined3d_mutex_lock();
1673 hr
= IWineD3DDevice_ValidateDevice(This
->WineD3DDevice
, pNumPasses
);
1674 wined3d_mutex_unlock();
1679 static HRESULT WINAPI
IDirect3DDevice9Impl_SetPaletteEntries(IDirect3DDevice9Ex
*iface
, UINT PaletteNumber
,
1680 const PALETTEENTRY
*pEntries
)
1682 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1685 TRACE("iface %p, palette_idx %u, entries %p.\n", iface
, PaletteNumber
, pEntries
);
1687 wined3d_mutex_lock();
1688 hr
= IWineD3DDevice_SetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1689 wined3d_mutex_unlock();
1694 static HRESULT WINAPI
IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
, PALETTEENTRY
* pEntries
) {
1695 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1698 TRACE("iface %p, palette_idx %u, entries %p.\n", iface
, PaletteNumber
, pEntries
);
1700 wined3d_mutex_lock();
1701 hr
= IWineD3DDevice_GetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1702 wined3d_mutex_unlock();
1707 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
) {
1708 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1711 TRACE("iface %p, palette_idx %u.\n", iface
, PaletteNumber
);
1713 wined3d_mutex_lock();
1714 hr
= IWineD3DDevice_SetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1715 wined3d_mutex_unlock();
1720 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT
* PaletteNumber
) {
1721 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1724 TRACE("iface %p, palette_idx %p.\n", iface
, PaletteNumber
);
1726 wined3d_mutex_lock();
1727 hr
= IWineD3DDevice_GetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1728 wined3d_mutex_unlock();
1733 static HRESULT WINAPI
IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9EX iface
, CONST RECT
* pRect
) {
1734 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1737 TRACE("iface %p, rect %p.\n", iface
, pRect
);
1739 wined3d_mutex_lock();
1740 hr
= IWineD3DDevice_SetScissorRect(This
->WineD3DDevice
, pRect
);
1741 wined3d_mutex_unlock();
1746 static HRESULT WINAPI
IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9EX iface
, RECT
* pRect
) {
1747 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1750 TRACE("iface %p, rect %p.\n", iface
, pRect
);
1752 wined3d_mutex_lock();
1753 hr
= IWineD3DDevice_GetScissorRect(This
->WineD3DDevice
, pRect
);
1754 wined3d_mutex_unlock();
1759 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
, BOOL bSoftware
) {
1760 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1763 TRACE("iface %p, software %#x.\n", iface
, bSoftware
);
1765 wined3d_mutex_lock();
1766 hr
= IWineD3DDevice_SetSoftwareVertexProcessing(This
->WineD3DDevice
, bSoftware
);
1767 wined3d_mutex_unlock();
1772 static BOOL WINAPI
IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
) {
1773 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1776 TRACE("iface %p.\n", iface
);
1778 wined3d_mutex_lock();
1779 ret
= IWineD3DDevice_GetSoftwareVertexProcessing(This
->WineD3DDevice
);
1780 wined3d_mutex_unlock();
1785 static HRESULT WINAPI
IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9EX iface
, float nSegments
) {
1786 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1789 TRACE("iface %p, segment_count %.8e.\n", iface
, nSegments
);
1791 wined3d_mutex_lock();
1792 hr
= IWineD3DDevice_SetNPatchMode(This
->WineD3DDevice
, nSegments
);
1793 wined3d_mutex_unlock();
1798 static float WINAPI
IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9EX iface
) {
1799 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1802 TRACE("iface %p.\n", iface
);
1804 wined3d_mutex_lock();
1805 ret
= IWineD3DDevice_GetNPatchMode(This
->WineD3DDevice
);
1806 wined3d_mutex_unlock();
1811 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitive(IDirect3DDevice9Ex
*iface
, D3DPRIMITIVETYPE PrimitiveType
,
1812 UINT StartVertex
, UINT PrimitiveCount
)
1814 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1817 TRACE("iface %p, primitive_type %#x, start_vertex %u, primitive_count %u.\n",
1818 iface
, PrimitiveType
, StartVertex
, PrimitiveCount
);
1820 wined3d_mutex_lock();
1821 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1822 hr
= IWineD3DDevice_DrawPrimitive(This
->WineD3DDevice
, StartVertex
,
1823 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
));
1824 wined3d_mutex_unlock();
1829 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
,
1830 INT BaseVertexIndex
, UINT MinVertexIndex
, UINT NumVertices
, UINT startIndex
, UINT primCount
) {
1831 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1834 TRACE("iface %p, primitive_type %#x, base_vertex_idx %u, min_vertex_idx %u,\n"
1835 "vertex_count %u, start_idx %u, primitive_count %u.\n",
1836 iface
, PrimitiveType
, BaseVertexIndex
, MinVertexIndex
,
1837 NumVertices
, startIndex
, primCount
);
1839 wined3d_mutex_lock();
1840 IWineD3DDevice_SetBaseVertexIndex(This
->WineD3DDevice
, BaseVertexIndex
);
1841 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1842 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->WineD3DDevice
, startIndex
,
1843 vertex_count_from_primitive_count(PrimitiveType
, primCount
));
1844 wined3d_mutex_unlock();
1849 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitiveUP(IDirect3DDevice9Ex
*iface
, D3DPRIMITIVETYPE PrimitiveType
,
1850 UINT PrimitiveCount
, const void *pVertexStreamZeroData
, UINT VertexStreamZeroStride
)
1852 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1855 TRACE("iface %p, primitive_type %#x, primitive_count %u, data %p, stride %u.\n",
1856 iface
, PrimitiveType
, PrimitiveCount
, pVertexStreamZeroData
, VertexStreamZeroStride
);
1858 wined3d_mutex_lock();
1859 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1860 hr
= IWineD3DDevice_DrawPrimitiveUP(This
->WineD3DDevice
,
1861 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
),
1862 pVertexStreamZeroData
, VertexStreamZeroStride
);
1863 wined3d_mutex_unlock();
1868 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT MinVertexIndex
,
1869 UINT NumVertexIndices
, UINT PrimitiveCount
, CONST
void* pIndexData
,
1870 D3DFORMAT IndexDataFormat
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1871 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1874 TRACE("iface %p, primitive_type %#x, min_vertex_idx %u, index_count %u, primitive_count %u,\n"
1875 "index_data %p, index_format %#x, vertex_data %p, vertex_stride %u.\n",
1876 iface
, PrimitiveType
, MinVertexIndex
, NumVertexIndices
, PrimitiveCount
,
1877 pIndexData
, IndexDataFormat
, pVertexStreamZeroData
, VertexStreamZeroStride
);
1879 wined3d_mutex_lock();
1880 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1881 hr
= IWineD3DDevice_DrawIndexedPrimitiveUP(This
->WineD3DDevice
,
1882 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
), pIndexData
,
1883 wined3dformat_from_d3dformat(IndexDataFormat
), pVertexStreamZeroData
, VertexStreamZeroStride
);
1884 wined3d_mutex_unlock();
1889 static HRESULT WINAPI
IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX iface
, UINT SrcStartIndex
, UINT DestIndex
, UINT VertexCount
, IDirect3DVertexBuffer9
* pDestBuffer
, IDirect3DVertexDeclaration9
* pVertexDecl
, DWORD Flags
) {
1890 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1891 IDirect3DVertexDeclaration9Impl
*Decl
= (IDirect3DVertexDeclaration9Impl
*) pVertexDecl
;
1893 IDirect3DVertexBuffer9Impl
*dest
= (IDirect3DVertexBuffer9Impl
*) pDestBuffer
;
1895 TRACE("iface %p, src_start_idx %u, dst_idx %u, vertex_count %u, dst_buffer %p, declaration %p, flags %#x.\n",
1896 iface
, SrcStartIndex
, DestIndex
, VertexCount
, pDestBuffer
, pVertexDecl
, Flags
);
1898 wined3d_mutex_lock();
1899 hr
= IWineD3DDevice_ProcessVertices(This
->WineD3DDevice
,SrcStartIndex
, DestIndex
, VertexCount
, dest
->wineD3DVertexBuffer
, Decl
? Decl
->wineD3DVertexDeclaration
: NULL
, Flags
, dest
->fvf
);
1900 wined3d_mutex_unlock();
1905 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateVertexDeclaration(IDirect3DDevice9Ex
*iface
,
1906 const D3DVERTEXELEMENT9
*elements
, IDirect3DVertexDeclaration9
**declaration
)
1908 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1909 IDirect3DVertexDeclaration9Impl
*object
;
1912 TRACE("iface %p, elements %p, declaration %p.\n", iface
, elements
, declaration
);
1916 WARN("Caller passed a NULL declaration, returning D3DERR_INVALIDCALL.\n");
1917 return D3DERR_INVALIDCALL
;
1920 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
1923 ERR("Failed to allocate vertex declaration memory.\n");
1924 return E_OUTOFMEMORY
;
1927 hr
= vertexdeclaration_init(object
, This
, elements
);
1930 WARN("Failed to initialize vertex declaration, hr %#x.\n", hr
);
1931 HeapFree(GetProcessHeap(), 0, object
);
1935 TRACE("Created vertex declaration %p.\n", object
);
1936 *declaration
= (IDirect3DVertexDeclaration9
*)object
;
1941 static IDirect3DVertexDeclaration9
*getConvertedDecl(IDirect3DDevice9Impl
*This
, DWORD fvf
) {
1943 D3DVERTEXELEMENT9
* elements
= NULL
;
1944 IDirect3DVertexDeclaration9
* pDecl
= NULL
;
1945 int p
, low
, high
; /* deliberately signed */
1946 IDirect3DVertexDeclaration9
**convertedDecls
= This
->convertedDecls
;
1948 TRACE("Searching for declaration for fvf %08x... ", fvf
);
1951 high
= This
->numConvertedDecls
- 1;
1952 while(low
<= high
) {
1953 p
= (low
+ high
) >> 1;
1955 if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
== fvf
) {
1956 TRACE("found %p\n", convertedDecls
[p
]);
1957 return convertedDecls
[p
];
1958 } else if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
< fvf
) {
1964 TRACE("not found. Creating and inserting at position %d.\n", low
);
1966 hr
= vdecl_convert_fvf(fvf
, &elements
);
1967 if (hr
!= S_OK
) return NULL
;
1969 hr
= IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9Ex
*) This
, elements
, &pDecl
);
1970 HeapFree(GetProcessHeap(), 0, elements
); /* CreateVertexDeclaration makes a copy */
1971 if (hr
!= S_OK
) return NULL
;
1973 if(This
->declArraySize
== This
->numConvertedDecls
) {
1974 int grow
= max(This
->declArraySize
/ 2, 8);
1975 convertedDecls
= HeapReAlloc(GetProcessHeap(), 0, convertedDecls
,
1976 sizeof(convertedDecls
[0]) * (This
->numConvertedDecls
+ grow
));
1977 if(!convertedDecls
) {
1978 /* This will destroy it */
1979 IDirect3DVertexDeclaration9_Release(pDecl
);
1982 This
->convertedDecls
= convertedDecls
;
1983 This
->declArraySize
+= grow
;
1986 memmove(convertedDecls
+ low
+ 1, convertedDecls
+ low
, sizeof(IDirect3DVertexDeclaration9Impl
*) * (This
->numConvertedDecls
- low
));
1987 convertedDecls
[low
] = pDecl
;
1988 This
->numConvertedDecls
++;
1990 /* Will prevent the decl from being destroyed */
1991 ((IDirect3DVertexDeclaration9Impl
*) pDecl
)->convFVF
= fvf
;
1992 IDirect3DVertexDeclaration9_Release(pDecl
); /* Does not destroy now */
1994 TRACE("Returning %p. %d decls in array\n", pDecl
, This
->numConvertedDecls
);
1998 static HRESULT WINAPI
IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface
, DWORD FVF
) {
1999 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2000 IDirect3DVertexDeclaration9
*decl
;
2003 TRACE("iface %p, fvf %#x.\n", iface
, FVF
);
2007 WARN("%#x is not a valid FVF\n", FVF
);
2011 wined3d_mutex_lock();
2012 decl
= getConvertedDecl(This
, FVF
);
2013 wined3d_mutex_unlock();
2017 /* Any situation when this should happen, except out of memory? */
2018 ERR("Failed to create a converted vertex declaration\n");
2019 return D3DERR_DRIVERINTERNALERROR
;
2022 hr
= IDirect3DDevice9Impl_SetVertexDeclaration(iface
, decl
);
2023 if (FAILED(hr
)) ERR("Failed to set vertex declaration\n");
2028 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFVF(IDirect3DDevice9Ex
*iface
, DWORD
*pFVF
)
2030 IDirect3DVertexDeclaration9
*decl
;
2033 TRACE("iface %p, fvf %p.\n", iface
, pFVF
);
2035 hr
= IDirect3DDevice9_GetVertexDeclaration(iface
, &decl
);
2038 WARN("Failed to get vertex declaration, %#x\n", hr
);
2045 *pFVF
= ((IDirect3DVertexDeclaration9Impl
*)decl
)->convFVF
;
2046 IDirect3DVertexDeclaration9_Release(decl
);
2053 TRACE("Returning FVF %#x\n", *pFVF
);
2058 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateVertexShader(IDirect3DDevice9Ex
*iface
,
2059 const DWORD
*byte_code
, IDirect3DVertexShader9
**shader
)
2061 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2062 IDirect3DVertexShader9Impl
*object
;
2065 TRACE("iface %p, byte_code %p, shader %p.\n", iface
, byte_code
, shader
);
2067 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2070 ERR("Failed to allocate vertex shader memory.\n");
2071 return E_OUTOFMEMORY
;
2074 hr
= vertexshader_init(object
, This
, byte_code
);
2077 WARN("Failed to initialize vertex shader, hr %#x.\n", hr
);
2078 HeapFree(GetProcessHeap(), 0, object
);
2082 TRACE("Created vertex shader %p.\n", object
);
2083 *shader
= (IDirect3DVertexShader9
*)object
;
2088 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
* pStreamData
, UINT OffsetInBytes
, UINT Stride
) {
2089 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2092 TRACE("iface %p, stream_idx %u, buffer %p, offset %u, stride %u.\n",
2093 iface
, StreamNumber
, pStreamData
, OffsetInBytes
, Stride
);
2095 wined3d_mutex_lock();
2096 hr
= IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, StreamNumber
,
2097 pStreamData
? ((IDirect3DVertexBuffer9Impl
*)pStreamData
)->wineD3DVertexBuffer
: NULL
,
2098 OffsetInBytes
, Stride
);
2099 wined3d_mutex_unlock();
2104 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
**pStream
, UINT
* OffsetInBytes
, UINT
* pStride
) {
2105 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2106 IWineD3DBuffer
*retStream
= NULL
;
2107 HRESULT rc
= D3D_OK
;
2109 TRACE("iface %p, stream_idx %u, buffer %p, offset %p, stride %p.\n",
2110 iface
, StreamNumber
, pStream
, OffsetInBytes
, pStride
);
2112 if(pStream
== NULL
){
2113 return D3DERR_INVALIDCALL
;
2116 wined3d_mutex_lock();
2117 rc
= IWineD3DDevice_GetStreamSource(This
->WineD3DDevice
, StreamNumber
, &retStream
, OffsetInBytes
, pStride
);
2118 if (rc
== D3D_OK
&& NULL
!= retStream
) {
2119 IWineD3DBuffer_GetParent(retStream
, (IUnknown
**)pStream
);
2120 IWineD3DBuffer_Release(retStream
);
2123 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes
, pStride
);
2127 wined3d_mutex_unlock();
2132 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSourceFreq(IDirect3DDevice9Ex
*iface
, UINT StreamNumber
,
2135 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2138 TRACE("iface %p, stream_idx %u, freq %u.\n", iface
, StreamNumber
, Divider
);
2140 wined3d_mutex_lock();
2141 hr
= IWineD3DDevice_SetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
2142 wined3d_mutex_unlock();
2147 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, UINT
* Divider
) {
2148 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2151 TRACE("iface %p, stream_idx %u, freq %p.\n", iface
, StreamNumber
, Divider
);
2153 wined3d_mutex_lock();
2154 hr
= IWineD3DDevice_GetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
2155 wined3d_mutex_unlock();
2160 static HRESULT WINAPI
IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
* pIndexData
) {
2161 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2163 IDirect3DIndexBuffer9Impl
*ib
= (IDirect3DIndexBuffer9Impl
*) pIndexData
;
2165 TRACE("iface %p, buffer %p.\n", iface
, pIndexData
);
2167 wined3d_mutex_lock();
2168 hr
= IWineD3DDevice_SetIndexBuffer(This
->WineD3DDevice
,
2169 ib
? ib
->wineD3DIndexBuffer
: NULL
,
2170 ib
? ib
->format
: WINED3DFMT_UNKNOWN
);
2171 wined3d_mutex_unlock();
2176 static HRESULT WINAPI
IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
**ppIndexData
) {
2177 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2178 IWineD3DBuffer
*retIndexData
= NULL
;
2179 HRESULT rc
= D3D_OK
;
2181 TRACE("iface %p, buffer %p.\n", iface
, ppIndexData
);
2183 if(ppIndexData
== NULL
){
2184 return D3DERR_INVALIDCALL
;
2187 wined3d_mutex_lock();
2188 rc
= IWineD3DDevice_GetIndexBuffer(This
->WineD3DDevice
, &retIndexData
);
2189 if (SUCCEEDED(rc
) && retIndexData
) {
2190 IWineD3DBuffer_GetParent(retIndexData
, (IUnknown
**)ppIndexData
);
2191 IWineD3DBuffer_Release(retIndexData
);
2193 if (FAILED(rc
)) FIXME("Call to GetIndices failed\n");
2194 *ppIndexData
= NULL
;
2196 wined3d_mutex_unlock();
2201 static HRESULT WINAPI
IDirect3DDevice9Impl_CreatePixelShader(IDirect3DDevice9Ex
*iface
,
2202 const DWORD
*byte_code
, IDirect3DPixelShader9
**shader
)
2204 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2205 IDirect3DPixelShader9Impl
*object
;
2208 TRACE("iface %p, byte_code %p, shader %p.\n", iface
, byte_code
, shader
);
2210 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2213 FIXME("Failed to allocate pixel shader memory.\n");
2214 return E_OUTOFMEMORY
;
2217 hr
= pixelshader_init(object
, This
, byte_code
);
2220 WARN("Failed to initialize pixel shader, hr %#x.\n", hr
);
2221 HeapFree(GetProcessHeap(), 0, object
);
2225 TRACE("Created pixel shader %p.\n", object
);
2226 *shader
= (IDirect3DPixelShader9
*)object
;
2231 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DRECTPATCH_INFO
* pRectPatchInfo
) {
2232 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2235 TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n",
2236 iface
, Handle
, pNumSegs
, pRectPatchInfo
);
2238 wined3d_mutex_lock();
2239 hr
= IWineD3DDevice_DrawRectPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DRECTPATCH_INFO
*)pRectPatchInfo
);
2240 wined3d_mutex_unlock();
2245 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DTRIPATCH_INFO
* pTriPatchInfo
) {
2246 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2249 TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n",
2250 iface
, Handle
, pNumSegs
, pTriPatchInfo
);
2252 wined3d_mutex_lock();
2253 hr
= IWineD3DDevice_DrawTriPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DTRIPATCH_INFO
*)pTriPatchInfo
);
2254 wined3d_mutex_unlock();
2259 static HRESULT WINAPI
IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
) {
2260 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2263 TRACE("iface %p, handle %#x.\n", iface
, Handle
);
2265 wined3d_mutex_lock();
2266 hr
= IWineD3DDevice_DeletePatch(This
->WineD3DDevice
, Handle
);
2267 wined3d_mutex_unlock();
2272 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex
*iface
,
2273 D3DQUERYTYPE type
, IDirect3DQuery9
**query
)
2275 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2276 IDirect3DQuery9Impl
*object
;
2279 TRACE("iface %p, type %#x, query %p.\n", iface
, type
, query
);
2281 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2284 ERR("Failed to allocate query memory.\n");
2285 return E_OUTOFMEMORY
;
2288 hr
= query_init(object
, This
, type
);
2291 WARN("Failed to initialize query, hr %#x.\n", hr
);
2292 HeapFree(GetProcessHeap(), 0, object
);
2296 TRACE("Created query %p.\n", object
);
2297 if (query
) *query
= (IDirect3DQuery9
*)object
;
2298 else IDirect3DQuery9_Release((IDirect3DQuery9
*)object
);
2303 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(IDirect3DDevice9Ex
*iface
,
2304 UINT width
, UINT height
, float *rows
, float *columns
)
2306 FIXME("iface %p, width %u, height %u, rows %p, columns %p stub!\n",
2307 iface
, width
, height
, rows
, columns
);
2309 return WINED3DERR_INVALIDCALL
;
2312 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ComposeRects(IDirect3DDevice9Ex
*iface
,
2313 IDirect3DSurface9
*src_surface
, IDirect3DSurface9
*dst_surface
, IDirect3DVertexBuffer9
*src_descs
,
2314 UINT rect_count
, IDirect3DVertexBuffer9
*dst_descs
, D3DCOMPOSERECTSOP operation
, INT offset_x
, INT offset_y
)
2316 FIXME("iface %p, src_surface %p, dst_surface %p, src_descs %p, rect_count %u,\n"
2317 "dst_descs %p, operation %#x, offset_x %u, offset_y %u stub!\n",
2318 iface
, src_surface
, dst_surface
, src_descs
, rect_count
,
2319 dst_descs
, operation
, offset_x
, offset_y
);
2321 return WINED3DERR_INVALIDCALL
;
2324 static HRESULT WINAPI
IDirect3DDevice9ExImpl_PresentEx(IDirect3DDevice9Ex
*iface
,
2325 const RECT
*src_rect
, const RECT
*dst_rect
, HWND dst_window_override
,
2326 const RGNDATA
*dirty_region
, DWORD flags
)
2328 FIXME("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p, flags %#x stub!\n",
2329 iface
, src_rect
, dst_rect
, dst_window_override
, dirty_region
, flags
);
2331 return WINED3DERR_INVALIDCALL
;
2334 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetGPUThreadPriority(IDirect3DDevice9Ex
*iface
, INT
*priority
)
2336 FIXME("iface %p, priority %p stub!\n", iface
, priority
);
2338 return WINED3DERR_INVALIDCALL
;
2341 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetGPUThreadPriority(IDirect3DDevice9Ex
*iface
, INT priority
)
2343 FIXME("iface %p, priority %d stub!\n", iface
, priority
);
2345 return WINED3DERR_INVALIDCALL
;
2348 static HRESULT WINAPI
IDirect3DDevice9ExImpl_WaitForVBlank(IDirect3DDevice9Ex
*iface
, UINT swapchain_idx
)
2350 FIXME("iface %p, swapchain_idx %u stub!\n", iface
, swapchain_idx
);
2352 return WINED3DERR_INVALIDCALL
;
2355 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckResourceResidency(IDirect3DDevice9Ex
*iface
,
2356 IDirect3DResource9
**resources
, UINT32 resource_count
)
2358 FIXME("iface %p, resources %p, resource_count %u stub!\n",
2359 iface
, resources
, resource_count
);
2361 return WINED3DERR_INVALIDCALL
;
2364 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetMaximumFrameLatency(IDirect3DDevice9Ex
*iface
, UINT max_latency
)
2366 FIXME("iface %p, max_latency %u stub!\n", iface
, max_latency
);
2368 return WINED3DERR_INVALIDCALL
;
2371 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetMaximumFrameLatency(IDirect3DDevice9Ex
*iface
, UINT
*max_latency
)
2373 FIXME("iface %p, max_latency %p stub!\n", iface
, max_latency
);
2377 return WINED3DERR_INVALIDCALL
;
2380 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckDeviceState(IDirect3DDevice9Ex
*iface
, HWND dst_window
)
2382 FIXME("iface %p, dst_window %p stub!\n", iface
, dst_window
);
2384 return WINED3DERR_INVALIDCALL
;
2387 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CreateRenderTargetEx(IDirect3DDevice9Ex
*iface
,
2388 UINT width
, UINT height
, D3DFORMAT format
, D3DMULTISAMPLE_TYPE multisample_type
, DWORD multisample_quality
,
2389 BOOL lockable
, IDirect3DSurface9
**surface
, HANDLE
*shared_handle
, DWORD usage
)
2391 FIXME("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u,\n"
2392 "lockable %#x, surface %p, shared_handle %p, usage %#x stub!\n",
2393 iface
, width
, height
, format
, multisample_type
, multisample_quality
,
2394 lockable
, surface
, shared_handle
, usage
);
2396 return WINED3DERR_INVALIDCALL
;
2399 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx(IDirect3DDevice9Ex
*iface
,
2400 UINT width
, UINT height
, D3DFORMAT format
, D3DPOOL pool
, IDirect3DSurface9
**surface
,
2401 HANDLE
*shared_handle
, DWORD usage
)
2403 FIXME("iface %p, width %u, height %u, format %#x, pool %#x, surface %p, shared_handle %p, usage %#x stub!\n",
2404 iface
, width
, height
, format
, pool
, surface
, shared_handle
, usage
);
2406 return WINED3DERR_INVALIDCALL
;
2409 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx(IDirect3DDevice9Ex
*iface
,
2410 UINT width
, UINT height
, D3DFORMAT format
, D3DMULTISAMPLE_TYPE multisample_type
, DWORD multisample_quality
,
2411 BOOL discard
, IDirect3DSurface9
**surface
, HANDLE
*shared_handle
, DWORD usage
)
2413 FIXME("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u,\n"
2414 "discard %#x, surface %p, shared_handle %p, usage %#x stub!\n",
2415 iface
, width
, height
, format
, multisample_type
, multisample_quality
,
2416 discard
, surface
, shared_handle
, usage
);
2418 return WINED3DERR_INVALIDCALL
;
2421 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ResetEx(IDirect3DDevice9Ex
*iface
,
2422 D3DPRESENT_PARAMETERS
*present_parameters
, D3DDISPLAYMODEEX
*mode
)
2424 FIXME("iface %p, present_parameters %p, mode %p stub!\n", iface
, present_parameters
, mode
);
2426 return WINED3DERR_INVALIDCALL
;
2429 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetDisplayModeEx(IDirect3DDevice9Ex
*iface
,
2430 UINT swapchain_idx
, D3DDISPLAYMODEEX
*mode
, D3DDISPLAYROTATION
*rotation
)
2432 FIXME("iface %p, swapchain_idx %u, mode %p, rotation %p stub!\n", iface
, swapchain_idx
, mode
, rotation
);
2434 return WINED3DERR_INVALIDCALL
;
2437 static const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl
=
2440 IDirect3DDevice9Impl_QueryInterface
,
2441 IDirect3DDevice9Impl_AddRef
,
2442 IDirect3DDevice9Impl_Release
,
2443 /* IDirect3DDevice9 */
2444 IDirect3DDevice9Impl_TestCooperativeLevel
,
2445 IDirect3DDevice9Impl_GetAvailableTextureMem
,
2446 IDirect3DDevice9Impl_EvictManagedResources
,
2447 IDirect3DDevice9Impl_GetDirect3D
,
2448 IDirect3DDevice9Impl_GetDeviceCaps
,
2449 IDirect3DDevice9Impl_GetDisplayMode
,
2450 IDirect3DDevice9Impl_GetCreationParameters
,
2451 IDirect3DDevice9Impl_SetCursorProperties
,
2452 IDirect3DDevice9Impl_SetCursorPosition
,
2453 IDirect3DDevice9Impl_ShowCursor
,
2454 IDirect3DDevice9Impl_CreateAdditionalSwapChain
,
2455 IDirect3DDevice9Impl_GetSwapChain
,
2456 IDirect3DDevice9Impl_GetNumberOfSwapChains
,
2457 IDirect3DDevice9Impl_Reset
,
2458 IDirect3DDevice9Impl_Present
,
2459 IDirect3DDevice9Impl_GetBackBuffer
,
2460 IDirect3DDevice9Impl_GetRasterStatus
,
2461 IDirect3DDevice9Impl_SetDialogBoxMode
,
2462 IDirect3DDevice9Impl_SetGammaRamp
,
2463 IDirect3DDevice9Impl_GetGammaRamp
,
2464 IDirect3DDevice9Impl_CreateTexture
,
2465 IDirect3DDevice9Impl_CreateVolumeTexture
,
2466 IDirect3DDevice9Impl_CreateCubeTexture
,
2467 IDirect3DDevice9Impl_CreateVertexBuffer
,
2468 IDirect3DDevice9Impl_CreateIndexBuffer
,
2469 IDirect3DDevice9Impl_CreateRenderTarget
,
2470 IDirect3DDevice9Impl_CreateDepthStencilSurface
,
2471 IDirect3DDevice9Impl_UpdateSurface
,
2472 IDirect3DDevice9Impl_UpdateTexture
,
2473 IDirect3DDevice9Impl_GetRenderTargetData
,
2474 IDirect3DDevice9Impl_GetFrontBufferData
,
2475 IDirect3DDevice9Impl_StretchRect
,
2476 IDirect3DDevice9Impl_ColorFill
,
2477 IDirect3DDevice9Impl_CreateOffscreenPlainSurface
,
2478 IDirect3DDevice9Impl_SetRenderTarget
,
2479 IDirect3DDevice9Impl_GetRenderTarget
,
2480 IDirect3DDevice9Impl_SetDepthStencilSurface
,
2481 IDirect3DDevice9Impl_GetDepthStencilSurface
,
2482 IDirect3DDevice9Impl_BeginScene
,
2483 IDirect3DDevice9Impl_EndScene
,
2484 IDirect3DDevice9Impl_Clear
,
2485 IDirect3DDevice9Impl_SetTransform
,
2486 IDirect3DDevice9Impl_GetTransform
,
2487 IDirect3DDevice9Impl_MultiplyTransform
,
2488 IDirect3DDevice9Impl_SetViewport
,
2489 IDirect3DDevice9Impl_GetViewport
,
2490 IDirect3DDevice9Impl_SetMaterial
,
2491 IDirect3DDevice9Impl_GetMaterial
,
2492 IDirect3DDevice9Impl_SetLight
,
2493 IDirect3DDevice9Impl_GetLight
,
2494 IDirect3DDevice9Impl_LightEnable
,
2495 IDirect3DDevice9Impl_GetLightEnable
,
2496 IDirect3DDevice9Impl_SetClipPlane
,
2497 IDirect3DDevice9Impl_GetClipPlane
,
2498 IDirect3DDevice9Impl_SetRenderState
,
2499 IDirect3DDevice9Impl_GetRenderState
,
2500 IDirect3DDevice9Impl_CreateStateBlock
,
2501 IDirect3DDevice9Impl_BeginStateBlock
,
2502 IDirect3DDevice9Impl_EndStateBlock
,
2503 IDirect3DDevice9Impl_SetClipStatus
,
2504 IDirect3DDevice9Impl_GetClipStatus
,
2505 IDirect3DDevice9Impl_GetTexture
,
2506 IDirect3DDevice9Impl_SetTexture
,
2507 IDirect3DDevice9Impl_GetTextureStageState
,
2508 IDirect3DDevice9Impl_SetTextureStageState
,
2509 IDirect3DDevice9Impl_GetSamplerState
,
2510 IDirect3DDevice9Impl_SetSamplerState
,
2511 IDirect3DDevice9Impl_ValidateDevice
,
2512 IDirect3DDevice9Impl_SetPaletteEntries
,
2513 IDirect3DDevice9Impl_GetPaletteEntries
,
2514 IDirect3DDevice9Impl_SetCurrentTexturePalette
,
2515 IDirect3DDevice9Impl_GetCurrentTexturePalette
,
2516 IDirect3DDevice9Impl_SetScissorRect
,
2517 IDirect3DDevice9Impl_GetScissorRect
,
2518 IDirect3DDevice9Impl_SetSoftwareVertexProcessing
,
2519 IDirect3DDevice9Impl_GetSoftwareVertexProcessing
,
2520 IDirect3DDevice9Impl_SetNPatchMode
,
2521 IDirect3DDevice9Impl_GetNPatchMode
,
2522 IDirect3DDevice9Impl_DrawPrimitive
,
2523 IDirect3DDevice9Impl_DrawIndexedPrimitive
,
2524 IDirect3DDevice9Impl_DrawPrimitiveUP
,
2525 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP
,
2526 IDirect3DDevice9Impl_ProcessVertices
,
2527 IDirect3DDevice9Impl_CreateVertexDeclaration
,
2528 IDirect3DDevice9Impl_SetVertexDeclaration
,
2529 IDirect3DDevice9Impl_GetVertexDeclaration
,
2530 IDirect3DDevice9Impl_SetFVF
,
2531 IDirect3DDevice9Impl_GetFVF
,
2532 IDirect3DDevice9Impl_CreateVertexShader
,
2533 IDirect3DDevice9Impl_SetVertexShader
,
2534 IDirect3DDevice9Impl_GetVertexShader
,
2535 IDirect3DDevice9Impl_SetVertexShaderConstantF
,
2536 IDirect3DDevice9Impl_GetVertexShaderConstantF
,
2537 IDirect3DDevice9Impl_SetVertexShaderConstantI
,
2538 IDirect3DDevice9Impl_GetVertexShaderConstantI
,
2539 IDirect3DDevice9Impl_SetVertexShaderConstantB
,
2540 IDirect3DDevice9Impl_GetVertexShaderConstantB
,
2541 IDirect3DDevice9Impl_SetStreamSource
,
2542 IDirect3DDevice9Impl_GetStreamSource
,
2543 IDirect3DDevice9Impl_SetStreamSourceFreq
,
2544 IDirect3DDevice9Impl_GetStreamSourceFreq
,
2545 IDirect3DDevice9Impl_SetIndices
,
2546 IDirect3DDevice9Impl_GetIndices
,
2547 IDirect3DDevice9Impl_CreatePixelShader
,
2548 IDirect3DDevice9Impl_SetPixelShader
,
2549 IDirect3DDevice9Impl_GetPixelShader
,
2550 IDirect3DDevice9Impl_SetPixelShaderConstantF
,
2551 IDirect3DDevice9Impl_GetPixelShaderConstantF
,
2552 IDirect3DDevice9Impl_SetPixelShaderConstantI
,
2553 IDirect3DDevice9Impl_GetPixelShaderConstantI
,
2554 IDirect3DDevice9Impl_SetPixelShaderConstantB
,
2555 IDirect3DDevice9Impl_GetPixelShaderConstantB
,
2556 IDirect3DDevice9Impl_DrawRectPatch
,
2557 IDirect3DDevice9Impl_DrawTriPatch
,
2558 IDirect3DDevice9Impl_DeletePatch
,
2559 IDirect3DDevice9Impl_CreateQuery
,
2560 /* IDirect3DDevice9Ex */
2561 IDirect3DDevice9ExImpl_SetConvolutionMonoKernel
,
2562 IDirect3DDevice9ExImpl_ComposeRects
,
2563 IDirect3DDevice9ExImpl_PresentEx
,
2564 IDirect3DDevice9ExImpl_GetGPUThreadPriority
,
2565 IDirect3DDevice9ExImpl_SetGPUThreadPriority
,
2566 IDirect3DDevice9ExImpl_WaitForVBlank
,
2567 IDirect3DDevice9ExImpl_CheckResourceResidency
,
2568 IDirect3DDevice9ExImpl_SetMaximumFrameLatency
,
2569 IDirect3DDevice9ExImpl_GetMaximumFrameLatency
,
2570 IDirect3DDevice9ExImpl_CheckDeviceState
,
2571 IDirect3DDevice9ExImpl_CreateRenderTargetEx
,
2572 IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx
,
2573 IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx
,
2574 IDirect3DDevice9ExImpl_ResetEx
,
2575 IDirect3DDevice9ExImpl_GetDisplayModeEx
2578 /* IWineD3DDeviceParent IUnknown methods */
2580 static inline struct IDirect3DDevice9Impl
*device_from_device_parent(IWineD3DDeviceParent
*iface
)
2582 return (struct IDirect3DDevice9Impl
*)((char*)iface
2583 - FIELD_OFFSET(struct IDirect3DDevice9Impl
, device_parent_vtbl
));
2586 static HRESULT STDMETHODCALLTYPE
device_parent_QueryInterface(IWineD3DDeviceParent
*iface
, REFIID riid
, void **object
)
2588 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2589 return IDirect3DDevice9Impl_QueryInterface((IDirect3DDevice9Ex
*)This
, riid
, object
);
2592 static ULONG STDMETHODCALLTYPE
device_parent_AddRef(IWineD3DDeviceParent
*iface
)
2594 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2595 return IDirect3DDevice9Impl_AddRef((IDirect3DDevice9Ex
*)This
);
2598 static ULONG STDMETHODCALLTYPE
device_parent_Release(IWineD3DDeviceParent
*iface
)
2600 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2601 return IDirect3DDevice9Impl_Release((IDirect3DDevice9Ex
*)This
);
2604 /* IWineD3DDeviceParent methods */
2606 static void STDMETHODCALLTYPE
device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent
*iface
, IWineD3DDevice
*device
)
2608 TRACE("iface %p, device %p\n", iface
, device
);
2611 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSurface(IWineD3DDeviceParent
*iface
,
2612 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, DWORD usage
,
2613 WINED3DPOOL pool
, UINT level
, WINED3DCUBEMAP_FACES face
, IWineD3DSurface
**surface
)
2615 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2616 IDirect3DSurface9Impl
*d3d_surface
;
2617 BOOL lockable
= TRUE
;
2620 TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
2621 "\tpool %#x, level %u, face %u, surface %p\n",
2622 iface
, superior
, width
, height
, format
, usage
, pool
, level
, face
, surface
);
2624 if (pool
== WINED3DPOOL_DEFAULT
&& !(usage
& D3DUSAGE_DYNAMIC
))
2627 hr
= IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex
*)This
, width
, height
,
2628 d3dformat_from_wined3dformat(format
), lockable
, FALSE
/* Discard */, level
,
2629 (IDirect3DSurface9
**)&d3d_surface
, usage
, pool
, D3DMULTISAMPLE_NONE
, 0 /* MultisampleQuality */);
2632 ERR("(%p) CreateSurface failed, returning %#x\n", iface
, hr
);
2636 *surface
= d3d_surface
->wineD3DSurface
;
2637 IWineD3DSurface_AddRef(*surface
);
2639 d3d_surface
->container
= superior
;
2640 IDirect3DDevice9Ex_Release(d3d_surface
->parentDevice
);
2641 d3d_surface
->parentDevice
= NULL
;
2643 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2644 d3d_surface
->forwardReference
= superior
;
2649 static HRESULT STDMETHODCALLTYPE
device_parent_CreateRenderTarget(IWineD3DDeviceParent
*iface
,
2650 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
2651 DWORD multisample_quality
, BOOL lockable
, IWineD3DSurface
**surface
)
2653 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2654 IDirect3DSurface9Impl
*d3d_surface
;
2657 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2658 "\tmultisample_quality %u, lockable %u, surface %p\n",
2659 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, lockable
, surface
);
2661 hr
= IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex
*)This
, width
, height
,
2662 d3dformat_from_wined3dformat(format
), multisample_type
, multisample_quality
, lockable
,
2663 (IDirect3DSurface9
**)&d3d_surface
, NULL
);
2666 ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface
, hr
);
2670 *surface
= d3d_surface
->wineD3DSurface
;
2671 IWineD3DSurface_AddRef(*surface
);
2673 d3d_surface
->container
= superior
;
2674 /* Implicit surfaces are created with an refcount of 0 */
2675 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2680 static HRESULT STDMETHODCALLTYPE
device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent
*iface
,
2681 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
2682 DWORD multisample_quality
, BOOL discard
, IWineD3DSurface
**surface
)
2684 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2685 IDirect3DSurface9Impl
*d3d_surface
;
2688 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2689 "\tmultisample_quality %u, discard %u, surface %p\n",
2690 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, discard
, surface
);
2692 hr
= IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex
*)This
, width
, height
,
2693 d3dformat_from_wined3dformat(format
), multisample_type
, multisample_quality
, discard
,
2694 (IDirect3DSurface9
**)&d3d_surface
, NULL
);
2697 ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface
, hr
);
2701 *surface
= d3d_surface
->wineD3DSurface
;
2702 IWineD3DSurface_AddRef(*surface
);
2703 d3d_surface
->container
= (IUnknown
*)This
;
2704 /* Implicit surfaces are created with an refcount of 0 */
2705 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2710 static HRESULT STDMETHODCALLTYPE
device_parent_CreateVolume(IWineD3DDeviceParent
*iface
,
2711 IUnknown
*superior
, UINT width
, UINT height
, UINT depth
, WINED3DFORMAT format
,
2712 WINED3DPOOL pool
, DWORD usage
, IWineD3DVolume
**volume
)
2714 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2715 IDirect3DVolume9Impl
*object
;
2718 TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
2719 iface
, superior
, width
, height
, depth
, format
, pool
, usage
, volume
);
2721 /* Allocate the storage for the device */
2722 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2725 FIXME("Allocation of memory failed\n");
2727 return D3DERR_OUTOFVIDEOMEMORY
;
2730 hr
= volume_init(object
, This
, width
, height
, depth
, usage
, format
, pool
);
2733 WARN("Failed to initialize volume, hr %#x.\n", hr
);
2734 HeapFree(GetProcessHeap(), 0, object
);
2738 *volume
= object
->wineD3DVolume
;
2739 IWineD3DVolume_AddRef(*volume
);
2740 IDirect3DVolume9_Release((IDirect3DVolume9
*)object
);
2742 object
->container
= superior
;
2743 object
->forwardReference
= superior
;
2745 TRACE("(%p) Created volume %p\n", iface
, object
);
2750 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSwapChain(IWineD3DDeviceParent
*iface
,
2751 WINED3DPRESENT_PARAMETERS
*present_parameters
, IWineD3DSwapChain
**swapchain
)
2753 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2754 IDirect3DSwapChain9Impl
*d3d_swapchain
;
2755 D3DPRESENT_PARAMETERS local_parameters
;
2758 TRACE("iface %p, present_parameters %p, swapchain %p\n", iface
, present_parameters
, swapchain
);
2760 /* Copy the presentation parameters */
2761 local_parameters
.BackBufferWidth
= present_parameters
->BackBufferWidth
;
2762 local_parameters
.BackBufferHeight
= present_parameters
->BackBufferHeight
;
2763 local_parameters
.BackBufferFormat
= d3dformat_from_wined3dformat(present_parameters
->BackBufferFormat
);
2764 local_parameters
.BackBufferCount
= present_parameters
->BackBufferCount
;
2765 local_parameters
.MultiSampleType
= present_parameters
->MultiSampleType
;
2766 local_parameters
.MultiSampleQuality
= present_parameters
->MultiSampleQuality
;
2767 local_parameters
.SwapEffect
= present_parameters
->SwapEffect
;
2768 local_parameters
.hDeviceWindow
= present_parameters
->hDeviceWindow
;
2769 local_parameters
.Windowed
= present_parameters
->Windowed
;
2770 local_parameters
.EnableAutoDepthStencil
= present_parameters
->EnableAutoDepthStencil
;
2771 local_parameters
.AutoDepthStencilFormat
= d3dformat_from_wined3dformat(present_parameters
->AutoDepthStencilFormat
);
2772 local_parameters
.Flags
= present_parameters
->Flags
;
2773 local_parameters
.FullScreen_RefreshRateInHz
= present_parameters
->FullScreen_RefreshRateInHz
;
2774 local_parameters
.PresentationInterval
= present_parameters
->PresentationInterval
;
2776 hr
= IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex
*)This
,
2777 &local_parameters
, (IDirect3DSwapChain9
**)&d3d_swapchain
);
2780 ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface
, hr
);
2785 *swapchain
= d3d_swapchain
->wineD3DSwapChain
;
2786 d3d_swapchain
->isImplicit
= TRUE
;
2787 /* Implicit swap chains are created with an refcount of 0 */
2788 IDirect3DSwapChain9_Release((IDirect3DSwapChain9
*)d3d_swapchain
);
2790 /* Copy back the presentation parameters */
2791 present_parameters
->BackBufferWidth
= local_parameters
.BackBufferWidth
;
2792 present_parameters
->BackBufferHeight
= local_parameters
.BackBufferHeight
;
2793 present_parameters
->BackBufferFormat
= wined3dformat_from_d3dformat(local_parameters
.BackBufferFormat
);
2794 present_parameters
->BackBufferCount
= local_parameters
.BackBufferCount
;
2795 present_parameters
->MultiSampleType
= local_parameters
.MultiSampleType
;
2796 present_parameters
->MultiSampleQuality
= local_parameters
.MultiSampleQuality
;
2797 present_parameters
->SwapEffect
= local_parameters
.SwapEffect
;
2798 present_parameters
->hDeviceWindow
= local_parameters
.hDeviceWindow
;
2799 present_parameters
->Windowed
= local_parameters
.Windowed
;
2800 present_parameters
->EnableAutoDepthStencil
= local_parameters
.EnableAutoDepthStencil
;
2801 present_parameters
->AutoDepthStencilFormat
= wined3dformat_from_d3dformat(local_parameters
.AutoDepthStencilFormat
);
2802 present_parameters
->Flags
= local_parameters
.Flags
;
2803 present_parameters
->FullScreen_RefreshRateInHz
= local_parameters
.FullScreen_RefreshRateInHz
;
2804 present_parameters
->PresentationInterval
= local_parameters
.PresentationInterval
;
2809 static const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl
=
2811 /* IUnknown methods */
2812 device_parent_QueryInterface
,
2813 device_parent_AddRef
,
2814 device_parent_Release
,
2815 /* IWineD3DDeviceParent methods */
2816 device_parent_WineD3DDeviceCreated
,
2817 device_parent_CreateSurface
,
2818 device_parent_CreateRenderTarget
,
2819 device_parent_CreateDepthStencilSurface
,
2820 device_parent_CreateVolume
,
2821 device_parent_CreateSwapChain
,
2824 HRESULT
device_init(IDirect3DDevice9Impl
*device
, IWineD3D
*wined3d
, UINT adapter
, D3DDEVTYPE device_type
,
2825 HWND focus_window
, DWORD flags
, D3DPRESENT_PARAMETERS
*parameters
)
2827 WINED3DPRESENT_PARAMETERS
*wined3d_parameters
;
2831 device
->lpVtbl
= &Direct3DDevice9_Vtbl
;
2832 device
->device_parent_vtbl
= &d3d9_wined3d_device_parent_vtbl
;
2835 wined3d_mutex_lock();
2836 hr
= IWineD3D_CreateDevice(wined3d
, adapter
, device_type
, focus_window
, flags
, (IUnknown
*)device
,
2837 (IWineD3DDeviceParent
*)&device
->device_parent_vtbl
, &device
->WineD3DDevice
);
2840 WARN("Failed to create wined3d device, hr %#x.\n", hr
);
2841 wined3d_mutex_unlock();
2845 if (flags
& D3DCREATE_ADAPTERGROUP_DEVICE
)
2849 IWineD3D_GetDeviceCaps(wined3d
, adapter
, device_type
, &caps
);
2850 count
= caps
.NumberOfAdaptersInGroup
;
2853 if (flags
& D3DCREATE_MULTITHREADED
) IWineD3DDevice_SetMultithreaded(device
->WineD3DDevice
);
2855 wined3d_parameters
= HeapAlloc(GetProcessHeap(), 0, sizeof(*wined3d_parameters
) * count
);
2856 if (!wined3d_parameters
)
2858 ERR("Failed to allocate wined3d parameters.\n");
2859 IWineD3DDevice_Release(device
->WineD3DDevice
);
2860 wined3d_mutex_unlock();
2861 return E_OUTOFMEMORY
;
2864 for (i
= 0; i
< count
; ++i
)
2866 wined3d_parameters
[i
].BackBufferWidth
= parameters
[i
].BackBufferWidth
;
2867 wined3d_parameters
[i
].BackBufferHeight
= parameters
[i
].BackBufferHeight
;
2868 wined3d_parameters
[i
].BackBufferFormat
= wined3dformat_from_d3dformat(parameters
[i
].BackBufferFormat
);
2869 wined3d_parameters
[i
].BackBufferCount
= parameters
[i
].BackBufferCount
;
2870 wined3d_parameters
[i
].MultiSampleType
= parameters
[i
].MultiSampleType
;
2871 wined3d_parameters
[i
].MultiSampleQuality
= parameters
[i
].MultiSampleQuality
;
2872 wined3d_parameters
[i
].SwapEffect
= parameters
[i
].SwapEffect
;
2873 wined3d_parameters
[i
].hDeviceWindow
= parameters
[i
].hDeviceWindow
;
2874 wined3d_parameters
[i
].Windowed
= parameters
[i
].Windowed
;
2875 wined3d_parameters
[i
].EnableAutoDepthStencil
= parameters
[i
].EnableAutoDepthStencil
;
2876 wined3d_parameters
[i
].AutoDepthStencilFormat
=
2877 wined3dformat_from_d3dformat(parameters
[i
].AutoDepthStencilFormat
);
2878 wined3d_parameters
[i
].Flags
= parameters
[i
].Flags
;
2879 wined3d_parameters
[i
].FullScreen_RefreshRateInHz
= parameters
[i
].FullScreen_RefreshRateInHz
;
2880 wined3d_parameters
[i
].PresentationInterval
= parameters
[i
].PresentationInterval
;
2881 wined3d_parameters
[i
].AutoRestoreDisplayMode
= TRUE
;
2884 hr
= IWineD3DDevice_Init3D(device
->WineD3DDevice
, wined3d_parameters
);
2887 WARN("Failed to initialize 3D, hr %#x.\n", hr
);
2888 HeapFree(GetProcessHeap(), 0, wined3d_parameters
);
2889 IWineD3DDevice_Release(device
->WineD3DDevice
);
2890 wined3d_mutex_unlock();
2894 wined3d_mutex_unlock();
2896 for (i
= 0; i
< count
; ++i
)
2898 parameters
[i
].BackBufferWidth
= wined3d_parameters
[i
].BackBufferWidth
;
2899 parameters
[i
].BackBufferHeight
= wined3d_parameters
[i
].BackBufferHeight
;
2900 parameters
[i
].BackBufferFormat
= d3dformat_from_wined3dformat(wined3d_parameters
[i
].BackBufferFormat
);
2901 parameters
[i
].BackBufferCount
= wined3d_parameters
[i
].BackBufferCount
;
2902 parameters
[i
].MultiSampleType
= wined3d_parameters
[i
].MultiSampleType
;
2903 parameters
[i
].MultiSampleQuality
= wined3d_parameters
[i
].MultiSampleQuality
;
2904 parameters
[i
].SwapEffect
= wined3d_parameters
[i
].SwapEffect
;
2905 parameters
[i
].hDeviceWindow
= wined3d_parameters
[i
].hDeviceWindow
;
2906 parameters
[i
].Windowed
= wined3d_parameters
[i
].Windowed
;
2907 parameters
[i
].EnableAutoDepthStencil
= wined3d_parameters
[i
].EnableAutoDepthStencil
;
2908 parameters
[i
].AutoDepthStencilFormat
=
2909 d3dformat_from_wined3dformat(wined3d_parameters
[i
].AutoDepthStencilFormat
);
2910 parameters
[i
].Flags
= wined3d_parameters
[i
].Flags
;
2911 parameters
[i
].FullScreen_RefreshRateInHz
= wined3d_parameters
[i
].FullScreen_RefreshRateInHz
;
2912 parameters
[i
].PresentationInterval
= wined3d_parameters
[i
].PresentationInterval
;
2914 HeapFree(GetProcessHeap(), 0, wined3d_parameters
);
2916 /* Initialize the converted declaration array. This creates a valid pointer
2917 * and when adding decls HeapReAlloc() can be used without further checking. */
2918 device
->convertedDecls
= HeapAlloc(GetProcessHeap(), 0, 0);
2919 if (!device
->convertedDecls
)
2921 ERR("Failed to allocate FVF vertex declaration map memory.\n");
2922 wined3d_mutex_lock();
2923 IWineD3DDevice_Uninit3D(device
->WineD3DDevice
, D3D9CB_DestroySwapChain
);
2924 IWineD3DDevice_Release(device
->WineD3DDevice
);
2925 wined3d_mutex_unlock();
2926 return E_OUTOFMEMORY
;