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_R8G8B8
: return D3DFMT_R8G8B8
;
39 case WINED3DFMT_A8R8G8B8
: return D3DFMT_A8R8G8B8
;
40 case WINED3DFMT_X8R8G8B8
: return D3DFMT_X8R8G8B8
;
41 case WINED3DFMT_R5G6B5
: return D3DFMT_R5G6B5
;
42 case WINED3DFMT_X1R5G5B5
: return D3DFMT_X1R5G5B5
;
43 case WINED3DFMT_A1R5G5B5
: return D3DFMT_A1R5G5B5
;
44 case WINED3DFMT_A4R4G4B4
: return D3DFMT_A4R4G4B4
;
45 case WINED3DFMT_R3G3B2
: return D3DFMT_R3G3B2
;
46 case WINED3DFMT_A8_UNORM
: return D3DFMT_A8
;
47 case WINED3DFMT_A8R3G3B2
: return D3DFMT_A8R3G3B2
;
48 case WINED3DFMT_X4R4G4B4
: return D3DFMT_X4R4G4B4
;
49 case WINED3DFMT_R10G10B10A2_UNORM
: return D3DFMT_A2B10G10R10
;
50 case WINED3DFMT_R8G8B8A8_UNORM
: return D3DFMT_A8B8G8R8
;
51 case WINED3DFMT_X8B8G8R8
: return D3DFMT_X8B8G8R8
;
52 case WINED3DFMT_R16G16_UNORM
: return D3DFMT_G16R16
;
53 case WINED3DFMT_A2R10G10B10
: return D3DFMT_A2R10G10B10
;
54 case WINED3DFMT_R16G16B16A16_UNORM
: return D3DFMT_A16B16G16R16
;
55 case WINED3DFMT_A8P8
: return D3DFMT_A8P8
;
56 case WINED3DFMT_P8
: return D3DFMT_P8
;
57 case WINED3DFMT_L8
: return D3DFMT_L8
;
58 case WINED3DFMT_A8L8
: return D3DFMT_A8L8
;
59 case WINED3DFMT_A4L4
: return D3DFMT_A4L4
;
60 case WINED3DFMT_R8G8_SNORM
: return D3DFMT_V8U8
;
61 case WINED3DFMT_L6V5U5
: return D3DFMT_L6V5U5
;
62 case WINED3DFMT_X8L8V8U8
: return D3DFMT_X8L8V8U8
;
63 case WINED3DFMT_R8G8B8A8_SNORM
: return D3DFMT_Q8W8V8U8
;
64 case WINED3DFMT_R16G16_SNORM
: return D3DFMT_V16U16
;
65 case WINED3DFMT_A2W10V10U10
: return D3DFMT_A2W10V10U10
;
66 case WINED3DFMT_D16_LOCKABLE
: return D3DFMT_D16_LOCKABLE
;
67 case WINED3DFMT_D32
: return D3DFMT_D32
;
68 case WINED3DFMT_D15S1
: return D3DFMT_D15S1
;
69 case WINED3DFMT_D24S8
: return D3DFMT_D24S8
;
70 case WINED3DFMT_D24X8
: return D3DFMT_D24X8
;
71 case WINED3DFMT_D24X4S4
: return D3DFMT_D24X4S4
;
72 case WINED3DFMT_D16_UNORM
: return D3DFMT_D16
;
73 case WINED3DFMT_L16
: return D3DFMT_L16
;
74 case WINED3DFMT_D32F_LOCKABLE
: return D3DFMT_D32F_LOCKABLE
;
75 case WINED3DFMT_D24FS8
: 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_CxV8U8
: 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_R8G8B8
;
104 case D3DFMT_A8R8G8B8
: return WINED3DFMT_A8R8G8B8
;
105 case D3DFMT_X8R8G8B8
: return WINED3DFMT_X8R8G8B8
;
106 case D3DFMT_R5G6B5
: return WINED3DFMT_R5G6B5
;
107 case D3DFMT_X1R5G5B5
: return WINED3DFMT_X1R5G5B5
;
108 case D3DFMT_A1R5G5B5
: return WINED3DFMT_A1R5G5B5
;
109 case D3DFMT_A4R4G4B4
: return WINED3DFMT_A4R4G4B4
;
110 case D3DFMT_R3G3B2
: return WINED3DFMT_R3G3B2
;
111 case D3DFMT_A8
: return WINED3DFMT_A8_UNORM
;
112 case D3DFMT_A8R3G3B2
: return WINED3DFMT_A8R3G3B2
;
113 case D3DFMT_X4R4G4B4
: return WINED3DFMT_X4R4G4B4
;
114 case D3DFMT_A2B10G10R10
: return WINED3DFMT_R10G10B10A2_UNORM
;
115 case D3DFMT_A8B8G8R8
: return WINED3DFMT_R8G8B8A8_UNORM
;
116 case D3DFMT_X8B8G8R8
: return WINED3DFMT_X8B8G8R8
;
117 case D3DFMT_G16R16
: return WINED3DFMT_R16G16_UNORM
;
118 case D3DFMT_A2R10G10B10
: return WINED3DFMT_A2R10G10B10
;
119 case D3DFMT_A16B16G16R16
: return WINED3DFMT_R16G16B16A16_UNORM
;
120 case D3DFMT_A8P8
: return WINED3DFMT_A8P8
;
121 case D3DFMT_P8
: return WINED3DFMT_P8
;
122 case D3DFMT_L8
: return WINED3DFMT_L8
;
123 case D3DFMT_A8L8
: return WINED3DFMT_A8L8
;
124 case D3DFMT_A4L4
: return WINED3DFMT_A4L4
;
125 case D3DFMT_V8U8
: return WINED3DFMT_R8G8_SNORM
;
126 case D3DFMT_L6V5U5
: return WINED3DFMT_L6V5U5
;
127 case D3DFMT_X8L8V8U8
: return WINED3DFMT_X8L8V8U8
;
128 case D3DFMT_Q8W8V8U8
: return WINED3DFMT_R8G8B8A8_SNORM
;
129 case D3DFMT_V16U16
: return WINED3DFMT_R16G16_SNORM
;
130 case D3DFMT_A2W10V10U10
: return WINED3DFMT_A2W10V10U10
;
131 case D3DFMT_D16_LOCKABLE
: return WINED3DFMT_D16_LOCKABLE
;
132 case D3DFMT_D32
: return WINED3DFMT_D32
;
133 case D3DFMT_D15S1
: return WINED3DFMT_D15S1
;
134 case D3DFMT_D24S8
: return WINED3DFMT_D24S8
;
135 case D3DFMT_D24X8
: return WINED3DFMT_D24X8
;
136 case D3DFMT_D24X4S4
: return WINED3DFMT_D24X4S4
;
137 case D3DFMT_D16
: return WINED3DFMT_D16_UNORM
;
138 case D3DFMT_L16
: return WINED3DFMT_L16
;
139 case D3DFMT_D32F_LOCKABLE
: return WINED3DFMT_D32F_LOCKABLE
;
140 case D3DFMT_D24FS8
: return WINED3DFMT_D24FS8
;
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_CxV8U8
;
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 /* IDirect3D IUnknown parts follow: */
185 static HRESULT WINAPI
IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX iface
, REFIID riid
, LPVOID
* ppobj
) {
186 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
188 IDirect3D9Impl
*d3dimpl
;
190 if (IsEqualGUID(riid
, &IID_IUnknown
)
191 || IsEqualGUID(riid
, &IID_IDirect3DDevice9
)) {
192 IDirect3DDevice9Ex_AddRef(iface
);
194 TRACE("Returning IDirect3DDevice9 interface at %p\n", *ppobj
);
196 } else if(IsEqualGUID(riid
, &IID_IDirect3DDevice9Ex
)) {
197 /* Find out if the creating d3d9 interface was created with Direct3DCreate9Ex.
198 * It doesn't matter with which function the device was created.
200 IDirect3DDevice9_GetDirect3D(iface
, &d3d
);
201 d3dimpl
= (IDirect3D9Impl
*) d3d
;
203 if(d3dimpl
->extended
) {
205 IDirect3DDevice9Ex_AddRef((IDirect3DDevice9Ex
*) *ppobj
);
206 IDirect3D9_Release(d3d
);
207 TRACE("Returning IDirect3DDevice9Ex interface at %p\n", *ppobj
);
210 WARN("IDirect3D9 instance wasn't created with CreateDirect3D9Ex, returning E_NOINTERFACE\n");
211 IDirect3D9_Release(d3d
);
213 return E_NOINTERFACE
;
217 if (IsEqualGUID(riid
, &IID_IWineD3DDeviceParent
))
219 IUnknown_AddRef((IUnknown
*)&This
->device_parent_vtbl
);
220 *ppobj
= &This
->device_parent_vtbl
;
224 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
226 return E_NOINTERFACE
;
229 static ULONG WINAPI
IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9EX iface
) {
230 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
231 ULONG ref
= InterlockedIncrement(&This
->ref
);
233 TRACE("(%p) : AddRef from %d\n", This
, ref
- 1);
238 static ULONG WINAPI
IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface
) {
239 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
242 if (This
->inDestruction
) return 0;
243 ref
= InterlockedDecrement(&This
->ref
);
245 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
249 This
->inDestruction
= TRUE
;
251 EnterCriticalSection(&d3d9_cs
);
252 for(i
= 0; i
< This
->numConvertedDecls
; i
++) {
253 /* Unless Wine is buggy or the app has a bug the refcount will be 0, because decls hold a reference to the
256 IDirect3DVertexDeclaration9Impl_Destroy(This
->convertedDecls
[i
]);
258 HeapFree(GetProcessHeap(), 0, This
->convertedDecls
);
260 IWineD3DDevice_Uninit3D(This
->WineD3DDevice
, D3D9CB_DestroyDepthStencilSurface
, D3D9CB_DestroySwapChain
);
261 IWineD3DDevice_Release(This
->WineD3DDevice
);
262 LeaveCriticalSection(&d3d9_cs
);
263 HeapFree(GetProcessHeap(), 0, This
);
268 /* IDirect3DDevice Interface follow: */
269 static HRESULT WINAPI
IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9EX iface
) {
270 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
272 TRACE("(%p)\n", This
);
274 EnterCriticalSection(&d3d9_cs
);
275 hr
= IWineD3DDevice_TestCooperativeLevel(This
->WineD3DDevice
);
276 LeaveCriticalSection(&d3d9_cs
);
277 if(hr
== WINED3D_OK
&& This
->notreset
) {
278 TRACE("D3D9 Device is marked not reset\n");
279 hr
= D3DERR_DEVICENOTRESET
;
285 static UINT WINAPI
IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9EX iface
) {
286 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
288 TRACE("(%p) Relay\n", This
);
290 EnterCriticalSection(&d3d9_cs
);
291 hr
= IWineD3DDevice_GetAvailableTextureMem(This
->WineD3DDevice
);
292 LeaveCriticalSection(&d3d9_cs
);
296 static HRESULT WINAPI
IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9EX iface
) {
297 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
299 TRACE("(%p) : Relay\n", This
);
301 EnterCriticalSection(&d3d9_cs
);
302 hr
= IWineD3DDevice_EvictManagedResources(This
->WineD3DDevice
);
303 LeaveCriticalSection(&d3d9_cs
);
307 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface
, IDirect3D9
** ppD3D9
) {
308 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
312 TRACE("(%p) Relay\n", This
);
314 if (NULL
== ppD3D9
) {
315 return D3DERR_INVALIDCALL
;
318 EnterCriticalSection(&d3d9_cs
);
319 hr
= IWineD3DDevice_GetDirect3D(This
->WineD3DDevice
, &pWineD3D
);
320 if (hr
== D3D_OK
&& pWineD3D
!= NULL
)
322 IWineD3D_GetParent(pWineD3D
,(IUnknown
**)ppD3D9
);
323 IWineD3D_Release(pWineD3D
);
325 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
328 TRACE("(%p) returning %p\n", This
, *ppD3D9
);
329 LeaveCriticalSection(&d3d9_cs
);
333 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9EX iface
, D3DCAPS9
* pCaps
) {
334 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
335 HRESULT hrc
= D3D_OK
;
336 WINED3DCAPS
*pWineCaps
;
338 TRACE("(%p) : Relay pCaps %p\n", This
, pCaps
);
340 return D3DERR_INVALIDCALL
;
342 pWineCaps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINED3DCAPS
));
343 if(pWineCaps
== NULL
){
344 return D3DERR_INVALIDCALL
; /* well this is what MSDN says to return */
347 memset(pCaps
, 0, sizeof(*pCaps
));
348 EnterCriticalSection(&d3d9_cs
);
349 hrc
= IWineD3DDevice_GetDeviceCaps(This
->WineD3DDevice
, pWineCaps
);
350 LeaveCriticalSection(&d3d9_cs
);
351 WINECAPSTOD3D9CAPS(pCaps
, pWineCaps
)
352 HeapFree(GetProcessHeap(), 0, pWineCaps
);
354 /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
355 pCaps
->DevCaps2
|= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
;
359 TRACE("Returning %p %p\n", This
, pCaps
);
363 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DDISPLAYMODE
* pMode
) {
364 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
366 TRACE("(%p) Relay\n", This
);
368 EnterCriticalSection(&d3d9_cs
);
369 hr
= IWineD3DDevice_GetDisplayMode(This
->WineD3DDevice
, iSwapChain
, (WINED3DDISPLAYMODE
*) pMode
);
370 LeaveCriticalSection(&d3d9_cs
);
372 if (SUCCEEDED(hr
)) pMode
->Format
= d3dformat_from_wined3dformat(pMode
->Format
);
377 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9EX iface
, D3DDEVICE_CREATION_PARAMETERS
*pParameters
) {
378 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
380 TRACE("(%p) Relay\n", This
);
382 EnterCriticalSection(&d3d9_cs
);
383 hr
= IWineD3DDevice_GetCreationParameters(This
->WineD3DDevice
, (WINED3DDEVICE_CREATION_PARAMETERS
*) pParameters
);
384 LeaveCriticalSection(&d3d9_cs
);
388 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9EX iface
, UINT XHotSpot
, UINT YHotSpot
, IDirect3DSurface9
* pCursorBitmap
) {
389 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
390 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pCursorBitmap
;
393 TRACE("(%p) Relay\n", This
);
395 WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
396 return WINED3DERR_INVALIDCALL
;
399 EnterCriticalSection(&d3d9_cs
);
400 hr
= IWineD3DDevice_SetCursorProperties(This
->WineD3DDevice
, XHotSpot
, YHotSpot
, pSurface
->wineD3DSurface
);
401 LeaveCriticalSection(&d3d9_cs
);
405 static void WINAPI
IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9EX iface
, int XScreenSpace
, int YScreenSpace
, DWORD Flags
) {
406 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
407 TRACE("(%p) Relay\n", This
);
409 EnterCriticalSection(&d3d9_cs
);
410 IWineD3DDevice_SetCursorPosition(This
->WineD3DDevice
, XScreenSpace
, YScreenSpace
, Flags
);
411 LeaveCriticalSection(&d3d9_cs
);
414 static BOOL WINAPI
IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX iface
, BOOL bShow
) {
415 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
417 TRACE("(%p) Relay\n", This
);
419 EnterCriticalSection(&d3d9_cs
);
420 ret
= IWineD3DDevice_ShowCursor(This
->WineD3DDevice
, bShow
);
421 LeaveCriticalSection(&d3d9_cs
);
425 static HRESULT WINAPI
reset_enum_callback(IWineD3DResource
*resource
, void *data
) {
426 BOOL
*resources_ok
= data
;
427 WINED3DRESOURCETYPE type
;
429 WINED3DSURFACE_DESC surface_desc
;
430 WINED3DVOLUME_DESC volume_desc
;
431 D3DINDEXBUFFER_DESC index_desc
;
432 D3DVERTEXBUFFER_DESC vertex_desc
;
433 WINED3DFORMAT dummy_format
;
434 WINED3DMULTISAMPLE_TYPE dummy_multisampletype
;
436 WINED3DPOOL pool
= WINED3DPOOL_SCRATCH
; /* a harmless pool */
437 IDirect3DResource9
*parent
;
439 IWineD3DResource_GetParent(resource
, (IUnknown
**) &parent
);
440 type
= IDirect3DResource9_GetType(parent
);
442 case D3DRTYPE_SURFACE
:
443 surface_desc
.Format
= &dummy_format
;
444 surface_desc
.Type
= &type
;
445 surface_desc
.Usage
= &dummy_dword
;
446 surface_desc
.Pool
= &pool
;
447 surface_desc
.Size
= &dummy_dword
;
448 surface_desc
.MultiSampleType
= &dummy_multisampletype
;
449 surface_desc
.MultiSampleQuality
= &dummy_dword
;
450 surface_desc
.Width
= &dummy_dword
;
451 surface_desc
.Height
= &dummy_dword
;
453 IWineD3DSurface_GetDesc((IWineD3DSurface
*) resource
, &surface_desc
);
456 case D3DRTYPE_VOLUME
:
457 IWineD3DVolume_GetDesc((IWineD3DVolume
*) resource
, &volume_desc
);
458 pool
= volume_desc
.Pool
;
461 case D3DRTYPE_INDEXBUFFER
:
462 IDirect3DIndexBuffer9_GetDesc((IDirect3DIndexBuffer9
*) parent
, &index_desc
);
463 pool
= index_desc
.Pool
;
466 case D3DRTYPE_VERTEXBUFFER
:
467 IDirect3DVertexBuffer9_GetDesc((IDirect3DVertexBuffer9
*)parent
, &vertex_desc
);
468 pool
= vertex_desc
.Pool
;
471 /* No need to check for textures. If there is a D3DPOOL_DEFAULT texture, there
472 * is a D3DPOOL_DEFAULT surface or volume as well
478 if(pool
== WINED3DPOOL_DEFAULT
) {
479 if(IUnknown_Release(parent
) == 0) {
480 TRACE("Parent %p is an implicit resource with ref 0\n", parent
);
482 WARN("Resource %p(wineD3D %p) with pool D3DPOOL_DEFAULT blocks the Reset call\n", parent
, resource
);
484 *resources_ok
= FALSE
;
487 IUnknown_Release(parent
);
489 IWineD3DResource_Release(resource
);
494 static HRESULT WINAPI
IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface
, D3DPRESENT_PARAMETERS
* pPresentationParameters
) {
495 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
496 WINED3DPRESENT_PARAMETERS localParameters
;
498 BOOL resources_ok
= TRUE
;
501 TRACE("(%p) Relay pPresentationParameters(%p)\n", This
, pPresentationParameters
);
503 /* Reset states that hold a COM object. WineD3D holds an internal reference to set objects, because
504 * such objects can still be used for rendering after their external d3d9 object has been destroyed.
505 * These objects must not be enumerated. Unsetting them tells WineD3D that the application will not
506 * make use of the hidden reference and destroys the objects.
508 * Unsetting them is no problem, because the states are supposed to be reset anyway. If the validation
509 * below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
511 EnterCriticalSection(&d3d9_cs
);
512 IWineD3DDevice_SetIndices(This
->WineD3DDevice
, NULL
, WINED3DFMT_UNKNOWN
);
513 for(i
= 0; i
< 16; i
++) {
514 IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, i
, NULL
, 0, 0);
516 for(i
= 0; i
< 16; i
++) {
517 IWineD3DDevice_SetTexture(This
->WineD3DDevice
, i
, NULL
);
520 IWineD3DDevice_EnumResources(This
->WineD3DDevice
, reset_enum_callback
, &resources_ok
);
522 WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
523 This
->notreset
= TRUE
;
524 LeaveCriticalSection(&d3d9_cs
);
525 return WINED3DERR_INVALIDCALL
;
528 localParameters
.BackBufferWidth
= pPresentationParameters
->BackBufferWidth
;
529 localParameters
.BackBufferHeight
= pPresentationParameters
->BackBufferHeight
;
530 localParameters
.BackBufferFormat
= wined3dformat_from_d3dformat(pPresentationParameters
->BackBufferFormat
);
531 localParameters
.BackBufferCount
= pPresentationParameters
->BackBufferCount
;
532 localParameters
.MultiSampleType
= pPresentationParameters
->MultiSampleType
;
533 localParameters
.MultiSampleQuality
= pPresentationParameters
->MultiSampleQuality
;
534 localParameters
.SwapEffect
= pPresentationParameters
->SwapEffect
;
535 localParameters
.hDeviceWindow
= pPresentationParameters
->hDeviceWindow
;
536 localParameters
.Windowed
= pPresentationParameters
->Windowed
;
537 localParameters
.EnableAutoDepthStencil
= pPresentationParameters
->EnableAutoDepthStencil
;
538 localParameters
.AutoDepthStencilFormat
= wined3dformat_from_d3dformat(pPresentationParameters
->AutoDepthStencilFormat
);
539 localParameters
.Flags
= pPresentationParameters
->Flags
;
540 localParameters
.FullScreen_RefreshRateInHz
= pPresentationParameters
->FullScreen_RefreshRateInHz
;
541 localParameters
.PresentationInterval
= pPresentationParameters
->PresentationInterval
;
542 localParameters
.AutoRestoreDisplayMode
= TRUE
;
544 hr
= IWineD3DDevice_Reset(This
->WineD3DDevice
, &localParameters
);
546 This
->notreset
= TRUE
;
548 pPresentationParameters
->BackBufferWidth
= localParameters
.BackBufferWidth
;
549 pPresentationParameters
->BackBufferHeight
= localParameters
.BackBufferHeight
;
550 pPresentationParameters
->BackBufferFormat
= d3dformat_from_wined3dformat(localParameters
.BackBufferFormat
);
551 pPresentationParameters
->BackBufferCount
= localParameters
.BackBufferCount
;
552 pPresentationParameters
->MultiSampleType
= localParameters
.MultiSampleType
;
553 pPresentationParameters
->MultiSampleQuality
= localParameters
.MultiSampleQuality
;
554 pPresentationParameters
->SwapEffect
= localParameters
.SwapEffect
;
555 pPresentationParameters
->hDeviceWindow
= localParameters
.hDeviceWindow
;
556 pPresentationParameters
->Windowed
= localParameters
.Windowed
;
557 pPresentationParameters
->EnableAutoDepthStencil
= localParameters
.EnableAutoDepthStencil
;
558 pPresentationParameters
->AutoDepthStencilFormat
= d3dformat_from_wined3dformat(localParameters
.AutoDepthStencilFormat
);
559 pPresentationParameters
->Flags
= localParameters
.Flags
;
560 pPresentationParameters
->FullScreen_RefreshRateInHz
= localParameters
.FullScreen_RefreshRateInHz
;
561 pPresentationParameters
->PresentationInterval
= localParameters
.PresentationInterval
;
563 This
->notreset
= FALSE
;
566 LeaveCriticalSection(&d3d9_cs
);
571 static HRESULT WINAPI
IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface
, CONST RECT
* pSourceRect
,CONST RECT
* pDestRect
,HWND hDestWindowOverride
,CONST RGNDATA
*
573 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
575 TRACE("(%p) Relay\n", This
);
577 EnterCriticalSection(&d3d9_cs
);
578 hr
= IWineD3DDevice_Present(This
->WineD3DDevice
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
);
579 LeaveCriticalSection(&d3d9_cs
);
583 static HRESULT WINAPI
IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, UINT BackBuffer
, D3DBACKBUFFER_TYPE Type
, IDirect3DSurface9
** ppBackBuffer
) {
584 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
585 IWineD3DSurface
*retSurface
= NULL
;
588 TRACE("(%p) Relay\n", This
);
590 EnterCriticalSection(&d3d9_cs
);
591 rc
= IWineD3DDevice_GetBackBuffer(This
->WineD3DDevice
, iSwapChain
, BackBuffer
, (WINED3DBACKBUFFER_TYPE
) Type
, &retSurface
);
592 if (rc
== D3D_OK
&& NULL
!= retSurface
&& NULL
!= ppBackBuffer
) {
593 IWineD3DSurface_GetParent(retSurface
, (IUnknown
**)ppBackBuffer
);
594 IWineD3DSurface_Release(retSurface
);
596 LeaveCriticalSection(&d3d9_cs
);
599 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DRASTER_STATUS
* pRasterStatus
) {
600 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
602 TRACE("(%p) Relay\n", This
);
604 EnterCriticalSection(&d3d9_cs
);
605 hr
= IWineD3DDevice_GetRasterStatus(This
->WineD3DDevice
, iSwapChain
, (WINED3DRASTER_STATUS
*) pRasterStatus
);
606 LeaveCriticalSection(&d3d9_cs
);
610 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9EX iface
, BOOL bEnableDialogs
) {
611 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
613 TRACE("(%p) Relay\n", This
);
615 EnterCriticalSection(&d3d9_cs
);
616 hr
= IWineD3DDevice_SetDialogBoxMode(This
->WineD3DDevice
, bEnableDialogs
);
617 LeaveCriticalSection(&d3d9_cs
);
621 static void WINAPI
IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, DWORD Flags
, CONST D3DGAMMARAMP
* pRamp
) {
623 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
624 TRACE("(%p) Relay\n", This
);
626 EnterCriticalSection(&d3d9_cs
);
627 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
628 IWineD3DDevice_SetGammaRamp(This
->WineD3DDevice
, iSwapChain
, Flags
, (CONST WINED3DGAMMARAMP
*)pRamp
);
629 LeaveCriticalSection(&d3d9_cs
);
632 static void WINAPI
IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DGAMMARAMP
* pRamp
) {
633 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
634 TRACE("(%p) Relay\n", This
);
636 EnterCriticalSection(&d3d9_cs
);
637 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
638 IWineD3DDevice_GetGammaRamp(This
->WineD3DDevice
, iSwapChain
, (WINED3DGAMMARAMP
*) pRamp
);
639 LeaveCriticalSection(&d3d9_cs
);
643 static HRESULT
IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
644 D3DFORMAT Format
, BOOL Lockable
, BOOL Discard
, UINT Level
, IDirect3DSurface9
**ppSurface
,
645 UINT Usage
, D3DPOOL Pool
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultisampleQuality
)
648 IDirect3DSurface9Impl
*object
;
649 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
650 TRACE("(%p) Relay\n", This
);
652 if(MultisampleQuality
> 0){
653 FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality
);
656 [in] Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by IDirect3D9::CheckDeviceMultiSampleType. Passing a larger value returns the error D3DERR_INVALIDCALL. The MultisampleQuality values of paired render targets, depth stencil surfaces, and the MultiSample type must all match.
659 MultisampleQuality
=0;
661 /*FIXME: Check MAX bounds of MultisampleQuality*/
663 /* Allocate the storage for the device */
664 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DSurface9Impl
));
665 if (NULL
== object
) {
666 FIXME("Allocation of memory failed\n");
667 return D3DERR_OUTOFVIDEOMEMORY
;
670 object
->lpVtbl
= &Direct3DSurface9_Vtbl
;
673 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This
, Width
, Height
, Format
, *ppSurface
);
675 EnterCriticalSection(&d3d9_cs
);
676 hrc
= IWineD3DDevice_CreateSurface(This
->WineD3DDevice
, Width
, Height
, wined3dformat_from_d3dformat(Format
),
677 Lockable
, Discard
, Level
, &object
->wineD3DSurface
, Usage
& WINED3DUSAGE_MASK
, (WINED3DPOOL
)Pool
,
678 MultiSample
, MultisampleQuality
, SURFACE_OPENGL
, (IUnknown
*)object
);
679 LeaveCriticalSection(&d3d9_cs
);
681 if (hrc
!= D3D_OK
|| NULL
== object
->wineD3DSurface
) {
684 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This
);
685 HeapFree(GetProcessHeap(), 0, object
);
687 IDirect3DDevice9Ex_AddRef(iface
);
688 object
->parentDevice
= iface
;
689 TRACE("(%p) : Created surface %p\n", This
, object
);
690 *ppSurface
= (LPDIRECT3DSURFACE9
) object
;
697 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
698 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
699 DWORD MultisampleQuality
, BOOL Lockable
,
700 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
704 hr
= IDirect3DDevice9Impl_CreateSurface(iface
, Width
, Height
, Format
, Lockable
, FALSE
/* Discard */,
705 0 /* Level */, ppSurface
, D3DUSAGE_RENDERTARGET
, D3DPOOL_DEFAULT
, MultiSample
, MultisampleQuality
);
710 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
711 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
712 DWORD MultisampleQuality
, BOOL Discard
,
713 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
717 hr
= IDirect3DDevice9Impl_CreateSurface(iface
, Width
, Height
, Format
, TRUE
/* Lockable */, Discard
,
718 0 /* Level */, ppSurface
, D3DUSAGE_DEPTHSTENCIL
, D3DPOOL_DEFAULT
, MultiSample
, MultisampleQuality
);
724 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestinationSurface
, CONST POINT
* pDestPoint
) {
725 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
727 TRACE("(%p) Relay\n" , This
);
729 EnterCriticalSection(&d3d9_cs
);
730 hr
= IWineD3DDevice_UpdateSurface(This
->WineD3DDevice
, ((IDirect3DSurface9Impl
*)pSourceSurface
)->wineD3DSurface
, pSourceRect
, ((IDirect3DSurface9Impl
*)pDestinationSurface
)->wineD3DSurface
, pDestPoint
);
731 LeaveCriticalSection(&d3d9_cs
);
735 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9EX iface
, IDirect3DBaseTexture9
* pSourceTexture
, IDirect3DBaseTexture9
* pDestinationTexture
) {
736 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
738 TRACE("(%p) Relay\n" , This
);
740 EnterCriticalSection(&d3d9_cs
);
741 hr
= IWineD3DDevice_UpdateTexture(This
->WineD3DDevice
, ((IDirect3DBaseTexture9Impl
*)pSourceTexture
)->wineD3DBaseTexture
, ((IDirect3DBaseTexture9Impl
*)pDestinationTexture
)->wineD3DBaseTexture
);
742 LeaveCriticalSection(&d3d9_cs
);
746 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pRenderTarget
, IDirect3DSurface9
* pDestSurface
) {
747 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
748 IDirect3DSurface9Impl
*renderTarget
= (IDirect3DSurface9Impl
*)pRenderTarget
;
749 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
751 TRACE("(%p)->(%p,%p)\n" , This
, renderTarget
, destSurface
);
753 EnterCriticalSection(&d3d9_cs
);
754 hr
= IWineD3DSurface_BltFast(destSurface
->wineD3DSurface
, 0, 0, renderTarget
->wineD3DSurface
, NULL
, WINEDDBLTFAST_NOCOLORKEY
);
755 LeaveCriticalSection(&d3d9_cs
);
759 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, IDirect3DSurface9
* pDestSurface
) {
760 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
761 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
763 TRACE("(%p) Relay\n" , This
);
765 EnterCriticalSection(&d3d9_cs
);
766 hr
= IWineD3DDevice_GetFrontBufferData(This
->WineD3DDevice
, iSwapChain
, destSurface
->wineD3DSurface
);
767 LeaveCriticalSection(&d3d9_cs
);
771 static HRESULT WINAPI
IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestSurface
, CONST RECT
* pDestRect
, D3DTEXTUREFILTERTYPE Filter
) {
772 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
773 IDirect3DSurface9Impl
*src
= (IDirect3DSurface9Impl
*) pSourceSurface
;
774 IDirect3DSurface9Impl
*dst
= (IDirect3DSurface9Impl
*) pDestSurface
;
777 TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This
, src
, pSourceRect
, dst
, pDestRect
, Filter
);
778 EnterCriticalSection(&d3d9_cs
);
779 hr
= IWineD3DSurface_Blt(dst
->wineD3DSurface
, pDestRect
, src
->wineD3DSurface
, pSourceRect
, 0, NULL
, Filter
);
780 LeaveCriticalSection(&d3d9_cs
);
784 static HRESULT WINAPI
IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSurface
, CONST RECT
* pRect
, D3DCOLOR color
) {
785 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
786 IDirect3DSurface9Impl
*surface
= (IDirect3DSurface9Impl
*)pSurface
;
788 WINED3DRESOURCETYPE restype
;
790 WINED3DSURFACE_DESC desc
;
792 TRACE("(%p) Relay\n" , This
);
794 memset(&desc
, 0, sizeof(desc
));
797 desc
.Type
= &restype
;
799 EnterCriticalSection(&d3d9_cs
);
800 IWineD3DSurface_GetDesc(surface
->wineD3DSurface
, &desc
);
802 /* This method is only allowed with surfaces that are render targets, or offscreen plain surfaces
805 if(!(usage
& WINED3DUSAGE_RENDERTARGET
) && (pool
!= WINED3DPOOL_DEFAULT
|| restype
!= WINED3DRTYPE_SURFACE
)) {
806 LeaveCriticalSection(&d3d9_cs
);
807 WARN("Surface is not a render target, or not a stand-alone D3DPOOL_DEFAULT surface\n");
808 return D3DERR_INVALIDCALL
;
811 /* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
812 /* Note: D3DRECT is compatible with WINED3DRECT */
813 hr
= IWineD3DDevice_ColorFill(This
->WineD3DDevice
, surface
->wineD3DSurface
, (CONST WINED3DRECT
*)pRect
, color
);
814 LeaveCriticalSection(&d3d9_cs
);
818 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
821 if(Pool
== D3DPOOL_MANAGED
){
822 FIXME("Attempting to create a managed offscreen plain surface\n");
823 return D3DERR_INVALIDCALL
;
826 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
828 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
829 Why, their always lockable?
830 should I change the usage to dynamic?
832 hr
= IDirect3DDevice9Impl_CreateSurface(iface
, Width
, Height
, Format
, TRUE
/* Lockable */, FALSE
/* Discard */,
833 0 /* Level */, ppSurface
, 0 /* Usage (undefined/none) */, (WINED3DPOOL
)Pool
, D3DMULTISAMPLE_NONE
,
834 0 /* MultisampleQuality */);
839 /* TODO: move to wineD3D */
840 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
* pRenderTarget
) {
841 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
842 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pRenderTarget
;
844 TRACE("(%p) Relay\n" , This
);
846 EnterCriticalSection(&d3d9_cs
);
847 hr
= IWineD3DDevice_SetRenderTarget(This
->WineD3DDevice
, RenderTargetIndex
, pSurface
? pSurface
->wineD3DSurface
: NULL
);
848 LeaveCriticalSection(&d3d9_cs
);
852 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
**ppRenderTarget
) {
853 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
854 IWineD3DSurface
*pRenderTarget
;
857 TRACE("(%p) Relay\n" , This
);
859 if (ppRenderTarget
== NULL
) {
860 return D3DERR_INVALIDCALL
;
863 EnterCriticalSection(&d3d9_cs
);
864 hr
=IWineD3DDevice_GetRenderTarget(This
->WineD3DDevice
,RenderTargetIndex
,&pRenderTarget
);
868 FIXME("Call to IWineD3DDevice_GetRenderTarget failed, hr %#x\n", hr
);
870 else if (!pRenderTarget
)
872 *ppRenderTarget
= NULL
;
876 IWineD3DSurface_GetParent(pRenderTarget
, (IUnknown
**)ppRenderTarget
);
877 IWineD3DSurface_Release(pRenderTarget
);
880 LeaveCriticalSection(&d3d9_cs
);
885 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pZStencilSurface
) {
886 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
887 IDirect3DSurface9Impl
*pSurface
;
889 TRACE("(%p) Relay\n" , This
);
891 pSurface
= (IDirect3DSurface9Impl
*)pZStencilSurface
;
892 EnterCriticalSection(&d3d9_cs
);
893 hr
= IWineD3DDevice_SetDepthStencilSurface(This
->WineD3DDevice
, NULL
==pSurface
? NULL
: pSurface
->wineD3DSurface
);
894 LeaveCriticalSection(&d3d9_cs
);
898 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
**ppZStencilSurface
) {
899 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
901 IWineD3DSurface
*pZStencilSurface
;
903 TRACE("(%p) Relay\n" , This
);
904 if(ppZStencilSurface
== NULL
){
905 return D3DERR_INVALIDCALL
;
908 EnterCriticalSection(&d3d9_cs
);
909 hr
= IWineD3DDevice_GetDepthStencilSurface(This
->WineD3DDevice
,&pZStencilSurface
);
910 if (hr
== WINED3D_OK
) {
911 IWineD3DSurface_GetParent(pZStencilSurface
,(IUnknown
**)ppZStencilSurface
);
912 IWineD3DSurface_Release(pZStencilSurface
);
914 if (hr
!= WINED3DERR_NOTFOUND
)
915 WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr
);
916 *ppZStencilSurface
= NULL
;
918 LeaveCriticalSection(&d3d9_cs
);
922 static HRESULT WINAPI
IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX iface
) {
923 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
925 TRACE("(%p) Relay\n" , This
);
927 EnterCriticalSection(&d3d9_cs
);
928 hr
= IWineD3DDevice_BeginScene(This
->WineD3DDevice
);
929 LeaveCriticalSection(&d3d9_cs
);
933 static HRESULT WINAPI
IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface
) {
934 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
936 TRACE("(%p) Relay\n" , This
);
938 EnterCriticalSection(&d3d9_cs
);
939 hr
= IWineD3DDevice_EndScene(This
->WineD3DDevice
);
940 LeaveCriticalSection(&d3d9_cs
);
944 static HRESULT WINAPI
IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9EX iface
, DWORD Count
, CONST D3DRECT
* pRects
, DWORD Flags
, D3DCOLOR Color
, float Z
, DWORD Stencil
) {
945 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
947 TRACE("(%p) Relay\n" , This
);
949 /* Note: D3DRECT is compatible with WINED3DRECT */
950 EnterCriticalSection(&d3d9_cs
);
951 hr
= IWineD3DDevice_Clear(This
->WineD3DDevice
, Count
, (CONST WINED3DRECT
*) pRects
, Flags
, Color
, Z
, Stencil
);
952 LeaveCriticalSection(&d3d9_cs
);
956 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* lpMatrix
) {
957 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
959 TRACE("(%p) Relay\n" , This
);
961 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
962 EnterCriticalSection(&d3d9_cs
);
963 hr
= IWineD3DDevice_SetTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) lpMatrix
);
964 LeaveCriticalSection(&d3d9_cs
);
968 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, D3DMATRIX
* pMatrix
) {
969 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
972 TRACE("(%p) Relay\n" , This
);
974 EnterCriticalSection(&d3d9_cs
);
975 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
976 hr
= IWineD3DDevice_GetTransform(This
->WineD3DDevice
, State
, (WINED3DMATRIX
*) pMatrix
);
977 LeaveCriticalSection(&d3d9_cs
);
982 static HRESULT WINAPI
IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* pMatrix
) {
983 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
985 TRACE("(%p) Relay\n" , This
);
987 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
988 EnterCriticalSection(&d3d9_cs
);
989 hr
= IWineD3DDevice_MultiplyTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) pMatrix
);
990 LeaveCriticalSection(&d3d9_cs
);
994 static HRESULT WINAPI
IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9EX iface
, CONST D3DVIEWPORT9
* pViewport
) {
995 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
997 TRACE("(%p) Relay\n" , This
);
999 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
1000 EnterCriticalSection(&d3d9_cs
);
1001 hr
= IWineD3DDevice_SetViewport(This
->WineD3DDevice
, (const WINED3DVIEWPORT
*)pViewport
);
1002 LeaveCriticalSection(&d3d9_cs
);
1006 static HRESULT WINAPI
IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9EX iface
, D3DVIEWPORT9
* pViewport
) {
1007 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1009 TRACE("(%p) Relay\n" , This
);
1011 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
1012 EnterCriticalSection(&d3d9_cs
);
1013 hr
= IWineD3DDevice_GetViewport(This
->WineD3DDevice
, (WINED3DVIEWPORT
*)pViewport
);
1014 LeaveCriticalSection(&d3d9_cs
);
1018 static HRESULT WINAPI
IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9EX iface
, CONST D3DMATERIAL9
* pMaterial
) {
1019 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1021 TRACE("(%p) Relay\n" , This
);
1023 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
1024 EnterCriticalSection(&d3d9_cs
);
1025 hr
= IWineD3DDevice_SetMaterial(This
->WineD3DDevice
, (const WINED3DMATERIAL
*)pMaterial
);
1026 LeaveCriticalSection(&d3d9_cs
);
1030 static HRESULT WINAPI
IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9EX iface
, D3DMATERIAL9
* pMaterial
) {
1031 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1033 TRACE("(%p) Relay\n" , This
);
1035 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
1036 EnterCriticalSection(&d3d9_cs
);
1037 hr
= IWineD3DDevice_GetMaterial(This
->WineD3DDevice
, (WINED3DMATERIAL
*)pMaterial
);
1038 LeaveCriticalSection(&d3d9_cs
);
1042 static HRESULT WINAPI
IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST D3DLIGHT9
* pLight
) {
1043 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1045 TRACE("(%p) Relay\n" , This
);
1047 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
1048 EnterCriticalSection(&d3d9_cs
);
1049 hr
= IWineD3DDevice_SetLight(This
->WineD3DDevice
, Index
, (const WINED3DLIGHT
*)pLight
);
1050 LeaveCriticalSection(&d3d9_cs
);
1054 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, D3DLIGHT9
* pLight
) {
1055 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1057 TRACE("(%p) Relay\n" , This
);
1059 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
1060 EnterCriticalSection(&d3d9_cs
);
1061 hr
= IWineD3DDevice_GetLight(This
->WineD3DDevice
, Index
, (WINED3DLIGHT
*)pLight
);
1062 LeaveCriticalSection(&d3d9_cs
);
1066 static HRESULT WINAPI
IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL Enable
) {
1067 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1069 TRACE("(%p) Relay\n" , This
);
1071 EnterCriticalSection(&d3d9_cs
);
1072 hr
= IWineD3DDevice_SetLightEnable(This
->WineD3DDevice
, Index
, Enable
);
1073 LeaveCriticalSection(&d3d9_cs
);
1077 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL
* pEnable
) {
1078 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1080 TRACE("(%p) Relay\n" , This
);
1082 EnterCriticalSection(&d3d9_cs
);
1083 hr
= IWineD3DDevice_GetLightEnable(This
->WineD3DDevice
, Index
, pEnable
);
1084 LeaveCriticalSection(&d3d9_cs
);
1088 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST
float* pPlane
) {
1089 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1091 TRACE("(%p) Relay\n" , This
);
1093 EnterCriticalSection(&d3d9_cs
);
1094 hr
= IWineD3DDevice_SetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
1095 LeaveCriticalSection(&d3d9_cs
);
1099 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, float* pPlane
) {
1100 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1102 TRACE("(%p) Relay\n" , This
);
1104 EnterCriticalSection(&d3d9_cs
);
1105 hr
= IWineD3DDevice_GetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
1106 LeaveCriticalSection(&d3d9_cs
);
1110 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD Value
) {
1111 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1113 TRACE("(%p) Relay\n" , This
);
1115 EnterCriticalSection(&d3d9_cs
);
1116 hr
= IWineD3DDevice_SetRenderState(This
->WineD3DDevice
, State
, Value
);
1117 LeaveCriticalSection(&d3d9_cs
);
1121 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD
* pValue
) {
1122 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1124 TRACE("(%p) Relay\n" , This
);
1126 EnterCriticalSection(&d3d9_cs
);
1127 hr
= IWineD3DDevice_GetRenderState(This
->WineD3DDevice
, State
, pValue
);
1128 LeaveCriticalSection(&d3d9_cs
);
1132 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX iface
, CONST D3DCLIPSTATUS9
* pClipStatus
) {
1133 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1135 TRACE("(%p) Relay\n" , This
);
1137 EnterCriticalSection(&d3d9_cs
);
1138 hr
= IWineD3DDevice_SetClipStatus(This
->WineD3DDevice
, (const WINED3DCLIPSTATUS
*)pClipStatus
);
1139 LeaveCriticalSection(&d3d9_cs
);
1143 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9EX iface
, D3DCLIPSTATUS9
* pClipStatus
) {
1144 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1146 TRACE("(%p) Relay\n" , This
);
1148 EnterCriticalSection(&d3d9_cs
);
1149 hr
= IWineD3DDevice_GetClipStatus(This
->WineD3DDevice
, (WINED3DCLIPSTATUS
*)pClipStatus
);
1150 LeaveCriticalSection(&d3d9_cs
);
1154 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
**ppTexture
) {
1155 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1156 IWineD3DBaseTexture
*retTexture
= NULL
;
1157 HRESULT rc
= D3D_OK
;
1159 TRACE("(%p) Relay\n" , This
);
1161 if(ppTexture
== NULL
){
1162 return D3DERR_INVALIDCALL
;
1165 EnterCriticalSection(&d3d9_cs
);
1166 rc
= IWineD3DDevice_GetTexture(This
->WineD3DDevice
, Stage
, &retTexture
);
1167 if (SUCCEEDED(rc
) && NULL
!= retTexture
) {
1168 IWineD3DBaseTexture_GetParent(retTexture
, (IUnknown
**)ppTexture
);
1169 IWineD3DBaseTexture_Release(retTexture
);
1172 WARN("Call to get texture (%d) failed (%p)\n", Stage
, retTexture
);
1176 LeaveCriticalSection(&d3d9_cs
);
1181 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
* pTexture
) {
1182 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1184 TRACE("(%p) Relay %d %p\n" , This
, Stage
, pTexture
);
1186 EnterCriticalSection(&d3d9_cs
);
1187 hr
= IWineD3DDevice_SetTexture(This
->WineD3DDevice
, Stage
,
1188 pTexture
==NULL
? NULL
:((IDirect3DBaseTexture9Impl
*)pTexture
)->wineD3DBaseTexture
);
1189 LeaveCriticalSection(&d3d9_cs
);
1193 static const WINED3DTEXTURESTAGESTATETYPE tss_lookup
[] =
1195 WINED3DTSS_FORCE_DWORD
, /* 0, unused */
1196 WINED3DTSS_COLOROP
, /* 1, D3DTSS_COLOROP */
1197 WINED3DTSS_COLORARG1
, /* 2, D3DTSS_COLORARG1 */
1198 WINED3DTSS_COLORARG2
, /* 3, D3DTSS_COLORARG2 */
1199 WINED3DTSS_ALPHAOP
, /* 4, D3DTSS_ALPHAOP */
1200 WINED3DTSS_ALPHAARG1
, /* 5, D3DTSS_ALPHAARG1 */
1201 WINED3DTSS_ALPHAARG2
, /* 6, D3DTSS_ALPHAARG2 */
1202 WINED3DTSS_BUMPENVMAT00
, /* 7, D3DTSS_BUMPENVMAT00 */
1203 WINED3DTSS_BUMPENVMAT01
, /* 8, D3DTSS_BUMPENVMAT01 */
1204 WINED3DTSS_BUMPENVMAT10
, /* 9, D3DTSS_BUMPENVMAT10 */
1205 WINED3DTSS_BUMPENVMAT11
, /* 10, D3DTSS_BUMPENVMAT11 */
1206 WINED3DTSS_TEXCOORDINDEX
, /* 11, D3DTSS_TEXCOORDINDEX */
1207 WINED3DTSS_FORCE_DWORD
, /* 12, unused */
1208 WINED3DTSS_FORCE_DWORD
, /* 13, unused */
1209 WINED3DTSS_FORCE_DWORD
, /* 14, unused */
1210 WINED3DTSS_FORCE_DWORD
, /* 15, unused */
1211 WINED3DTSS_FORCE_DWORD
, /* 16, unused */
1212 WINED3DTSS_FORCE_DWORD
, /* 17, unused */
1213 WINED3DTSS_FORCE_DWORD
, /* 18, unused */
1214 WINED3DTSS_FORCE_DWORD
, /* 19, unused */
1215 WINED3DTSS_FORCE_DWORD
, /* 20, unused */
1216 WINED3DTSS_FORCE_DWORD
, /* 21, unused */
1217 WINED3DTSS_BUMPENVLSCALE
, /* 22, D3DTSS_BUMPENVLSCALE */
1218 WINED3DTSS_BUMPENVLOFFSET
, /* 23, D3DTSS_BUMPENVLOFFSET */
1219 WINED3DTSS_TEXTURETRANSFORMFLAGS
, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
1220 WINED3DTSS_FORCE_DWORD
, /* 25, unused */
1221 WINED3DTSS_COLORARG0
, /* 26, D3DTSS_COLORARG0 */
1222 WINED3DTSS_ALPHAARG0
, /* 27, D3DTSS_ALPHAARG0 */
1223 WINED3DTSS_RESULTARG
, /* 28, D3DTSS_RESULTARG */
1224 WINED3DTSS_FORCE_DWORD
, /* 29, unused */
1225 WINED3DTSS_FORCE_DWORD
, /* 30, unused */
1226 WINED3DTSS_FORCE_DWORD
, /* 31, unused */
1227 WINED3DTSS_CONSTANT
, /* 32, D3DTSS_CONSTANT */
1230 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD
* pValue
) {
1231 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1233 TRACE("(%p) Relay\n" , This
);
1235 EnterCriticalSection(&d3d9_cs
);
1236 hr
= IWineD3DDevice_GetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], pValue
);
1237 LeaveCriticalSection(&d3d9_cs
);
1241 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD Value
) {
1242 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1244 TRACE("(%p) Relay\n" , This
);
1246 EnterCriticalSection(&d3d9_cs
);
1247 hr
= IWineD3DDevice_SetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], Value
);
1248 LeaveCriticalSection(&d3d9_cs
);
1252 static HRESULT WINAPI
IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9EX iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD
* pValue
) {
1253 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1255 TRACE("(%p) Relay\n" , This
);
1257 EnterCriticalSection(&d3d9_cs
);
1258 hr
= IWineD3DDevice_GetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, pValue
);
1259 LeaveCriticalSection(&d3d9_cs
);
1263 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD Value
) {
1264 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1266 TRACE("(%p) Relay\n" , This
);
1268 EnterCriticalSection(&d3d9_cs
);
1269 hr
= IWineD3DDevice_SetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, Value
);
1270 LeaveCriticalSection(&d3d9_cs
);
1274 static HRESULT WINAPI
IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9EX iface
, DWORD
* pNumPasses
) {
1275 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1277 TRACE("(%p) Relay\n" , This
);
1279 EnterCriticalSection(&d3d9_cs
);
1280 hr
= IWineD3DDevice_ValidateDevice(This
->WineD3DDevice
, pNumPasses
);
1281 LeaveCriticalSection(&d3d9_cs
);
1285 static HRESULT WINAPI
IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
, CONST PALETTEENTRY
* pEntries
) {
1286 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1288 TRACE("(%p) Relay\n" , This
);
1290 EnterCriticalSection(&d3d9_cs
);
1291 hr
= IWineD3DDevice_SetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1292 LeaveCriticalSection(&d3d9_cs
);
1296 static HRESULT WINAPI
IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
, PALETTEENTRY
* pEntries
) {
1297 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1299 TRACE("(%p) Relay\n" , This
);
1301 EnterCriticalSection(&d3d9_cs
);
1302 hr
= IWineD3DDevice_GetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1303 LeaveCriticalSection(&d3d9_cs
);
1307 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
) {
1308 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1310 TRACE("(%p) Relay\n" , This
);
1312 EnterCriticalSection(&d3d9_cs
);
1313 hr
= IWineD3DDevice_SetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1314 LeaveCriticalSection(&d3d9_cs
);
1318 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT
* PaletteNumber
) {
1319 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1321 TRACE("(%p) Relay\n" , This
);
1323 EnterCriticalSection(&d3d9_cs
);
1324 hr
= IWineD3DDevice_GetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1325 LeaveCriticalSection(&d3d9_cs
);
1329 static HRESULT WINAPI
IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9EX iface
, CONST RECT
* pRect
) {
1330 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1332 TRACE("(%p) Relay\n" , This
);
1334 EnterCriticalSection(&d3d9_cs
);
1335 hr
= IWineD3DDevice_SetScissorRect(This
->WineD3DDevice
, pRect
);
1336 LeaveCriticalSection(&d3d9_cs
);
1340 static HRESULT WINAPI
IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9EX iface
, RECT
* pRect
) {
1341 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1343 TRACE("(%p) Relay\n" , This
);
1345 EnterCriticalSection(&d3d9_cs
);
1346 hr
= IWineD3DDevice_GetScissorRect(This
->WineD3DDevice
, pRect
);
1347 LeaveCriticalSection(&d3d9_cs
);
1351 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
, BOOL bSoftware
) {
1352 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1354 TRACE("(%p) Relay\n" , This
);
1356 EnterCriticalSection(&d3d9_cs
);
1357 hr
= IWineD3DDevice_SetSoftwareVertexProcessing(This
->WineD3DDevice
, bSoftware
);
1358 LeaveCriticalSection(&d3d9_cs
);
1362 static BOOL WINAPI
IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
) {
1363 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1365 TRACE("(%p) Relay\n" , This
);
1367 EnterCriticalSection(&d3d9_cs
);
1368 ret
= IWineD3DDevice_GetSoftwareVertexProcessing(This
->WineD3DDevice
);
1369 LeaveCriticalSection(&d3d9_cs
);
1373 static HRESULT WINAPI
IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9EX iface
, float nSegments
) {
1374 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1376 TRACE("(%p) Relay\n" , This
);
1378 EnterCriticalSection(&d3d9_cs
);
1379 hr
= IWineD3DDevice_SetNPatchMode(This
->WineD3DDevice
, nSegments
);
1380 LeaveCriticalSection(&d3d9_cs
);
1384 static float WINAPI
IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9EX iface
) {
1385 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1387 TRACE("(%p) Relay\n" , This
);
1389 EnterCriticalSection(&d3d9_cs
);
1390 ret
= IWineD3DDevice_GetNPatchMode(This
->WineD3DDevice
);
1391 LeaveCriticalSection(&d3d9_cs
);
1395 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT StartVertex
, UINT PrimitiveCount
) {
1396 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1398 TRACE("(%p) Relay\n" , This
);
1400 EnterCriticalSection(&d3d9_cs
);
1401 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1402 hr
= IWineD3DDevice_DrawPrimitive(This
->WineD3DDevice
, StartVertex
,
1403 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
));
1404 LeaveCriticalSection(&d3d9_cs
);
1408 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
,
1409 INT BaseVertexIndex
, UINT MinVertexIndex
, UINT NumVertices
, UINT startIndex
, UINT primCount
) {
1410 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1412 TRACE("(%p) Relay\n" , This
);
1414 /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
1415 EnterCriticalSection(&d3d9_cs
);
1416 IWineD3DDevice_SetBaseVertexIndex(This
->WineD3DDevice
, BaseVertexIndex
);
1417 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1418 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->WineD3DDevice
, MinVertexIndex
, NumVertices
,
1419 startIndex
, vertex_count_from_primitive_count(PrimitiveType
, primCount
));
1420 LeaveCriticalSection(&d3d9_cs
);
1424 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT PrimitiveCount
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1425 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1427 TRACE("(%p) Relay\n" , This
);
1429 EnterCriticalSection(&d3d9_cs
);
1430 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1431 hr
= IWineD3DDevice_DrawPrimitiveUP(This
->WineD3DDevice
,
1432 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
),
1433 pVertexStreamZeroData
, VertexStreamZeroStride
);
1434 LeaveCriticalSection(&d3d9_cs
);
1438 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT MinVertexIndex
,
1439 UINT NumVertexIndices
, UINT PrimitiveCount
, CONST
void* pIndexData
,
1440 D3DFORMAT IndexDataFormat
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1441 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1443 TRACE("(%p) Relay\n" , This
);
1445 EnterCriticalSection(&d3d9_cs
);
1446 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1447 hr
= IWineD3DDevice_DrawIndexedPrimitiveUP(This
->WineD3DDevice
, MinVertexIndex
, NumVertexIndices
,
1448 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
), pIndexData
,
1449 wined3dformat_from_d3dformat(IndexDataFormat
), pVertexStreamZeroData
, VertexStreamZeroStride
);
1450 LeaveCriticalSection(&d3d9_cs
);
1454 static HRESULT WINAPI
IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX iface
, UINT SrcStartIndex
, UINT DestIndex
, UINT VertexCount
, IDirect3DVertexBuffer9
* pDestBuffer
, IDirect3DVertexDeclaration9
* pVertexDecl
, DWORD Flags
) {
1455 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1456 IDirect3DVertexDeclaration9Impl
*Decl
= (IDirect3DVertexDeclaration9Impl
*) pVertexDecl
;
1458 IDirect3DVertexBuffer9Impl
*dest
= (IDirect3DVertexBuffer9Impl
*) pDestBuffer
;
1459 TRACE("(%p) Relay\n" , This
);
1461 EnterCriticalSection(&d3d9_cs
);
1462 hr
= IWineD3DDevice_ProcessVertices(This
->WineD3DDevice
,SrcStartIndex
, DestIndex
, VertexCount
, dest
->wineD3DVertexBuffer
, Decl
? Decl
->wineD3DVertexDeclaration
: NULL
, Flags
, dest
->fvf
);
1463 LeaveCriticalSection(&d3d9_cs
);
1467 static IDirect3DVertexDeclaration9
*getConvertedDecl(IDirect3DDevice9Impl
*This
, DWORD fvf
) {
1469 D3DVERTEXELEMENT9
* elements
= NULL
;
1470 IDirect3DVertexDeclaration9
* pDecl
= NULL
;
1471 int p
, low
, high
; /* deliberately signed */
1472 IDirect3DVertexDeclaration9
**convertedDecls
= This
->convertedDecls
;
1474 TRACE("Searching for declaration for fvf %08x... ", fvf
);
1477 high
= This
->numConvertedDecls
- 1;
1478 while(low
<= high
) {
1479 p
= (low
+ high
) >> 1;
1481 if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
== fvf
) {
1482 TRACE("found %p\n", convertedDecls
[p
]);
1483 return convertedDecls
[p
];
1484 } else if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
< fvf
) {
1490 TRACE("not found. Creating and inserting at position %d.\n", low
);
1492 hr
= vdecl_convert_fvf(fvf
, &elements
);
1493 if (hr
!= S_OK
) return NULL
;
1495 hr
= IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9Ex
*) This
, elements
, &pDecl
);
1496 HeapFree(GetProcessHeap(), 0, elements
); /* CreateVertexDeclaration makes a copy */
1497 if (hr
!= S_OK
) return NULL
;
1499 if(This
->declArraySize
== This
->numConvertedDecls
) {
1500 int grow
= max(This
->declArraySize
/ 2, 8);
1501 convertedDecls
= HeapReAlloc(GetProcessHeap(), 0, convertedDecls
,
1502 sizeof(convertedDecls
[0]) * (This
->numConvertedDecls
+ grow
));
1503 if(!convertedDecls
) {
1504 /* This will destroy it */
1505 IDirect3DVertexDeclaration9_Release(pDecl
);
1508 This
->convertedDecls
= convertedDecls
;
1509 This
->declArraySize
+= grow
;
1512 memmove(convertedDecls
+ low
+ 1, convertedDecls
+ low
, sizeof(IDirect3DVertexDeclaration9Impl
*) * (This
->numConvertedDecls
- low
));
1513 convertedDecls
[low
] = pDecl
;
1514 This
->numConvertedDecls
++;
1516 /* Will prevent the decl from being destroyed */
1517 ((IDirect3DVertexDeclaration9Impl
*) pDecl
)->convFVF
= fvf
;
1518 IDirect3DVertexDeclaration9_Release(pDecl
); /* Does not destroy now */
1520 TRACE("Returning %p. %d decls in array\n", pDecl
, This
->numConvertedDecls
);
1524 static HRESULT WINAPI
IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface
, DWORD FVF
) {
1525 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1526 IDirect3DVertexDeclaration9
*decl
;
1529 TRACE("(%p) Relay\n" , This
);
1533 WARN("%#x is not a valid FVF\n", FVF
);
1537 EnterCriticalSection(&d3d9_cs
);
1538 decl
= getConvertedDecl(This
, FVF
);
1539 LeaveCriticalSection(&d3d9_cs
);
1543 /* Any situation when this should happen, except out of memory? */
1544 ERR("Failed to create a converted vertex declaration\n");
1545 return D3DERR_DRIVERINTERNALERROR
;
1548 hr
= IDirect3DDevice9Impl_SetVertexDeclaration(iface
, decl
);
1549 if (FAILED(hr
)) ERR("Failed to set vertex declaration\n");
1554 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface
, DWORD
* pFVF
) {
1555 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1556 IDirect3DVertexDeclaration9
*decl
;
1558 TRACE("(%p) Relay\n" , This
);
1560 hr
= IDirect3DDevice9_GetVertexDeclaration(iface
, &decl
);
1563 WARN("Failed to get vertex declaration, %#x\n", hr
);
1570 *pFVF
= ((IDirect3DVertexDeclaration9Impl
*)decl
)->convFVF
;
1571 IDirect3DVertexDeclaration9_Release(decl
);
1578 TRACE("Returning FVF %#x\n", *pFVF
);
1583 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
* pStreamData
, UINT OffsetInBytes
, UINT Stride
) {
1584 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1586 TRACE("(%p) Relay\n" , This
);
1588 EnterCriticalSection(&d3d9_cs
);
1589 hr
= IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, StreamNumber
,
1590 pStreamData
==NULL
? NULL
:((IDirect3DVertexBuffer9Impl
*)pStreamData
)->wineD3DVertexBuffer
,
1591 OffsetInBytes
, Stride
);
1592 LeaveCriticalSection(&d3d9_cs
);
1596 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
**pStream
, UINT
* OffsetInBytes
, UINT
* pStride
) {
1597 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1598 IWineD3DBuffer
*retStream
= NULL
;
1599 HRESULT rc
= D3D_OK
;
1601 TRACE("(%p) Relay\n" , This
);
1603 if(pStream
== NULL
){
1604 return D3DERR_INVALIDCALL
;
1607 EnterCriticalSection(&d3d9_cs
);
1608 rc
= IWineD3DDevice_GetStreamSource(This
->WineD3DDevice
, StreamNumber
, &retStream
, OffsetInBytes
, pStride
);
1609 if (rc
== D3D_OK
&& NULL
!= retStream
) {
1610 IWineD3DBuffer_GetParent(retStream
, (IUnknown
**)pStream
);
1611 IWineD3DBuffer_Release(retStream
);
1614 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes
, pStride
);
1618 LeaveCriticalSection(&d3d9_cs
);
1623 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, UINT Divider
) {
1624 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1626 TRACE("(%p) Relay\n" , This
);
1628 EnterCriticalSection(&d3d9_cs
);
1629 hr
= IWineD3DDevice_SetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1630 LeaveCriticalSection(&d3d9_cs
);
1634 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, UINT
* Divider
) {
1635 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1637 TRACE("(%p) Relay\n" , This
);
1639 EnterCriticalSection(&d3d9_cs
);
1640 hr
= IWineD3DDevice_GetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1641 LeaveCriticalSection(&d3d9_cs
);
1645 static HRESULT WINAPI
IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
* pIndexData
) {
1646 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1648 IDirect3DIndexBuffer9Impl
*ib
= (IDirect3DIndexBuffer9Impl
*) pIndexData
;
1649 TRACE("(%p) Relay\n", This
);
1651 EnterCriticalSection(&d3d9_cs
);
1652 hr
= IWineD3DDevice_SetIndices(This
->WineD3DDevice
,
1653 ib
? ib
->wineD3DIndexBuffer
: NULL
,
1654 ib
? ib
->format
: WINED3DFMT_UNKNOWN
);
1655 LeaveCriticalSection(&d3d9_cs
);
1659 static HRESULT WINAPI
IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
**ppIndexData
) {
1660 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1661 IWineD3DBuffer
*retIndexData
= NULL
;
1662 HRESULT rc
= D3D_OK
;
1664 TRACE("(%p) Relay\n", This
);
1666 if(ppIndexData
== NULL
){
1667 return D3DERR_INVALIDCALL
;
1670 EnterCriticalSection(&d3d9_cs
);
1671 rc
= IWineD3DDevice_GetIndices(This
->WineD3DDevice
, &retIndexData
);
1672 if (SUCCEEDED(rc
) && retIndexData
) {
1673 IWineD3DBuffer_GetParent(retIndexData
, (IUnknown
**)ppIndexData
);
1674 IWineD3DBuffer_Release(retIndexData
);
1676 if (FAILED(rc
)) FIXME("Call to GetIndices failed\n");
1677 *ppIndexData
= NULL
;
1679 LeaveCriticalSection(&d3d9_cs
);
1683 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DRECTPATCH_INFO
* pRectPatchInfo
) {
1684 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1686 TRACE("(%p) Relay\n", This
);
1688 EnterCriticalSection(&d3d9_cs
);
1689 hr
= IWineD3DDevice_DrawRectPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DRECTPATCH_INFO
*)pRectPatchInfo
);
1690 LeaveCriticalSection(&d3d9_cs
);
1694 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DTRIPATCH_INFO
* pTriPatchInfo
) {
1695 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1697 TRACE("(%p) Relay\n", This
);
1699 EnterCriticalSection(&d3d9_cs
);
1700 hr
= IWineD3DDevice_DrawTriPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DTRIPATCH_INFO
*)pTriPatchInfo
);
1701 LeaveCriticalSection(&d3d9_cs
);
1705 static HRESULT WINAPI
IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
) {
1706 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1708 TRACE("(%p) Relay\n", This
);
1710 EnterCriticalSection(&d3d9_cs
);
1711 hr
= IWineD3DDevice_DeletePatch(This
->WineD3DDevice
, Handle
);
1712 LeaveCriticalSection(&d3d9_cs
);
1716 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(LPDIRECT3DDEVICE9EX iface
, UINT width
, UINT height
, float *rows
, float *columns
) {
1717 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1718 FIXME("(%p)->(%d, %d, %p, %p) Stub!\n", This
, width
, height
, rows
, columns
);
1719 return WINED3DERR_INVALIDCALL
;
1722 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ComposeRects(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
*pSrc
, IDirect3DDevice9
*pDst
, IDirect3DVertexBuffer9
*pSrcRectDescs
, UINT NumRects
, IDirect3DVertexBuffer9
*pDstRectDescs
, D3DCOMPOSERECTSOP Operation
, int Xoffset
, int Yoffset
) {
1723 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1724 FIXME("(%p)->(%p, %p, %p, %d, %p, %d, %d, %d) Stub!\n", This
, pSrc
, pDst
, pSrcRectDescs
, NumRects
, pDstRectDescs
, Operation
, Xoffset
, Yoffset
);
1725 return WINED3DERR_INVALIDCALL
;
1728 static HRESULT WINAPI
IDirect3DDevice9ExImpl_PresentEx(LPDIRECT3DDEVICE9EX iface
, CONST RECT
*pSourceRect
, CONST RECT
*pDestRect
, HWND hDestWindowOverride
, CONST RGNDATA
*pDirtyRegion
, DWORD dwFlags
) {
1729 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1730 FIXME("(%p= -> (%p), %p, %p, %p, 0x%08x) Stub!\n", This
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
, dwFlags
);
1731 return WINED3DERR_INVALIDCALL
;
1734 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface
, INT
*pPriority
) {
1735 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1736 FIXME("(%p)->(%p) Stub!\n", This
, pPriority
);
1737 return WINED3DERR_INVALIDCALL
;
1740 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface
, INT Priority
) {
1741 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1742 FIXME("(%p)->(%d) Stub!\n", This
, Priority
);
1743 return WINED3DERR_INVALIDCALL
;
1746 static HRESULT WINAPI
IDirect3DDevice9ExImpl_WaitForVBlank(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
) {
1747 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1748 FIXME("(%p)->(%d) Stub!\n", This
, iSwapChain
);
1749 return WINED3DERR_INVALIDCALL
;
1752 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckresourceResidency(LPDIRECT3DDEVICE9EX iface
, IDirect3DResource9
** pResourceArray
, UINT32 Numresources
) {
1753 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1754 FIXME("(%p)->(%p, %d) Stub!\n", This
, pResourceArray
, Numresources
);
1755 return WINED3DERR_INVALIDCALL
;
1758 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface
, UINT MaxLatency
) {
1759 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1760 FIXME("(%p)->(%d) Stub!\n", This
, MaxLatency
);
1761 return WINED3DERR_INVALIDCALL
;
1764 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface
, UINT
*pMaxLatency
) {
1765 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1766 FIXME("(%p)->(%p) Stub!\n", This
, pMaxLatency
);
1768 return WINED3DERR_INVALIDCALL
;
1771 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckdeviceState(LPDIRECT3DDEVICE9EX iface
, HWND hDestinationWindow
) {
1772 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1773 FIXME("(%p)->(%p) Stub!\n", This
, hDestinationWindow
);
1774 return WINED3DERR_INVALIDCALL
;
1777 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CreateRenderTargetEx(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultiSampleQuality
, BOOL Lockable
, IDirect3DSurface9
** ppSurface
, HANDLE
*pSharedHandle
, DWORD Usage
) {
1778 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1779 FIXME("(%p)->(%d, %d, %d, %d, %d, %s, %p, %p, 0x%08x) Stub!\n", This
, Width
, Height
, Format
, MultiSample
, MultiSampleQuality
, Lockable
? "true" : "false", ppSurface
, pSharedHandle
, Usage
);
1780 return WINED3DERR_INVALIDCALL
;
1783 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
*pSharedHandle
, DWORD Usage
) {
1784 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1785 FIXME("(%p)->(%d, %d, %d, %d, %p, %p, 0x%08x) Stub!\n", This
, Width
, Height
, Format
, Pool
, ppSurface
, pSharedHandle
, Usage
);
1786 return WINED3DERR_INVALIDCALL
;
1789 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultiSampleQuality
, BOOL Discard
, IDirect3DSurface9
**ppSurface
, HANDLE
*pSharedHandle
, DWORD Usage
) {
1790 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1791 FIXME("(%p)->(%d, %d, %d, %d, %d, %s, %p, %p, 0x%08x) Stub!\n", This
, Width
, Height
, Format
, MultiSample
, MultiSampleQuality
, Discard
? "true" : "false", ppSurface
, pSharedHandle
, Usage
);
1792 return WINED3DERR_INVALIDCALL
;
1795 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ResetEx(LPDIRECT3DDEVICE9EX iface
, D3DPRESENT_PARAMETERS
*pPresentationParameters
, D3DDISPLAYMODEEX
*pFullscreenDisplayMode
) {
1796 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1797 FIXME("(%p)->(%p) Stub!\n", This
, pPresentationParameters
);
1798 return WINED3DERR_INVALIDCALL
;
1801 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetDisplayModeEx(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DDISPLAYMODEEX
*pMode
, D3DDISPLAYROTATION
*pRotation
) {
1802 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1803 FIXME("(%p)->(%d, %p, %p) Stub!\n", This
, iSwapChain
, pMode
, pRotation
);
1804 return WINED3DERR_INVALIDCALL
;
1807 const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl
=
1810 IDirect3DDevice9Impl_QueryInterface
,
1811 IDirect3DDevice9Impl_AddRef
,
1812 IDirect3DDevice9Impl_Release
,
1813 /* IDirect3DDevice9 */
1814 IDirect3DDevice9Impl_TestCooperativeLevel
,
1815 IDirect3DDevice9Impl_GetAvailableTextureMem
,
1816 IDirect3DDevice9Impl_EvictManagedResources
,
1817 IDirect3DDevice9Impl_GetDirect3D
,
1818 IDirect3DDevice9Impl_GetDeviceCaps
,
1819 IDirect3DDevice9Impl_GetDisplayMode
,
1820 IDirect3DDevice9Impl_GetCreationParameters
,
1821 IDirect3DDevice9Impl_SetCursorProperties
,
1822 IDirect3DDevice9Impl_SetCursorPosition
,
1823 IDirect3DDevice9Impl_ShowCursor
,
1824 IDirect3DDevice9Impl_CreateAdditionalSwapChain
,
1825 IDirect3DDevice9Impl_GetSwapChain
,
1826 IDirect3DDevice9Impl_GetNumberOfSwapChains
,
1827 IDirect3DDevice9Impl_Reset
,
1828 IDirect3DDevice9Impl_Present
,
1829 IDirect3DDevice9Impl_GetBackBuffer
,
1830 IDirect3DDevice9Impl_GetRasterStatus
,
1831 IDirect3DDevice9Impl_SetDialogBoxMode
,
1832 IDirect3DDevice9Impl_SetGammaRamp
,
1833 IDirect3DDevice9Impl_GetGammaRamp
,
1834 IDirect3DDevice9Impl_CreateTexture
,
1835 IDirect3DDevice9Impl_CreateVolumeTexture
,
1836 IDirect3DDevice9Impl_CreateCubeTexture
,
1837 IDirect3DDevice9Impl_CreateVertexBuffer
,
1838 IDirect3DDevice9Impl_CreateIndexBuffer
,
1839 IDirect3DDevice9Impl_CreateRenderTarget
,
1840 IDirect3DDevice9Impl_CreateDepthStencilSurface
,
1841 IDirect3DDevice9Impl_UpdateSurface
,
1842 IDirect3DDevice9Impl_UpdateTexture
,
1843 IDirect3DDevice9Impl_GetRenderTargetData
,
1844 IDirect3DDevice9Impl_GetFrontBufferData
,
1845 IDirect3DDevice9Impl_StretchRect
,
1846 IDirect3DDevice9Impl_ColorFill
,
1847 IDirect3DDevice9Impl_CreateOffscreenPlainSurface
,
1848 IDirect3DDevice9Impl_SetRenderTarget
,
1849 IDirect3DDevice9Impl_GetRenderTarget
,
1850 IDirect3DDevice9Impl_SetDepthStencilSurface
,
1851 IDirect3DDevice9Impl_GetDepthStencilSurface
,
1852 IDirect3DDevice9Impl_BeginScene
,
1853 IDirect3DDevice9Impl_EndScene
,
1854 IDirect3DDevice9Impl_Clear
,
1855 IDirect3DDevice9Impl_SetTransform
,
1856 IDirect3DDevice9Impl_GetTransform
,
1857 IDirect3DDevice9Impl_MultiplyTransform
,
1858 IDirect3DDevice9Impl_SetViewport
,
1859 IDirect3DDevice9Impl_GetViewport
,
1860 IDirect3DDevice9Impl_SetMaterial
,
1861 IDirect3DDevice9Impl_GetMaterial
,
1862 IDirect3DDevice9Impl_SetLight
,
1863 IDirect3DDevice9Impl_GetLight
,
1864 IDirect3DDevice9Impl_LightEnable
,
1865 IDirect3DDevice9Impl_GetLightEnable
,
1866 IDirect3DDevice9Impl_SetClipPlane
,
1867 IDirect3DDevice9Impl_GetClipPlane
,
1868 IDirect3DDevice9Impl_SetRenderState
,
1869 IDirect3DDevice9Impl_GetRenderState
,
1870 IDirect3DDevice9Impl_CreateStateBlock
,
1871 IDirect3DDevice9Impl_BeginStateBlock
,
1872 IDirect3DDevice9Impl_EndStateBlock
,
1873 IDirect3DDevice9Impl_SetClipStatus
,
1874 IDirect3DDevice9Impl_GetClipStatus
,
1875 IDirect3DDevice9Impl_GetTexture
,
1876 IDirect3DDevice9Impl_SetTexture
,
1877 IDirect3DDevice9Impl_GetTextureStageState
,
1878 IDirect3DDevice9Impl_SetTextureStageState
,
1879 IDirect3DDevice9Impl_GetSamplerState
,
1880 IDirect3DDevice9Impl_SetSamplerState
,
1881 IDirect3DDevice9Impl_ValidateDevice
,
1882 IDirect3DDevice9Impl_SetPaletteEntries
,
1883 IDirect3DDevice9Impl_GetPaletteEntries
,
1884 IDirect3DDevice9Impl_SetCurrentTexturePalette
,
1885 IDirect3DDevice9Impl_GetCurrentTexturePalette
,
1886 IDirect3DDevice9Impl_SetScissorRect
,
1887 IDirect3DDevice9Impl_GetScissorRect
,
1888 IDirect3DDevice9Impl_SetSoftwareVertexProcessing
,
1889 IDirect3DDevice9Impl_GetSoftwareVertexProcessing
,
1890 IDirect3DDevice9Impl_SetNPatchMode
,
1891 IDirect3DDevice9Impl_GetNPatchMode
,
1892 IDirect3DDevice9Impl_DrawPrimitive
,
1893 IDirect3DDevice9Impl_DrawIndexedPrimitive
,
1894 IDirect3DDevice9Impl_DrawPrimitiveUP
,
1895 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP
,
1896 IDirect3DDevice9Impl_ProcessVertices
,
1897 IDirect3DDevice9Impl_CreateVertexDeclaration
,
1898 IDirect3DDevice9Impl_SetVertexDeclaration
,
1899 IDirect3DDevice9Impl_GetVertexDeclaration
,
1900 IDirect3DDevice9Impl_SetFVF
,
1901 IDirect3DDevice9Impl_GetFVF
,
1902 IDirect3DDevice9Impl_CreateVertexShader
,
1903 IDirect3DDevice9Impl_SetVertexShader
,
1904 IDirect3DDevice9Impl_GetVertexShader
,
1905 IDirect3DDevice9Impl_SetVertexShaderConstantF
,
1906 IDirect3DDevice9Impl_GetVertexShaderConstantF
,
1907 IDirect3DDevice9Impl_SetVertexShaderConstantI
,
1908 IDirect3DDevice9Impl_GetVertexShaderConstantI
,
1909 IDirect3DDevice9Impl_SetVertexShaderConstantB
,
1910 IDirect3DDevice9Impl_GetVertexShaderConstantB
,
1911 IDirect3DDevice9Impl_SetStreamSource
,
1912 IDirect3DDevice9Impl_GetStreamSource
,
1913 IDirect3DDevice9Impl_SetStreamSourceFreq
,
1914 IDirect3DDevice9Impl_GetStreamSourceFreq
,
1915 IDirect3DDevice9Impl_SetIndices
,
1916 IDirect3DDevice9Impl_GetIndices
,
1917 IDirect3DDevice9Impl_CreatePixelShader
,
1918 IDirect3DDevice9Impl_SetPixelShader
,
1919 IDirect3DDevice9Impl_GetPixelShader
,
1920 IDirect3DDevice9Impl_SetPixelShaderConstantF
,
1921 IDirect3DDevice9Impl_GetPixelShaderConstantF
,
1922 IDirect3DDevice9Impl_SetPixelShaderConstantI
,
1923 IDirect3DDevice9Impl_GetPixelShaderConstantI
,
1924 IDirect3DDevice9Impl_SetPixelShaderConstantB
,
1925 IDirect3DDevice9Impl_GetPixelShaderConstantB
,
1926 IDirect3DDevice9Impl_DrawRectPatch
,
1927 IDirect3DDevice9Impl_DrawTriPatch
,
1928 IDirect3DDevice9Impl_DeletePatch
,
1929 IDirect3DDevice9Impl_CreateQuery
,
1930 /* IDirect3DDevice9Ex */
1931 IDirect3DDevice9ExImpl_SetConvolutionMonoKernel
,
1932 IDirect3DDevice9ExImpl_ComposeRects
,
1933 IDirect3DDevice9ExImpl_PresentEx
,
1934 IDirect3DDevice9ExImpl_GetGPUThreadPriority
,
1935 IDirect3DDevice9ExImpl_SetGPUThreadPriority
,
1936 IDirect3DDevice9ExImpl_WaitForVBlank
,
1937 IDirect3DDevice9ExImpl_CheckresourceResidency
,
1938 IDirect3DDevice9ExImpl_SetMaximumFrameLatency
,
1939 IDirect3DDevice9ExImpl_GetMaximumFrameLatency
,
1940 IDirect3DDevice9ExImpl_CheckdeviceState
,
1941 IDirect3DDevice9ExImpl_CreateRenderTargetEx
,
1942 IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx
,
1943 IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx
,
1944 IDirect3DDevice9ExImpl_ResetEx
,
1945 IDirect3DDevice9ExImpl_GetDisplayModeEx
1948 ULONG WINAPI
D3D9CB_DestroySurface(IWineD3DSurface
*pSurface
) {
1949 IDirect3DSurface9Impl
* surfaceParent
;
1950 TRACE("(%p) call back\n", pSurface
);
1952 IWineD3DSurface_GetParent(pSurface
, (IUnknown
**) &surfaceParent
);
1953 /* GetParent's AddRef was forwarded to an object in destruction.
1954 * Releasing it here again would cause an endless recursion. */
1955 surfaceParent
->forwardReference
= NULL
;
1956 return IDirect3DSurface9_Release((IDirect3DSurface9
*) surfaceParent
);
1959 /* IWineD3DDeviceParent IUnknown methods */
1961 static inline struct IDirect3DDevice9Impl
*device_from_device_parent(IWineD3DDeviceParent
*iface
)
1963 return (struct IDirect3DDevice9Impl
*)((char*)iface
1964 - FIELD_OFFSET(struct IDirect3DDevice9Impl
, device_parent_vtbl
));
1967 static HRESULT STDMETHODCALLTYPE
device_parent_QueryInterface(IWineD3DDeviceParent
*iface
, REFIID riid
, void **object
)
1969 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1970 return IDirect3DDevice9Impl_QueryInterface((IDirect3DDevice9Ex
*)This
, riid
, object
);
1973 static ULONG STDMETHODCALLTYPE
device_parent_AddRef(IWineD3DDeviceParent
*iface
)
1975 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1976 return IDirect3DDevice9Impl_AddRef((IDirect3DDevice9Ex
*)This
);
1979 static ULONG STDMETHODCALLTYPE
device_parent_Release(IWineD3DDeviceParent
*iface
)
1981 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1982 return IDirect3DDevice9Impl_Release((IDirect3DDevice9Ex
*)This
);
1985 /* IWineD3DDeviceParent methods */
1987 static void STDMETHODCALLTYPE
device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent
*iface
, IWineD3DDevice
*device
)
1989 TRACE("iface %p, device %p\n", iface
, device
);
1992 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSurface(IWineD3DDeviceParent
*iface
,
1993 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, DWORD usage
,
1994 WINED3DPOOL pool
, UINT level
, WINED3DCUBEMAP_FACES face
, IWineD3DSurface
**surface
)
1996 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1997 IDirect3DSurface9Impl
*d3d_surface
;
1998 BOOL lockable
= TRUE
;
2001 TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
2002 "\tpool %#x, level %u, face %u, surface %p\n",
2003 iface
, superior
, width
, height
, format
, usage
, pool
, level
, face
, surface
);
2005 if (pool
== WINED3DPOOL_DEFAULT
&& !(usage
& D3DUSAGE_DYNAMIC
))
2008 hr
= IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex
*)This
, width
, height
,
2009 d3dformat_from_wined3dformat(format
), lockable
, FALSE
/* Discard */, level
,
2010 (IDirect3DSurface9
**)&d3d_surface
, usage
, pool
, D3DMULTISAMPLE_NONE
, 0 /* MultisampleQuality */);
2013 ERR("(%p) CreateSurface failed, returning %#x\n", iface
, hr
);
2017 *surface
= d3d_surface
->wineD3DSurface
;
2018 d3d_surface
->container
= superior
;
2019 IDirect3DDevice9Ex_Release(d3d_surface
->parentDevice
);
2020 d3d_surface
->parentDevice
= NULL
;
2021 d3d_surface
->forwardReference
= superior
;
2026 static HRESULT STDMETHODCALLTYPE
device_parent_CreateRenderTarget(IWineD3DDeviceParent
*iface
,
2027 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
2028 DWORD multisample_quality
, BOOL lockable
, IWineD3DSurface
**surface
)
2030 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2031 IDirect3DSurface9Impl
*d3d_surface
;
2034 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2035 "\tmultisample_quality %u, lockable %u, surface %p\n",
2036 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, lockable
, surface
);
2038 hr
= IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex
*)This
, width
, height
,
2039 d3dformat_from_wined3dformat(format
), multisample_type
, multisample_quality
, lockable
,
2040 (IDirect3DSurface9
**)&d3d_surface
, NULL
);
2043 ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface
, hr
);
2047 *surface
= d3d_surface
->wineD3DSurface
;
2048 d3d_surface
->container
= superior
;
2049 d3d_surface
->isImplicit
= TRUE
;
2050 /* Implicit surfaces are created with an refcount of 0 */
2051 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2056 static HRESULT STDMETHODCALLTYPE
device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent
*iface
,
2057 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
2058 DWORD multisample_quality
, BOOL discard
, IWineD3DSurface
**surface
)
2060 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2061 IDirect3DSurface9Impl
*d3d_surface
;
2064 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2065 "\tmultisample_quality %u, discard %u, surface %p\n",
2066 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, discard
, surface
);
2068 hr
= IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex
*)This
, width
, height
,
2069 d3dformat_from_wined3dformat(format
), multisample_type
, multisample_quality
, discard
,
2070 (IDirect3DSurface9
**)&d3d_surface
, NULL
);
2073 ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface
, hr
);
2077 *surface
= d3d_surface
->wineD3DSurface
;
2078 d3d_surface
->container
= (IUnknown
*)This
;
2079 d3d_surface
->isImplicit
= TRUE
;
2080 /* Implicit surfaces are created with an refcount of 0 */
2081 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2086 static HRESULT STDMETHODCALLTYPE
device_parent_CreateVolume(IWineD3DDeviceParent
*iface
,
2087 IUnknown
*superior
, UINT width
, UINT height
, UINT depth
, WINED3DFORMAT format
,
2088 WINED3DPOOL pool
, DWORD usage
, IWineD3DVolume
**volume
)
2090 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2091 IDirect3DVolume9Impl
*object
;
2094 TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
2095 iface
, superior
, width
, height
, depth
, format
, pool
, usage
, volume
);
2097 /* Allocate the storage for the device */
2098 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2101 FIXME("Allocation of memory failed\n");
2103 return D3DERR_OUTOFVIDEOMEMORY
;
2106 object
->lpVtbl
= &Direct3DVolume9_Vtbl
;
2108 hr
= IWineD3DDevice_CreateVolume(This
->WineD3DDevice
, width
, height
, depth
, usage
& WINED3DUSAGE_MASK
,
2109 format
, pool
, &object
->wineD3DVolume
, (IUnknown
*)object
);
2112 ERR("(%p) CreateVolume failed, returning %#x\n", iface
, hr
);
2113 HeapFree(GetProcessHeap(), 0, object
);
2118 *volume
= object
->wineD3DVolume
;
2119 object
->container
= superior
;
2120 object
->forwardReference
= superior
;
2122 TRACE("(%p) Created volume %p\n", iface
, *volume
);
2127 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSwapChain(IWineD3DDeviceParent
*iface
,
2128 WINED3DPRESENT_PARAMETERS
*present_parameters
, IWineD3DSwapChain
**swapchain
)
2130 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2131 IDirect3DSwapChain9Impl
*d3d_swapchain
;
2132 D3DPRESENT_PARAMETERS local_parameters
;
2135 TRACE("iface %p, present_parameters %p, swapchain %p\n", iface
, present_parameters
, swapchain
);
2137 /* Copy the presentation parameters */
2138 local_parameters
.BackBufferWidth
= present_parameters
->BackBufferWidth
;
2139 local_parameters
.BackBufferHeight
= present_parameters
->BackBufferHeight
;
2140 local_parameters
.BackBufferFormat
= d3dformat_from_wined3dformat(present_parameters
->BackBufferFormat
);
2141 local_parameters
.BackBufferCount
= present_parameters
->BackBufferCount
;
2142 local_parameters
.MultiSampleType
= present_parameters
->MultiSampleType
;
2143 local_parameters
.MultiSampleQuality
= present_parameters
->MultiSampleQuality
;
2144 local_parameters
.SwapEffect
= present_parameters
->SwapEffect
;
2145 local_parameters
.hDeviceWindow
= present_parameters
->hDeviceWindow
;
2146 local_parameters
.Windowed
= present_parameters
->Windowed
;
2147 local_parameters
.EnableAutoDepthStencil
= present_parameters
->EnableAutoDepthStencil
;
2148 local_parameters
.AutoDepthStencilFormat
= d3dformat_from_wined3dformat(present_parameters
->AutoDepthStencilFormat
);
2149 local_parameters
.Flags
= present_parameters
->Flags
;
2150 local_parameters
.FullScreen_RefreshRateInHz
= present_parameters
->FullScreen_RefreshRateInHz
;
2151 local_parameters
.PresentationInterval
= present_parameters
->PresentationInterval
;
2153 hr
= IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex
*)This
,
2154 &local_parameters
, (IDirect3DSwapChain9
**)&d3d_swapchain
);
2157 ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface
, hr
);
2162 *swapchain
= d3d_swapchain
->wineD3DSwapChain
;
2163 d3d_swapchain
->isImplicit
= TRUE
;
2164 /* Implicit swap chains are created with an refcount of 0 */
2165 IDirect3DSwapChain9_Release((IDirect3DSwapChain9
*)d3d_swapchain
);
2167 /* Copy back the presentation parameters */
2168 present_parameters
->BackBufferWidth
= local_parameters
.BackBufferWidth
;
2169 present_parameters
->BackBufferHeight
= local_parameters
.BackBufferHeight
;
2170 present_parameters
->BackBufferFormat
= wined3dformat_from_d3dformat(local_parameters
.BackBufferFormat
);
2171 present_parameters
->BackBufferCount
= local_parameters
.BackBufferCount
;
2172 present_parameters
->MultiSampleType
= local_parameters
.MultiSampleType
;
2173 present_parameters
->MultiSampleQuality
= local_parameters
.MultiSampleQuality
;
2174 present_parameters
->SwapEffect
= local_parameters
.SwapEffect
;
2175 present_parameters
->hDeviceWindow
= local_parameters
.hDeviceWindow
;
2176 present_parameters
->Windowed
= local_parameters
.Windowed
;
2177 present_parameters
->EnableAutoDepthStencil
= local_parameters
.EnableAutoDepthStencil
;
2178 present_parameters
->AutoDepthStencilFormat
= wined3dformat_from_d3dformat(local_parameters
.AutoDepthStencilFormat
);
2179 present_parameters
->Flags
= local_parameters
.Flags
;
2180 present_parameters
->FullScreen_RefreshRateInHz
= local_parameters
.FullScreen_RefreshRateInHz
;
2181 present_parameters
->PresentationInterval
= local_parameters
.PresentationInterval
;
2186 const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl
=
2188 /* IUnknown methods */
2189 device_parent_QueryInterface
,
2190 device_parent_AddRef
,
2191 device_parent_Release
,
2192 /* IWineD3DDeviceParent methods */
2193 device_parent_WineD3DDeviceCreated
,
2194 device_parent_CreateSurface
,
2195 device_parent_CreateRenderTarget
,
2196 device_parent_CreateDepthStencilSurface
,
2197 device_parent_CreateVolume
,
2198 device_parent_CreateSwapChain
,