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 volume_desc
.Format
= &dummy_format
;
458 volume_desc
.Type
= &type
;
459 volume_desc
.Usage
= &dummy_dword
;
460 volume_desc
.Pool
= &pool
;
461 volume_desc
.Size
= &dummy_dword
;
462 volume_desc
.Width
= &dummy_dword
;
463 volume_desc
.Height
= &dummy_dword
;
464 volume_desc
.Depth
= &dummy_dword
;
465 IWineD3DVolume_GetDesc((IWineD3DVolume
*) resource
, &volume_desc
);
468 case D3DRTYPE_INDEXBUFFER
:
469 IDirect3DIndexBuffer9_GetDesc((IDirect3DIndexBuffer9
*) parent
, &index_desc
);
470 pool
= index_desc
.Pool
;
473 case D3DRTYPE_VERTEXBUFFER
:
474 IDirect3DVertexBuffer9_GetDesc((IDirect3DVertexBuffer9
*)parent
, &vertex_desc
);
475 pool
= vertex_desc
.Pool
;
478 /* No need to check for textures. If there is a D3DPOOL_DEFAULT texture, there
479 * is a D3DPOOL_DEFAULT surface or volume as well
485 if(pool
== WINED3DPOOL_DEFAULT
) {
486 if(IUnknown_Release(parent
) == 0) {
487 TRACE("Parent %p is an implicit resource with ref 0\n", parent
);
489 WARN("Resource %p(wineD3D %p) with pool D3DPOOL_DEFAULT blocks the Reset call\n", parent
, resource
);
491 *resources_ok
= FALSE
;
494 IUnknown_Release(parent
);
496 IWineD3DResource_Release(resource
);
501 static HRESULT WINAPI
IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface
, D3DPRESENT_PARAMETERS
* pPresentationParameters
) {
502 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
503 WINED3DPRESENT_PARAMETERS localParameters
;
505 BOOL resources_ok
= TRUE
;
508 TRACE("(%p) Relay pPresentationParameters(%p)\n", This
, pPresentationParameters
);
510 /* Reset states that hold a COM object. WineD3D holds an internal reference to set objects, because
511 * such objects can still be used for rendering after their external d3d9 object has been destroyed.
512 * These objects must not be enumerated. Unsetting them tells WineD3D that the application will not
513 * make use of the hidden reference and destroys the objects.
515 * Unsetting them is no problem, because the states are supposed to be reset anyway. If the validation
516 * below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
518 EnterCriticalSection(&d3d9_cs
);
519 IWineD3DDevice_SetIndices(This
->WineD3DDevice
, NULL
, WINED3DFMT_UNKNOWN
);
520 for(i
= 0; i
< 16; i
++) {
521 IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, i
, NULL
, 0, 0);
523 for(i
= 0; i
< 16; i
++) {
524 IWineD3DDevice_SetTexture(This
->WineD3DDevice
, i
, NULL
);
527 IWineD3DDevice_EnumResources(This
->WineD3DDevice
, reset_enum_callback
, &resources_ok
);
529 WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
530 This
->notreset
= TRUE
;
531 LeaveCriticalSection(&d3d9_cs
);
532 return WINED3DERR_INVALIDCALL
;
535 localParameters
.BackBufferWidth
= pPresentationParameters
->BackBufferWidth
;
536 localParameters
.BackBufferHeight
= pPresentationParameters
->BackBufferHeight
;
537 localParameters
.BackBufferFormat
= wined3dformat_from_d3dformat(pPresentationParameters
->BackBufferFormat
);
538 localParameters
.BackBufferCount
= pPresentationParameters
->BackBufferCount
;
539 localParameters
.MultiSampleType
= pPresentationParameters
->MultiSampleType
;
540 localParameters
.MultiSampleQuality
= pPresentationParameters
->MultiSampleQuality
;
541 localParameters
.SwapEffect
= pPresentationParameters
->SwapEffect
;
542 localParameters
.hDeviceWindow
= pPresentationParameters
->hDeviceWindow
;
543 localParameters
.Windowed
= pPresentationParameters
->Windowed
;
544 localParameters
.EnableAutoDepthStencil
= pPresentationParameters
->EnableAutoDepthStencil
;
545 localParameters
.AutoDepthStencilFormat
= wined3dformat_from_d3dformat(pPresentationParameters
->AutoDepthStencilFormat
);
546 localParameters
.Flags
= pPresentationParameters
->Flags
;
547 localParameters
.FullScreen_RefreshRateInHz
= pPresentationParameters
->FullScreen_RefreshRateInHz
;
548 localParameters
.PresentationInterval
= pPresentationParameters
->PresentationInterval
;
549 localParameters
.AutoRestoreDisplayMode
= TRUE
;
551 hr
= IWineD3DDevice_Reset(This
->WineD3DDevice
, &localParameters
);
553 This
->notreset
= TRUE
;
555 pPresentationParameters
->BackBufferWidth
= localParameters
.BackBufferWidth
;
556 pPresentationParameters
->BackBufferHeight
= localParameters
.BackBufferHeight
;
557 pPresentationParameters
->BackBufferFormat
= d3dformat_from_wined3dformat(localParameters
.BackBufferFormat
);
558 pPresentationParameters
->BackBufferCount
= localParameters
.BackBufferCount
;
559 pPresentationParameters
->MultiSampleType
= localParameters
.MultiSampleType
;
560 pPresentationParameters
->MultiSampleQuality
= localParameters
.MultiSampleQuality
;
561 pPresentationParameters
->SwapEffect
= localParameters
.SwapEffect
;
562 pPresentationParameters
->hDeviceWindow
= localParameters
.hDeviceWindow
;
563 pPresentationParameters
->Windowed
= localParameters
.Windowed
;
564 pPresentationParameters
->EnableAutoDepthStencil
= localParameters
.EnableAutoDepthStencil
;
565 pPresentationParameters
->AutoDepthStencilFormat
= d3dformat_from_wined3dformat(localParameters
.AutoDepthStencilFormat
);
566 pPresentationParameters
->Flags
= localParameters
.Flags
;
567 pPresentationParameters
->FullScreen_RefreshRateInHz
= localParameters
.FullScreen_RefreshRateInHz
;
568 pPresentationParameters
->PresentationInterval
= localParameters
.PresentationInterval
;
570 This
->notreset
= FALSE
;
573 LeaveCriticalSection(&d3d9_cs
);
578 static HRESULT WINAPI
IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface
, CONST RECT
* pSourceRect
,CONST RECT
* pDestRect
,HWND hDestWindowOverride
,CONST RGNDATA
*
580 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
582 TRACE("(%p) Relay\n", This
);
584 EnterCriticalSection(&d3d9_cs
);
585 hr
= IWineD3DDevice_Present(This
->WineD3DDevice
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
);
586 LeaveCriticalSection(&d3d9_cs
);
590 static HRESULT WINAPI
IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, UINT BackBuffer
, D3DBACKBUFFER_TYPE Type
, IDirect3DSurface9
** ppBackBuffer
) {
591 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
592 IWineD3DSurface
*retSurface
= NULL
;
595 TRACE("(%p) Relay\n", This
);
597 EnterCriticalSection(&d3d9_cs
);
598 rc
= IWineD3DDevice_GetBackBuffer(This
->WineD3DDevice
, iSwapChain
, BackBuffer
, (WINED3DBACKBUFFER_TYPE
) Type
, &retSurface
);
599 if (rc
== D3D_OK
&& NULL
!= retSurface
&& NULL
!= ppBackBuffer
) {
600 IWineD3DSurface_GetParent(retSurface
, (IUnknown
**)ppBackBuffer
);
601 IWineD3DSurface_Release(retSurface
);
603 LeaveCriticalSection(&d3d9_cs
);
606 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DRASTER_STATUS
* pRasterStatus
) {
607 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
609 TRACE("(%p) Relay\n", This
);
611 EnterCriticalSection(&d3d9_cs
);
612 hr
= IWineD3DDevice_GetRasterStatus(This
->WineD3DDevice
, iSwapChain
, (WINED3DRASTER_STATUS
*) pRasterStatus
);
613 LeaveCriticalSection(&d3d9_cs
);
617 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9EX iface
, BOOL bEnableDialogs
) {
618 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
620 TRACE("(%p) Relay\n", This
);
622 EnterCriticalSection(&d3d9_cs
);
623 hr
= IWineD3DDevice_SetDialogBoxMode(This
->WineD3DDevice
, bEnableDialogs
);
624 LeaveCriticalSection(&d3d9_cs
);
628 static void WINAPI
IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, DWORD Flags
, CONST D3DGAMMARAMP
* pRamp
) {
630 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
631 TRACE("(%p) Relay\n", This
);
633 EnterCriticalSection(&d3d9_cs
);
634 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
635 IWineD3DDevice_SetGammaRamp(This
->WineD3DDevice
, iSwapChain
, Flags
, (CONST WINED3DGAMMARAMP
*)pRamp
);
636 LeaveCriticalSection(&d3d9_cs
);
639 static void WINAPI
IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DGAMMARAMP
* pRamp
) {
640 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
641 TRACE("(%p) Relay\n", This
);
643 EnterCriticalSection(&d3d9_cs
);
644 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
645 IWineD3DDevice_GetGammaRamp(This
->WineD3DDevice
, iSwapChain
, (WINED3DGAMMARAMP
*) pRamp
);
646 LeaveCriticalSection(&d3d9_cs
);
650 static HRESULT
IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, BOOL Lockable
, BOOL Discard
, UINT Level
, IDirect3DSurface9
**ppSurface
,D3DRESOURCETYPE Type
, UINT Usage
, D3DPOOL Pool
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultisampleQuality
,HANDLE
* pSharedHandle
) {
652 IDirect3DSurface9Impl
*object
;
653 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
654 TRACE("(%p) Relay\n", This
);
656 if(MultisampleQuality
> 0){
657 FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality
);
660 [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.
663 MultisampleQuality
=0;
665 /*FIXME: Check MAX bounds of MultisampleQuality*/
667 /* Allocate the storage for the device */
668 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DSurface9Impl
));
669 if (NULL
== object
) {
670 FIXME("Allocation of memory failed\n");
671 return D3DERR_OUTOFVIDEOMEMORY
;
674 object
->lpVtbl
= &Direct3DSurface9_Vtbl
;
677 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This
, Width
, Height
, Format
, *ppSurface
);
679 EnterCriticalSection(&d3d9_cs
);
680 hrc
= IWineD3DDevice_CreateSurface(This
->WineD3DDevice
, Width
, Height
, wined3dformat_from_d3dformat(Format
),
681 Lockable
, Discard
, Level
, &object
->wineD3DSurface
, Type
, Usage
& WINED3DUSAGE_MASK
,
682 (WINED3DPOOL
)Pool
, MultiSample
, MultisampleQuality
, SURFACE_OPENGL
, (IUnknown
*)object
);
683 LeaveCriticalSection(&d3d9_cs
);
685 if (hrc
!= D3D_OK
|| NULL
== object
->wineD3DSurface
) {
688 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This
);
689 HeapFree(GetProcessHeap(), 0, object
);
691 IDirect3DDevice9Ex_AddRef(iface
);
692 object
->parentDevice
= iface
;
693 TRACE("(%p) : Created surface %p\n", This
, object
);
694 *ppSurface
= (LPDIRECT3DSURFACE9
) object
;
701 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
702 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
703 DWORD MultisampleQuality
, BOOL Lockable
,
704 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
708 hr
= IDirect3DDevice9Impl_CreateSurface(iface
,Width
,Height
,Format
,Lockable
,FALSE
/*Discard*/, 0/*Level*/, ppSurface
,D3DRTYPE_SURFACE
,D3DUSAGE_RENDERTARGET
,D3DPOOL_DEFAULT
,MultiSample
,MultisampleQuality
,pSharedHandle
);
712 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
713 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
714 DWORD MultisampleQuality
, BOOL Discard
,
715 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
719 hr
= IDirect3DDevice9Impl_CreateSurface(iface
,Width
,Height
,Format
,TRUE
/* Lockable */,Discard
, 0/* Level */
720 ,ppSurface
,D3DRTYPE_SURFACE
,D3DUSAGE_DEPTHSTENCIL
,
721 D3DPOOL_DEFAULT
,MultiSample
,MultisampleQuality
,pSharedHandle
);
726 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestinationSurface
, CONST POINT
* pDestPoint
) {
727 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
729 TRACE("(%p) Relay\n" , This
);
731 EnterCriticalSection(&d3d9_cs
);
732 hr
= IWineD3DDevice_UpdateSurface(This
->WineD3DDevice
, ((IDirect3DSurface9Impl
*)pSourceSurface
)->wineD3DSurface
, pSourceRect
, ((IDirect3DSurface9Impl
*)pDestinationSurface
)->wineD3DSurface
, pDestPoint
);
733 LeaveCriticalSection(&d3d9_cs
);
737 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9EX iface
, IDirect3DBaseTexture9
* pSourceTexture
, IDirect3DBaseTexture9
* pDestinationTexture
) {
738 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
740 TRACE("(%p) Relay\n" , This
);
742 EnterCriticalSection(&d3d9_cs
);
743 hr
= IWineD3DDevice_UpdateTexture(This
->WineD3DDevice
, ((IDirect3DBaseTexture9Impl
*)pSourceTexture
)->wineD3DBaseTexture
, ((IDirect3DBaseTexture9Impl
*)pDestinationTexture
)->wineD3DBaseTexture
);
744 LeaveCriticalSection(&d3d9_cs
);
748 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pRenderTarget
, IDirect3DSurface9
* pDestSurface
) {
749 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
750 IDirect3DSurface9Impl
*renderTarget
= (IDirect3DSurface9Impl
*)pRenderTarget
;
751 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
753 TRACE("(%p)->(%p,%p)\n" , This
, renderTarget
, destSurface
);
755 EnterCriticalSection(&d3d9_cs
);
756 hr
= IWineD3DSurface_BltFast(destSurface
->wineD3DSurface
, 0, 0, renderTarget
->wineD3DSurface
, NULL
, WINEDDBLTFAST_NOCOLORKEY
);
757 LeaveCriticalSection(&d3d9_cs
);
761 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, IDirect3DSurface9
* pDestSurface
) {
762 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
763 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
765 TRACE("(%p) Relay\n" , This
);
767 EnterCriticalSection(&d3d9_cs
);
768 hr
= IWineD3DDevice_GetFrontBufferData(This
->WineD3DDevice
, iSwapChain
, destSurface
->wineD3DSurface
);
769 LeaveCriticalSection(&d3d9_cs
);
773 static HRESULT WINAPI
IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestSurface
, CONST RECT
* pDestRect
, D3DTEXTUREFILTERTYPE Filter
) {
774 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
775 IDirect3DSurface9Impl
*src
= (IDirect3DSurface9Impl
*) pSourceSurface
;
776 IDirect3DSurface9Impl
*dst
= (IDirect3DSurface9Impl
*) pDestSurface
;
779 TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This
, src
, pSourceRect
, dst
, pDestRect
, Filter
);
780 EnterCriticalSection(&d3d9_cs
);
781 hr
= IWineD3DSurface_Blt(dst
->wineD3DSurface
, pDestRect
, src
->wineD3DSurface
, pSourceRect
, 0, NULL
, Filter
);
782 LeaveCriticalSection(&d3d9_cs
);
786 static HRESULT WINAPI
IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSurface
, CONST RECT
* pRect
, D3DCOLOR color
) {
787 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
788 IDirect3DSurface9Impl
*surface
= (IDirect3DSurface9Impl
*)pSurface
;
790 WINED3DRESOURCETYPE restype
;
792 WINED3DSURFACE_DESC desc
;
794 TRACE("(%p) Relay\n" , This
);
796 memset(&desc
, 0, sizeof(desc
));
799 desc
.Type
= &restype
;
801 EnterCriticalSection(&d3d9_cs
);
802 IWineD3DSurface_GetDesc(surface
->wineD3DSurface
, &desc
);
804 /* This method is only allowed with surfaces that are render targets, or offscreen plain surfaces
807 if(!(usage
& WINED3DUSAGE_RENDERTARGET
) && (pool
!= D3DPOOL_DEFAULT
|| restype
!= D3DRTYPE_SURFACE
)) {
808 LeaveCriticalSection(&d3d9_cs
);
809 WARN("Surface is not a render target, or not a stand-alone D3DPOOL_DEFAULT surface\n");
810 return D3DERR_INVALIDCALL
;
813 /* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
814 /* Note: D3DRECT is compatible with WINED3DRECT */
815 hr
= IWineD3DDevice_ColorFill(This
->WineD3DDevice
, surface
->wineD3DSurface
, (CONST WINED3DRECT
*)pRect
, color
);
816 LeaveCriticalSection(&d3d9_cs
);
820 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
823 if(Pool
== D3DPOOL_MANAGED
){
824 FIXME("Attempting to create a managed offscreen plain surface\n");
825 return D3DERR_INVALIDCALL
;
828 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
830 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
831 Why, their always lockable?
832 should I change the usage to dynamic?
834 hr
= IDirect3DDevice9Impl_CreateSurface(iface
,Width
,Height
,Format
,TRUE
/*Loackable*/,FALSE
/*Discard*/,0/*Level*/ , ppSurface
,D3DRTYPE_SURFACE
, 0/*Usage (undefined/none)*/,(WINED3DPOOL
) Pool
,D3DMULTISAMPLE_NONE
,0/*MultisampleQuality*/,pSharedHandle
);
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
;
855 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
);
866 if (hr
== D3D_OK
&& pRenderTarget
!= NULL
) {
867 IWineD3DSurface_GetParent(pRenderTarget
,(IUnknown
**)ppRenderTarget
);
868 IWineD3DSurface_Release(pRenderTarget
);
870 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
871 *ppRenderTarget
= NULL
;
873 LeaveCriticalSection(&d3d9_cs
);
878 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pZStencilSurface
) {
879 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
880 IDirect3DSurface9Impl
*pSurface
;
882 TRACE("(%p) Relay\n" , This
);
884 pSurface
= (IDirect3DSurface9Impl
*)pZStencilSurface
;
885 EnterCriticalSection(&d3d9_cs
);
886 hr
= IWineD3DDevice_SetDepthStencilSurface(This
->WineD3DDevice
, NULL
==pSurface
? NULL
: pSurface
->wineD3DSurface
);
887 LeaveCriticalSection(&d3d9_cs
);
891 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
**ppZStencilSurface
) {
892 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
894 IWineD3DSurface
*pZStencilSurface
;
896 TRACE("(%p) Relay\n" , This
);
897 if(ppZStencilSurface
== NULL
){
898 return D3DERR_INVALIDCALL
;
901 EnterCriticalSection(&d3d9_cs
);
902 hr
= IWineD3DDevice_GetDepthStencilSurface(This
->WineD3DDevice
,&pZStencilSurface
);
903 if (hr
== WINED3D_OK
) {
904 IWineD3DSurface_GetParent(pZStencilSurface
,(IUnknown
**)ppZStencilSurface
);
905 IWineD3DSurface_Release(pZStencilSurface
);
907 if (hr
!= WINED3DERR_NOTFOUND
)
908 WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr
);
909 *ppZStencilSurface
= NULL
;
911 LeaveCriticalSection(&d3d9_cs
);
915 static HRESULT WINAPI
IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX iface
) {
916 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
918 TRACE("(%p) Relay\n" , This
);
920 EnterCriticalSection(&d3d9_cs
);
921 hr
= IWineD3DDevice_BeginScene(This
->WineD3DDevice
);
922 LeaveCriticalSection(&d3d9_cs
);
926 static HRESULT WINAPI
IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface
) {
927 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
929 TRACE("(%p) Relay\n" , This
);
931 EnterCriticalSection(&d3d9_cs
);
932 hr
= IWineD3DDevice_EndScene(This
->WineD3DDevice
);
933 LeaveCriticalSection(&d3d9_cs
);
937 static HRESULT WINAPI
IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9EX iface
, DWORD Count
, CONST D3DRECT
* pRects
, DWORD Flags
, D3DCOLOR Color
, float Z
, DWORD Stencil
) {
938 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
940 TRACE("(%p) Relay\n" , This
);
942 /* Note: D3DRECT is compatible with WINED3DRECT */
943 EnterCriticalSection(&d3d9_cs
);
944 hr
= IWineD3DDevice_Clear(This
->WineD3DDevice
, Count
, (CONST WINED3DRECT
*) pRects
, Flags
, Color
, Z
, Stencil
);
945 LeaveCriticalSection(&d3d9_cs
);
949 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* lpMatrix
) {
950 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
952 TRACE("(%p) Relay\n" , This
);
954 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
955 EnterCriticalSection(&d3d9_cs
);
956 hr
= IWineD3DDevice_SetTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) lpMatrix
);
957 LeaveCriticalSection(&d3d9_cs
);
961 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, D3DMATRIX
* pMatrix
) {
962 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
965 TRACE("(%p) Relay\n" , This
);
967 EnterCriticalSection(&d3d9_cs
);
968 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
969 hr
= IWineD3DDevice_GetTransform(This
->WineD3DDevice
, State
, (WINED3DMATRIX
*) pMatrix
);
970 LeaveCriticalSection(&d3d9_cs
);
975 static HRESULT WINAPI
IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* pMatrix
) {
976 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
978 TRACE("(%p) Relay\n" , This
);
980 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
981 EnterCriticalSection(&d3d9_cs
);
982 hr
= IWineD3DDevice_MultiplyTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) pMatrix
);
983 LeaveCriticalSection(&d3d9_cs
);
987 static HRESULT WINAPI
IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9EX iface
, CONST D3DVIEWPORT9
* pViewport
) {
988 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
990 TRACE("(%p) Relay\n" , This
);
992 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
993 EnterCriticalSection(&d3d9_cs
);
994 hr
= IWineD3DDevice_SetViewport(This
->WineD3DDevice
, (const WINED3DVIEWPORT
*)pViewport
);
995 LeaveCriticalSection(&d3d9_cs
);
999 static HRESULT WINAPI
IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9EX iface
, D3DVIEWPORT9
* pViewport
) {
1000 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1002 TRACE("(%p) Relay\n" , This
);
1004 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
1005 EnterCriticalSection(&d3d9_cs
);
1006 hr
= IWineD3DDevice_GetViewport(This
->WineD3DDevice
, (WINED3DVIEWPORT
*)pViewport
);
1007 LeaveCriticalSection(&d3d9_cs
);
1011 static HRESULT WINAPI
IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9EX iface
, CONST D3DMATERIAL9
* pMaterial
) {
1012 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1014 TRACE("(%p) Relay\n" , This
);
1016 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
1017 EnterCriticalSection(&d3d9_cs
);
1018 hr
= IWineD3DDevice_SetMaterial(This
->WineD3DDevice
, (const WINED3DMATERIAL
*)pMaterial
);
1019 LeaveCriticalSection(&d3d9_cs
);
1023 static HRESULT WINAPI
IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9EX iface
, D3DMATERIAL9
* pMaterial
) {
1024 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1026 TRACE("(%p) Relay\n" , This
);
1028 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
1029 EnterCriticalSection(&d3d9_cs
);
1030 hr
= IWineD3DDevice_GetMaterial(This
->WineD3DDevice
, (WINED3DMATERIAL
*)pMaterial
);
1031 LeaveCriticalSection(&d3d9_cs
);
1035 static HRESULT WINAPI
IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST D3DLIGHT9
* pLight
) {
1036 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1038 TRACE("(%p) Relay\n" , This
);
1040 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
1041 EnterCriticalSection(&d3d9_cs
);
1042 hr
= IWineD3DDevice_SetLight(This
->WineD3DDevice
, Index
, (const WINED3DLIGHT
*)pLight
);
1043 LeaveCriticalSection(&d3d9_cs
);
1047 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, D3DLIGHT9
* pLight
) {
1048 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1050 TRACE("(%p) Relay\n" , This
);
1052 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
1053 EnterCriticalSection(&d3d9_cs
);
1054 hr
= IWineD3DDevice_GetLight(This
->WineD3DDevice
, Index
, (WINED3DLIGHT
*)pLight
);
1055 LeaveCriticalSection(&d3d9_cs
);
1059 static HRESULT WINAPI
IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL Enable
) {
1060 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1062 TRACE("(%p) Relay\n" , This
);
1064 EnterCriticalSection(&d3d9_cs
);
1065 hr
= IWineD3DDevice_SetLightEnable(This
->WineD3DDevice
, Index
, Enable
);
1066 LeaveCriticalSection(&d3d9_cs
);
1070 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL
* pEnable
) {
1071 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1073 TRACE("(%p) Relay\n" , This
);
1075 EnterCriticalSection(&d3d9_cs
);
1076 hr
= IWineD3DDevice_GetLightEnable(This
->WineD3DDevice
, Index
, pEnable
);
1077 LeaveCriticalSection(&d3d9_cs
);
1081 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST
float* pPlane
) {
1082 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1084 TRACE("(%p) Relay\n" , This
);
1086 EnterCriticalSection(&d3d9_cs
);
1087 hr
= IWineD3DDevice_SetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
1088 LeaveCriticalSection(&d3d9_cs
);
1092 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, float* pPlane
) {
1093 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1095 TRACE("(%p) Relay\n" , This
);
1097 EnterCriticalSection(&d3d9_cs
);
1098 hr
= IWineD3DDevice_GetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
1099 LeaveCriticalSection(&d3d9_cs
);
1103 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD Value
) {
1104 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1106 TRACE("(%p) Relay\n" , This
);
1108 EnterCriticalSection(&d3d9_cs
);
1109 hr
= IWineD3DDevice_SetRenderState(This
->WineD3DDevice
, State
, Value
);
1110 LeaveCriticalSection(&d3d9_cs
);
1114 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD
* pValue
) {
1115 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1117 TRACE("(%p) Relay\n" , This
);
1119 EnterCriticalSection(&d3d9_cs
);
1120 hr
= IWineD3DDevice_GetRenderState(This
->WineD3DDevice
, State
, pValue
);
1121 LeaveCriticalSection(&d3d9_cs
);
1125 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX iface
, CONST D3DCLIPSTATUS9
* pClipStatus
) {
1126 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1128 TRACE("(%p) Relay\n" , This
);
1130 EnterCriticalSection(&d3d9_cs
);
1131 hr
= IWineD3DDevice_SetClipStatus(This
->WineD3DDevice
, (const WINED3DCLIPSTATUS
*)pClipStatus
);
1132 LeaveCriticalSection(&d3d9_cs
);
1136 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9EX iface
, D3DCLIPSTATUS9
* pClipStatus
) {
1137 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1139 TRACE("(%p) Relay\n" , This
);
1141 EnterCriticalSection(&d3d9_cs
);
1142 hr
= IWineD3DDevice_GetClipStatus(This
->WineD3DDevice
, (WINED3DCLIPSTATUS
*)pClipStatus
);
1143 LeaveCriticalSection(&d3d9_cs
);
1147 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
**ppTexture
) {
1148 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1149 IWineD3DBaseTexture
*retTexture
= NULL
;
1150 HRESULT rc
= D3D_OK
;
1152 TRACE("(%p) Relay\n" , This
);
1154 if(ppTexture
== NULL
){
1155 return D3DERR_INVALIDCALL
;
1158 EnterCriticalSection(&d3d9_cs
);
1159 rc
= IWineD3DDevice_GetTexture(This
->WineD3DDevice
, Stage
, &retTexture
);
1160 if (SUCCEEDED(rc
) && NULL
!= retTexture
) {
1161 IWineD3DBaseTexture_GetParent(retTexture
, (IUnknown
**)ppTexture
);
1162 IWineD3DBaseTexture_Release(retTexture
);
1165 WARN("Call to get texture (%d) failed (%p)\n", Stage
, retTexture
);
1169 LeaveCriticalSection(&d3d9_cs
);
1174 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
* pTexture
) {
1175 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1177 TRACE("(%p) Relay %d %p\n" , This
, Stage
, pTexture
);
1179 EnterCriticalSection(&d3d9_cs
);
1180 hr
= IWineD3DDevice_SetTexture(This
->WineD3DDevice
, Stage
,
1181 pTexture
==NULL
? NULL
:((IDirect3DBaseTexture9Impl
*)pTexture
)->wineD3DBaseTexture
);
1182 LeaveCriticalSection(&d3d9_cs
);
1186 static const WINED3DTEXTURESTAGESTATETYPE tss_lookup
[] =
1188 WINED3DTSS_FORCE_DWORD
, /* 0, unused */
1189 WINED3DTSS_COLOROP
, /* 1, D3DTSS_COLOROP */
1190 WINED3DTSS_COLORARG1
, /* 2, D3DTSS_COLORARG1 */
1191 WINED3DTSS_COLORARG2
, /* 3, D3DTSS_COLORARG2 */
1192 WINED3DTSS_ALPHAOP
, /* 4, D3DTSS_ALPHAOP */
1193 WINED3DTSS_ALPHAARG1
, /* 5, D3DTSS_ALPHAARG1 */
1194 WINED3DTSS_ALPHAARG2
, /* 6, D3DTSS_ALPHAARG2 */
1195 WINED3DTSS_BUMPENVMAT00
, /* 7, D3DTSS_BUMPENVMAT00 */
1196 WINED3DTSS_BUMPENVMAT01
, /* 8, D3DTSS_BUMPENVMAT01 */
1197 WINED3DTSS_BUMPENVMAT10
, /* 9, D3DTSS_BUMPENVMAT10 */
1198 WINED3DTSS_BUMPENVMAT11
, /* 10, D3DTSS_BUMPENVMAT11 */
1199 WINED3DTSS_TEXCOORDINDEX
, /* 11, D3DTSS_TEXCOORDINDEX */
1200 WINED3DTSS_FORCE_DWORD
, /* 12, unused */
1201 WINED3DTSS_FORCE_DWORD
, /* 13, unused */
1202 WINED3DTSS_FORCE_DWORD
, /* 14, unused */
1203 WINED3DTSS_FORCE_DWORD
, /* 15, unused */
1204 WINED3DTSS_FORCE_DWORD
, /* 16, unused */
1205 WINED3DTSS_FORCE_DWORD
, /* 17, unused */
1206 WINED3DTSS_FORCE_DWORD
, /* 18, unused */
1207 WINED3DTSS_FORCE_DWORD
, /* 19, unused */
1208 WINED3DTSS_FORCE_DWORD
, /* 20, unused */
1209 WINED3DTSS_FORCE_DWORD
, /* 21, unused */
1210 WINED3DTSS_BUMPENVLSCALE
, /* 22, D3DTSS_BUMPENVLSCALE */
1211 WINED3DTSS_BUMPENVLOFFSET
, /* 23, D3DTSS_BUMPENVLOFFSET */
1212 WINED3DTSS_TEXTURETRANSFORMFLAGS
, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
1213 WINED3DTSS_FORCE_DWORD
, /* 25, unused */
1214 WINED3DTSS_COLORARG0
, /* 26, D3DTSS_COLORARG0 */
1215 WINED3DTSS_ALPHAARG0
, /* 27, D3DTSS_ALPHAARG0 */
1216 WINED3DTSS_RESULTARG
, /* 28, D3DTSS_RESULTARG */
1217 WINED3DTSS_FORCE_DWORD
, /* 29, unused */
1218 WINED3DTSS_FORCE_DWORD
, /* 30, unused */
1219 WINED3DTSS_FORCE_DWORD
, /* 31, unused */
1220 WINED3DTSS_CONSTANT
, /* 32, D3DTSS_CONSTANT */
1223 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD
* pValue
) {
1224 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1226 TRACE("(%p) Relay\n" , This
);
1228 EnterCriticalSection(&d3d9_cs
);
1229 hr
= IWineD3DDevice_GetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], pValue
);
1230 LeaveCriticalSection(&d3d9_cs
);
1234 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD Value
) {
1235 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1237 TRACE("(%p) Relay\n" , This
);
1239 EnterCriticalSection(&d3d9_cs
);
1240 hr
= IWineD3DDevice_SetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], Value
);
1241 LeaveCriticalSection(&d3d9_cs
);
1245 static HRESULT WINAPI
IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9EX iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD
* pValue
) {
1246 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1248 TRACE("(%p) Relay\n" , This
);
1250 EnterCriticalSection(&d3d9_cs
);
1251 hr
= IWineD3DDevice_GetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, pValue
);
1252 LeaveCriticalSection(&d3d9_cs
);
1256 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD Value
) {
1257 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1259 TRACE("(%p) Relay\n" , This
);
1261 EnterCriticalSection(&d3d9_cs
);
1262 hr
= IWineD3DDevice_SetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, Value
);
1263 LeaveCriticalSection(&d3d9_cs
);
1267 static HRESULT WINAPI
IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9EX iface
, DWORD
* pNumPasses
) {
1268 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1270 TRACE("(%p) Relay\n" , This
);
1272 EnterCriticalSection(&d3d9_cs
);
1273 hr
= IWineD3DDevice_ValidateDevice(This
->WineD3DDevice
, pNumPasses
);
1274 LeaveCriticalSection(&d3d9_cs
);
1278 static HRESULT WINAPI
IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
, CONST PALETTEENTRY
* pEntries
) {
1279 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1281 TRACE("(%p) Relay\n" , This
);
1283 EnterCriticalSection(&d3d9_cs
);
1284 hr
= IWineD3DDevice_SetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1285 LeaveCriticalSection(&d3d9_cs
);
1289 static HRESULT WINAPI
IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
, PALETTEENTRY
* pEntries
) {
1290 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1292 TRACE("(%p) Relay\n" , This
);
1294 EnterCriticalSection(&d3d9_cs
);
1295 hr
= IWineD3DDevice_GetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1296 LeaveCriticalSection(&d3d9_cs
);
1300 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
) {
1301 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1303 TRACE("(%p) Relay\n" , This
);
1305 EnterCriticalSection(&d3d9_cs
);
1306 hr
= IWineD3DDevice_SetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1307 LeaveCriticalSection(&d3d9_cs
);
1311 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT
* PaletteNumber
) {
1312 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1314 TRACE("(%p) Relay\n" , This
);
1316 EnterCriticalSection(&d3d9_cs
);
1317 hr
= IWineD3DDevice_GetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1318 LeaveCriticalSection(&d3d9_cs
);
1322 static HRESULT WINAPI
IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9EX iface
, CONST RECT
* pRect
) {
1323 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1325 TRACE("(%p) Relay\n" , This
);
1327 EnterCriticalSection(&d3d9_cs
);
1328 hr
= IWineD3DDevice_SetScissorRect(This
->WineD3DDevice
, pRect
);
1329 LeaveCriticalSection(&d3d9_cs
);
1333 static HRESULT WINAPI
IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9EX iface
, RECT
* pRect
) {
1334 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1336 TRACE("(%p) Relay\n" , This
);
1338 EnterCriticalSection(&d3d9_cs
);
1339 hr
= IWineD3DDevice_GetScissorRect(This
->WineD3DDevice
, pRect
);
1340 LeaveCriticalSection(&d3d9_cs
);
1344 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
, BOOL bSoftware
) {
1345 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1347 TRACE("(%p) Relay\n" , This
);
1349 EnterCriticalSection(&d3d9_cs
);
1350 hr
= IWineD3DDevice_SetSoftwareVertexProcessing(This
->WineD3DDevice
, bSoftware
);
1351 LeaveCriticalSection(&d3d9_cs
);
1355 static BOOL WINAPI
IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
) {
1356 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1358 TRACE("(%p) Relay\n" , This
);
1360 EnterCriticalSection(&d3d9_cs
);
1361 ret
= IWineD3DDevice_GetSoftwareVertexProcessing(This
->WineD3DDevice
);
1362 LeaveCriticalSection(&d3d9_cs
);
1366 static HRESULT WINAPI
IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9EX iface
, float nSegments
) {
1367 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1369 TRACE("(%p) Relay\n" , This
);
1371 EnterCriticalSection(&d3d9_cs
);
1372 hr
= IWineD3DDevice_SetNPatchMode(This
->WineD3DDevice
, nSegments
);
1373 LeaveCriticalSection(&d3d9_cs
);
1377 static float WINAPI
IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9EX iface
) {
1378 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1380 TRACE("(%p) Relay\n" , This
);
1382 EnterCriticalSection(&d3d9_cs
);
1383 ret
= IWineD3DDevice_GetNPatchMode(This
->WineD3DDevice
);
1384 LeaveCriticalSection(&d3d9_cs
);
1388 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT StartVertex
, UINT PrimitiveCount
) {
1389 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1391 TRACE("(%p) Relay\n" , This
);
1393 EnterCriticalSection(&d3d9_cs
);
1394 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1395 hr
= IWineD3DDevice_DrawPrimitive(This
->WineD3DDevice
, StartVertex
,
1396 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
));
1397 LeaveCriticalSection(&d3d9_cs
);
1401 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
,
1402 INT BaseVertexIndex
, UINT MinVertexIndex
, UINT NumVertices
, UINT startIndex
, UINT primCount
) {
1403 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1405 TRACE("(%p) Relay\n" , This
);
1407 /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
1408 EnterCriticalSection(&d3d9_cs
);
1409 IWineD3DDevice_SetBaseVertexIndex(This
->WineD3DDevice
, BaseVertexIndex
);
1410 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1411 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->WineD3DDevice
, MinVertexIndex
, NumVertices
,
1412 startIndex
, vertex_count_from_primitive_count(PrimitiveType
, primCount
));
1413 LeaveCriticalSection(&d3d9_cs
);
1417 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT PrimitiveCount
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1418 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1420 TRACE("(%p) Relay\n" , This
);
1422 EnterCriticalSection(&d3d9_cs
);
1423 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1424 hr
= IWineD3DDevice_DrawPrimitiveUP(This
->WineD3DDevice
,
1425 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
),
1426 pVertexStreamZeroData
, VertexStreamZeroStride
);
1427 LeaveCriticalSection(&d3d9_cs
);
1431 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT MinVertexIndex
,
1432 UINT NumVertexIndices
, UINT PrimitiveCount
, CONST
void* pIndexData
,
1433 D3DFORMAT IndexDataFormat
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1434 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1436 TRACE("(%p) Relay\n" , This
);
1438 EnterCriticalSection(&d3d9_cs
);
1439 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1440 hr
= IWineD3DDevice_DrawIndexedPrimitiveUP(This
->WineD3DDevice
, MinVertexIndex
, NumVertexIndices
,
1441 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
), pIndexData
,
1442 wined3dformat_from_d3dformat(IndexDataFormat
), pVertexStreamZeroData
, VertexStreamZeroStride
);
1443 LeaveCriticalSection(&d3d9_cs
);
1447 static HRESULT WINAPI
IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX iface
, UINT SrcStartIndex
, UINT DestIndex
, UINT VertexCount
, IDirect3DVertexBuffer9
* pDestBuffer
, IDirect3DVertexDeclaration9
* pVertexDecl
, DWORD Flags
) {
1448 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1449 IDirect3DVertexDeclaration9Impl
*Decl
= (IDirect3DVertexDeclaration9Impl
*) pVertexDecl
;
1451 IDirect3DVertexBuffer9Impl
*dest
= (IDirect3DVertexBuffer9Impl
*) pDestBuffer
;
1452 TRACE("(%p) Relay\n" , This
);
1454 EnterCriticalSection(&d3d9_cs
);
1455 hr
= IWineD3DDevice_ProcessVertices(This
->WineD3DDevice
,SrcStartIndex
, DestIndex
, VertexCount
, dest
->wineD3DVertexBuffer
, Decl
? Decl
->wineD3DVertexDeclaration
: NULL
, Flags
, dest
->fvf
);
1456 LeaveCriticalSection(&d3d9_cs
);
1460 static IDirect3DVertexDeclaration9
*getConvertedDecl(IDirect3DDevice9Impl
*This
, DWORD fvf
) {
1462 D3DVERTEXELEMENT9
* elements
= NULL
;
1463 IDirect3DVertexDeclaration9
* pDecl
= NULL
;
1464 int p
, low
, high
; /* deliberately signed */
1465 IDirect3DVertexDeclaration9
**convertedDecls
= This
->convertedDecls
;
1467 TRACE("Searching for declaration for fvf %08x... ", fvf
);
1470 high
= This
->numConvertedDecls
- 1;
1471 while(low
<= high
) {
1472 p
= (low
+ high
) >> 1;
1474 if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
== fvf
) {
1475 TRACE("found %p\n", convertedDecls
[p
]);
1476 return convertedDecls
[p
];
1477 } else if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
< fvf
) {
1483 TRACE("not found. Creating and inserting at position %d.\n", low
);
1485 hr
= vdecl_convert_fvf(fvf
, &elements
);
1486 if (hr
!= S_OK
) return NULL
;
1488 hr
= IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9Ex
*) This
, elements
, &pDecl
);
1489 HeapFree(GetProcessHeap(), 0, elements
); /* CreateVertexDeclaration makes a copy */
1490 if (hr
!= S_OK
) return NULL
;
1492 if(This
->declArraySize
== This
->numConvertedDecls
) {
1493 int grow
= max(This
->declArraySize
/ 2, 8);
1494 convertedDecls
= HeapReAlloc(GetProcessHeap(), 0, convertedDecls
,
1495 sizeof(convertedDecls
[0]) * (This
->numConvertedDecls
+ grow
));
1496 if(!convertedDecls
) {
1497 /* This will destroy it */
1498 IDirect3DVertexDeclaration9_Release(pDecl
);
1501 This
->convertedDecls
= convertedDecls
;
1502 This
->declArraySize
+= grow
;
1505 memmove(convertedDecls
+ low
+ 1, convertedDecls
+ low
, sizeof(IDirect3DVertexDeclaration9Impl
*) * (This
->numConvertedDecls
- low
));
1506 convertedDecls
[low
] = pDecl
;
1507 This
->numConvertedDecls
++;
1509 /* Will prevent the decl from being destroyed */
1510 ((IDirect3DVertexDeclaration9Impl
*) pDecl
)->convFVF
= fvf
;
1511 IDirect3DVertexDeclaration9_Release(pDecl
); /* Does not destroy now */
1513 TRACE("Returning %p. %d decls in array\n", pDecl
, This
->numConvertedDecls
);
1517 static HRESULT WINAPI
IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface
, DWORD FVF
) {
1518 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1519 IDirect3DVertexDeclaration9
*decl
;
1522 TRACE("(%p) Relay\n" , This
);
1526 WARN("%#x is not a valid FVF\n", FVF
);
1530 EnterCriticalSection(&d3d9_cs
);
1531 decl
= getConvertedDecl(This
, FVF
);
1532 LeaveCriticalSection(&d3d9_cs
);
1536 /* Any situation when this should happen, except out of memory? */
1537 ERR("Failed to create a converted vertex declaration\n");
1538 return D3DERR_DRIVERINTERNALERROR
;
1541 hr
= IDirect3DDevice9Impl_SetVertexDeclaration(iface
, decl
);
1542 if (FAILED(hr
)) ERR("Failed to set vertex declaration\n");
1547 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface
, DWORD
* pFVF
) {
1548 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1549 IDirect3DVertexDeclaration9
*decl
;
1551 TRACE("(%p) Relay\n" , This
);
1553 hr
= IDirect3DDevice9_GetVertexDeclaration(iface
, &decl
);
1556 WARN("Failed to get vertex declaration, %#x\n", hr
);
1563 *pFVF
= ((IDirect3DVertexDeclaration9Impl
*)decl
)->convFVF
;
1564 IDirect3DVertexDeclaration9_Release(decl
);
1571 TRACE("Returning FVF %#x\n", *pFVF
);
1576 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
* pStreamData
, UINT OffsetInBytes
, UINT Stride
) {
1577 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1579 TRACE("(%p) Relay\n" , This
);
1581 EnterCriticalSection(&d3d9_cs
);
1582 hr
= IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, StreamNumber
,
1583 pStreamData
==NULL
? NULL
:((IDirect3DVertexBuffer9Impl
*)pStreamData
)->wineD3DVertexBuffer
,
1584 OffsetInBytes
, Stride
);
1585 LeaveCriticalSection(&d3d9_cs
);
1589 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
**pStream
, UINT
* OffsetInBytes
, UINT
* pStride
) {
1590 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1591 IWineD3DBuffer
*retStream
= NULL
;
1592 HRESULT rc
= D3D_OK
;
1594 TRACE("(%p) Relay\n" , This
);
1596 if(pStream
== NULL
){
1597 return D3DERR_INVALIDCALL
;
1600 EnterCriticalSection(&d3d9_cs
);
1601 rc
= IWineD3DDevice_GetStreamSource(This
->WineD3DDevice
, StreamNumber
, &retStream
, OffsetInBytes
, pStride
);
1602 if (rc
== D3D_OK
&& NULL
!= retStream
) {
1603 IWineD3DBuffer_GetParent(retStream
, (IUnknown
**)pStream
);
1604 IWineD3DBuffer_Release(retStream
);
1607 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes
, pStride
);
1611 LeaveCriticalSection(&d3d9_cs
);
1616 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, UINT Divider
) {
1617 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1619 TRACE("(%p) Relay\n" , This
);
1621 EnterCriticalSection(&d3d9_cs
);
1622 hr
= IWineD3DDevice_SetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1623 LeaveCriticalSection(&d3d9_cs
);
1627 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, UINT
* Divider
) {
1628 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1630 TRACE("(%p) Relay\n" , This
);
1632 EnterCriticalSection(&d3d9_cs
);
1633 hr
= IWineD3DDevice_GetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1634 LeaveCriticalSection(&d3d9_cs
);
1638 static HRESULT WINAPI
IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
* pIndexData
) {
1639 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1641 IDirect3DIndexBuffer9Impl
*ib
= (IDirect3DIndexBuffer9Impl
*) pIndexData
;
1642 TRACE("(%p) Relay\n", This
);
1644 EnterCriticalSection(&d3d9_cs
);
1645 hr
= IWineD3DDevice_SetIndices(This
->WineD3DDevice
,
1646 ib
? ib
->wineD3DIndexBuffer
: NULL
,
1647 ib
? ib
->format
: WINED3DFMT_UNKNOWN
);
1648 LeaveCriticalSection(&d3d9_cs
);
1652 static HRESULT WINAPI
IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
**ppIndexData
) {
1653 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1654 IWineD3DBuffer
*retIndexData
= NULL
;
1655 HRESULT rc
= D3D_OK
;
1657 TRACE("(%p) Relay\n", This
);
1659 if(ppIndexData
== NULL
){
1660 return D3DERR_INVALIDCALL
;
1663 EnterCriticalSection(&d3d9_cs
);
1664 rc
= IWineD3DDevice_GetIndices(This
->WineD3DDevice
, &retIndexData
);
1665 if (SUCCEEDED(rc
) && retIndexData
) {
1666 IWineD3DBuffer_GetParent(retIndexData
, (IUnknown
**)ppIndexData
);
1667 IWineD3DBuffer_Release(retIndexData
);
1669 if (FAILED(rc
)) FIXME("Call to GetIndices failed\n");
1670 *ppIndexData
= NULL
;
1672 LeaveCriticalSection(&d3d9_cs
);
1676 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DRECTPATCH_INFO
* pRectPatchInfo
) {
1677 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1679 TRACE("(%p) Relay\n", This
);
1681 EnterCriticalSection(&d3d9_cs
);
1682 hr
= IWineD3DDevice_DrawRectPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DRECTPATCH_INFO
*)pRectPatchInfo
);
1683 LeaveCriticalSection(&d3d9_cs
);
1687 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DTRIPATCH_INFO
* pTriPatchInfo
) {
1688 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1690 TRACE("(%p) Relay\n", This
);
1692 EnterCriticalSection(&d3d9_cs
);
1693 hr
= IWineD3DDevice_DrawTriPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DTRIPATCH_INFO
*)pTriPatchInfo
);
1694 LeaveCriticalSection(&d3d9_cs
);
1698 static HRESULT WINAPI
IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
) {
1699 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1701 TRACE("(%p) Relay\n", This
);
1703 EnterCriticalSection(&d3d9_cs
);
1704 hr
= IWineD3DDevice_DeletePatch(This
->WineD3DDevice
, Handle
);
1705 LeaveCriticalSection(&d3d9_cs
);
1709 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(LPDIRECT3DDEVICE9EX iface
, UINT width
, UINT height
, float *rows
, float *columns
) {
1710 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1711 FIXME("(%p)->(%d, %d, %p, %p) Stub!\n", This
, width
, height
, rows
, columns
);
1712 return WINED3DERR_INVALIDCALL
;
1715 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ComposeRects(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
*pSrc
, IDirect3DDevice9
*pDst
, IDirect3DVertexBuffer9
*pSrcRectDescs
, UINT NumRects
, IDirect3DVertexBuffer9
*pDstRectDescs
, D3DCOMPOSERECTSOP Operation
, int Xoffset
, int Yoffset
) {
1716 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1717 FIXME("(%p)->(%p, %p, %p, %d, %p, %d, %d, %d) Stub!\n", This
, pSrc
, pDst
, pSrcRectDescs
, NumRects
, pDstRectDescs
, Operation
, Xoffset
, Yoffset
);
1718 return WINED3DERR_INVALIDCALL
;
1721 static HRESULT WINAPI
IDirect3DDevice9ExImpl_PresentEx(LPDIRECT3DDEVICE9EX iface
, CONST RECT
*pSourceRect
, CONST RECT
*pDestRect
, HWND hDestWindowOverride
, CONST RGNDATA
*pDirtyRegion
, DWORD dwFlags
) {
1722 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1723 FIXME("(%p= -> (%p), %p, %p, %p, 0x%08x) Stub!\n", This
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
, dwFlags
);
1724 return WINED3DERR_INVALIDCALL
;
1727 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface
, INT
*pPriority
) {
1728 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1729 FIXME("(%p)->(%p) Stub!\n", This
, pPriority
);
1730 return WINED3DERR_INVALIDCALL
;
1733 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface
, INT Priority
) {
1734 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1735 FIXME("(%p)->(%d) Stub!\n", This
, Priority
);
1736 return WINED3DERR_INVALIDCALL
;
1739 static HRESULT WINAPI
IDirect3DDevice9ExImpl_WaitForVBlank(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
) {
1740 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1741 FIXME("(%p)->(%d) Stub!\n", This
, iSwapChain
);
1742 return WINED3DERR_INVALIDCALL
;
1745 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckresourceResidency(LPDIRECT3DDEVICE9EX iface
, IDirect3DResource9
** pResourceArray
, UINT32 Numresources
) {
1746 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1747 FIXME("(%p)->(%p, %d) Stub!\n", This
, pResourceArray
, Numresources
);
1748 return WINED3DERR_INVALIDCALL
;
1751 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface
, UINT MaxLatency
) {
1752 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1753 FIXME("(%p)->(%d) Stub!\n", This
, MaxLatency
);
1754 return WINED3DERR_INVALIDCALL
;
1757 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface
, UINT
*pMaxLatency
) {
1758 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1759 FIXME("(%p)->(%p) Stub!\n", This
, pMaxLatency
);
1761 return WINED3DERR_INVALIDCALL
;
1764 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckdeviceState(LPDIRECT3DDEVICE9EX iface
, HWND hDestinationWindow
) {
1765 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1766 FIXME("(%p)->(%p) Stub!\n", This
, hDestinationWindow
);
1767 return WINED3DERR_INVALIDCALL
;
1770 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
) {
1771 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1772 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
);
1773 return WINED3DERR_INVALIDCALL
;
1776 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
*pSharedHandle
, DWORD Usage
) {
1777 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1778 FIXME("(%p)->(%d, %d, %d, %d, %p, %p, 0x%08x) Stub!\n", This
, Width
, Height
, Format
, Pool
, ppSurface
, pSharedHandle
, Usage
);
1779 return WINED3DERR_INVALIDCALL
;
1782 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
) {
1783 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1784 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
);
1785 return WINED3DERR_INVALIDCALL
;
1788 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ResetEx(LPDIRECT3DDEVICE9EX iface
, D3DPRESENT_PARAMETERS
*pPresentationParameters
, D3DDISPLAYMODEEX
*pFullscreenDisplayMode
) {
1789 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1790 FIXME("(%p)->(%p) Stub!\n", This
, pPresentationParameters
);
1791 return WINED3DERR_INVALIDCALL
;
1794 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetDisplayModeEx(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DDISPLAYMODEEX
*pMode
, D3DDISPLAYROTATION
*pRotation
) {
1795 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1796 FIXME("(%p)->(%d, %p, %p) Stub!\n", This
, iSwapChain
, pMode
, pRotation
);
1797 return WINED3DERR_INVALIDCALL
;
1800 const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl
=
1803 IDirect3DDevice9Impl_QueryInterface
,
1804 IDirect3DDevice9Impl_AddRef
,
1805 IDirect3DDevice9Impl_Release
,
1806 /* IDirect3DDevice9 */
1807 IDirect3DDevice9Impl_TestCooperativeLevel
,
1808 IDirect3DDevice9Impl_GetAvailableTextureMem
,
1809 IDirect3DDevice9Impl_EvictManagedResources
,
1810 IDirect3DDevice9Impl_GetDirect3D
,
1811 IDirect3DDevice9Impl_GetDeviceCaps
,
1812 IDirect3DDevice9Impl_GetDisplayMode
,
1813 IDirect3DDevice9Impl_GetCreationParameters
,
1814 IDirect3DDevice9Impl_SetCursorProperties
,
1815 IDirect3DDevice9Impl_SetCursorPosition
,
1816 IDirect3DDevice9Impl_ShowCursor
,
1817 IDirect3DDevice9Impl_CreateAdditionalSwapChain
,
1818 IDirect3DDevice9Impl_GetSwapChain
,
1819 IDirect3DDevice9Impl_GetNumberOfSwapChains
,
1820 IDirect3DDevice9Impl_Reset
,
1821 IDirect3DDevice9Impl_Present
,
1822 IDirect3DDevice9Impl_GetBackBuffer
,
1823 IDirect3DDevice9Impl_GetRasterStatus
,
1824 IDirect3DDevice9Impl_SetDialogBoxMode
,
1825 IDirect3DDevice9Impl_SetGammaRamp
,
1826 IDirect3DDevice9Impl_GetGammaRamp
,
1827 IDirect3DDevice9Impl_CreateTexture
,
1828 IDirect3DDevice9Impl_CreateVolumeTexture
,
1829 IDirect3DDevice9Impl_CreateCubeTexture
,
1830 IDirect3DDevice9Impl_CreateVertexBuffer
,
1831 IDirect3DDevice9Impl_CreateIndexBuffer
,
1832 IDirect3DDevice9Impl_CreateRenderTarget
,
1833 IDirect3DDevice9Impl_CreateDepthStencilSurface
,
1834 IDirect3DDevice9Impl_UpdateSurface
,
1835 IDirect3DDevice9Impl_UpdateTexture
,
1836 IDirect3DDevice9Impl_GetRenderTargetData
,
1837 IDirect3DDevice9Impl_GetFrontBufferData
,
1838 IDirect3DDevice9Impl_StretchRect
,
1839 IDirect3DDevice9Impl_ColorFill
,
1840 IDirect3DDevice9Impl_CreateOffscreenPlainSurface
,
1841 IDirect3DDevice9Impl_SetRenderTarget
,
1842 IDirect3DDevice9Impl_GetRenderTarget
,
1843 IDirect3DDevice9Impl_SetDepthStencilSurface
,
1844 IDirect3DDevice9Impl_GetDepthStencilSurface
,
1845 IDirect3DDevice9Impl_BeginScene
,
1846 IDirect3DDevice9Impl_EndScene
,
1847 IDirect3DDevice9Impl_Clear
,
1848 IDirect3DDevice9Impl_SetTransform
,
1849 IDirect3DDevice9Impl_GetTransform
,
1850 IDirect3DDevice9Impl_MultiplyTransform
,
1851 IDirect3DDevice9Impl_SetViewport
,
1852 IDirect3DDevice9Impl_GetViewport
,
1853 IDirect3DDevice9Impl_SetMaterial
,
1854 IDirect3DDevice9Impl_GetMaterial
,
1855 IDirect3DDevice9Impl_SetLight
,
1856 IDirect3DDevice9Impl_GetLight
,
1857 IDirect3DDevice9Impl_LightEnable
,
1858 IDirect3DDevice9Impl_GetLightEnable
,
1859 IDirect3DDevice9Impl_SetClipPlane
,
1860 IDirect3DDevice9Impl_GetClipPlane
,
1861 IDirect3DDevice9Impl_SetRenderState
,
1862 IDirect3DDevice9Impl_GetRenderState
,
1863 IDirect3DDevice9Impl_CreateStateBlock
,
1864 IDirect3DDevice9Impl_BeginStateBlock
,
1865 IDirect3DDevice9Impl_EndStateBlock
,
1866 IDirect3DDevice9Impl_SetClipStatus
,
1867 IDirect3DDevice9Impl_GetClipStatus
,
1868 IDirect3DDevice9Impl_GetTexture
,
1869 IDirect3DDevice9Impl_SetTexture
,
1870 IDirect3DDevice9Impl_GetTextureStageState
,
1871 IDirect3DDevice9Impl_SetTextureStageState
,
1872 IDirect3DDevice9Impl_GetSamplerState
,
1873 IDirect3DDevice9Impl_SetSamplerState
,
1874 IDirect3DDevice9Impl_ValidateDevice
,
1875 IDirect3DDevice9Impl_SetPaletteEntries
,
1876 IDirect3DDevice9Impl_GetPaletteEntries
,
1877 IDirect3DDevice9Impl_SetCurrentTexturePalette
,
1878 IDirect3DDevice9Impl_GetCurrentTexturePalette
,
1879 IDirect3DDevice9Impl_SetScissorRect
,
1880 IDirect3DDevice9Impl_GetScissorRect
,
1881 IDirect3DDevice9Impl_SetSoftwareVertexProcessing
,
1882 IDirect3DDevice9Impl_GetSoftwareVertexProcessing
,
1883 IDirect3DDevice9Impl_SetNPatchMode
,
1884 IDirect3DDevice9Impl_GetNPatchMode
,
1885 IDirect3DDevice9Impl_DrawPrimitive
,
1886 IDirect3DDevice9Impl_DrawIndexedPrimitive
,
1887 IDirect3DDevice9Impl_DrawPrimitiveUP
,
1888 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP
,
1889 IDirect3DDevice9Impl_ProcessVertices
,
1890 IDirect3DDevice9Impl_CreateVertexDeclaration
,
1891 IDirect3DDevice9Impl_SetVertexDeclaration
,
1892 IDirect3DDevice9Impl_GetVertexDeclaration
,
1893 IDirect3DDevice9Impl_SetFVF
,
1894 IDirect3DDevice9Impl_GetFVF
,
1895 IDirect3DDevice9Impl_CreateVertexShader
,
1896 IDirect3DDevice9Impl_SetVertexShader
,
1897 IDirect3DDevice9Impl_GetVertexShader
,
1898 IDirect3DDevice9Impl_SetVertexShaderConstantF
,
1899 IDirect3DDevice9Impl_GetVertexShaderConstantF
,
1900 IDirect3DDevice9Impl_SetVertexShaderConstantI
,
1901 IDirect3DDevice9Impl_GetVertexShaderConstantI
,
1902 IDirect3DDevice9Impl_SetVertexShaderConstantB
,
1903 IDirect3DDevice9Impl_GetVertexShaderConstantB
,
1904 IDirect3DDevice9Impl_SetStreamSource
,
1905 IDirect3DDevice9Impl_GetStreamSource
,
1906 IDirect3DDevice9Impl_SetStreamSourceFreq
,
1907 IDirect3DDevice9Impl_GetStreamSourceFreq
,
1908 IDirect3DDevice9Impl_SetIndices
,
1909 IDirect3DDevice9Impl_GetIndices
,
1910 IDirect3DDevice9Impl_CreatePixelShader
,
1911 IDirect3DDevice9Impl_SetPixelShader
,
1912 IDirect3DDevice9Impl_GetPixelShader
,
1913 IDirect3DDevice9Impl_SetPixelShaderConstantF
,
1914 IDirect3DDevice9Impl_GetPixelShaderConstantF
,
1915 IDirect3DDevice9Impl_SetPixelShaderConstantI
,
1916 IDirect3DDevice9Impl_GetPixelShaderConstantI
,
1917 IDirect3DDevice9Impl_SetPixelShaderConstantB
,
1918 IDirect3DDevice9Impl_GetPixelShaderConstantB
,
1919 IDirect3DDevice9Impl_DrawRectPatch
,
1920 IDirect3DDevice9Impl_DrawTriPatch
,
1921 IDirect3DDevice9Impl_DeletePatch
,
1922 IDirect3DDevice9Impl_CreateQuery
,
1923 /* IDirect3DDevice9Ex */
1924 IDirect3DDevice9ExImpl_SetConvolutionMonoKernel
,
1925 IDirect3DDevice9ExImpl_ComposeRects
,
1926 IDirect3DDevice9ExImpl_PresentEx
,
1927 IDirect3DDevice9ExImpl_GetGPUThreadPriority
,
1928 IDirect3DDevice9ExImpl_SetGPUThreadPriority
,
1929 IDirect3DDevice9ExImpl_WaitForVBlank
,
1930 IDirect3DDevice9ExImpl_CheckresourceResidency
,
1931 IDirect3DDevice9ExImpl_SetMaximumFrameLatency
,
1932 IDirect3DDevice9ExImpl_GetMaximumFrameLatency
,
1933 IDirect3DDevice9ExImpl_CheckdeviceState
,
1934 IDirect3DDevice9ExImpl_CreateRenderTargetEx
,
1935 IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx
,
1936 IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx
,
1937 IDirect3DDevice9ExImpl_ResetEx
,
1938 IDirect3DDevice9ExImpl_GetDisplayModeEx
1941 ULONG WINAPI
D3D9CB_DestroySurface(IWineD3DSurface
*pSurface
) {
1942 IDirect3DSurface9Impl
* surfaceParent
;
1943 TRACE("(%p) call back\n", pSurface
);
1945 IWineD3DSurface_GetParent(pSurface
, (IUnknown
**) &surfaceParent
);
1946 /* GetParent's AddRef was forwarded to an object in destruction.
1947 * Releasing it here again would cause an endless recursion. */
1948 surfaceParent
->forwardReference
= NULL
;
1949 return IDirect3DSurface9_Release((IDirect3DSurface9
*) surfaceParent
);
1952 /* IWineD3DDeviceParent IUnknown methods */
1954 static inline struct IDirect3DDevice9Impl
*device_from_device_parent(IWineD3DDeviceParent
*iface
)
1956 return (struct IDirect3DDevice9Impl
*)((char*)iface
1957 - FIELD_OFFSET(struct IDirect3DDevice9Impl
, device_parent_vtbl
));
1960 static HRESULT STDMETHODCALLTYPE
device_parent_QueryInterface(IWineD3DDeviceParent
*iface
, REFIID riid
, void **object
)
1962 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1963 return IDirect3DDevice9Impl_QueryInterface((IDirect3DDevice9Ex
*)This
, riid
, object
);
1966 static ULONG STDMETHODCALLTYPE
device_parent_AddRef(IWineD3DDeviceParent
*iface
)
1968 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1969 return IDirect3DDevice9Impl_AddRef((IDirect3DDevice9Ex
*)This
);
1972 static ULONG STDMETHODCALLTYPE
device_parent_Release(IWineD3DDeviceParent
*iface
)
1974 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1975 return IDirect3DDevice9Impl_Release((IDirect3DDevice9Ex
*)This
);
1978 /* IWineD3DDeviceParent methods */
1980 static void STDMETHODCALLTYPE
device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent
*iface
, IWineD3DDevice
*device
)
1982 TRACE("iface %p, device %p\n", iface
, device
);
1985 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSurface(IWineD3DDeviceParent
*iface
,
1986 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, DWORD usage
,
1987 WINED3DPOOL pool
, UINT level
, WINED3DCUBEMAP_FACES face
, IWineD3DSurface
**surface
)
1989 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1990 IDirect3DSurface9Impl
*d3d_surface
;
1991 BOOL lockable
= TRUE
;
1994 TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
1995 "\tpool %#x, level %u, face %u, surface %p\n",
1996 iface
, superior
, width
, height
, format
, usage
, pool
, level
, face
, surface
);
1998 if (pool
== D3DPOOL_DEFAULT
&& !(usage
& D3DUSAGE_DYNAMIC
)) lockable
= FALSE
;
2000 hr
= IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex
*)This
, width
, height
,
2001 d3dformat_from_wined3dformat(format
), lockable
, FALSE
/* Discard */, level
,
2002 (IDirect3DSurface9
**)&d3d_surface
, D3DRTYPE_SURFACE
, usage
, pool
,
2003 D3DMULTISAMPLE_NONE
, 0 /* MultisampleQuality */, NULL
);
2006 ERR("(%p) CreateSurface failed, returning %#x\n", iface
, hr
);
2010 *surface
= d3d_surface
->wineD3DSurface
;
2011 d3d_surface
->container
= superior
;
2012 IDirect3DDevice9Ex_Release(d3d_surface
->parentDevice
);
2013 d3d_surface
->parentDevice
= NULL
;
2014 d3d_surface
->forwardReference
= superior
;
2019 static HRESULT STDMETHODCALLTYPE
device_parent_CreateRenderTarget(IWineD3DDeviceParent
*iface
,
2020 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
2021 DWORD multisample_quality
, BOOL lockable
, IWineD3DSurface
**surface
)
2023 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2024 IDirect3DSurface9Impl
*d3d_surface
;
2027 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2028 "\tmultisample_quality %u, lockable %u, surface %p\n",
2029 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, lockable
, surface
);
2031 hr
= IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex
*)This
, width
, height
,
2032 d3dformat_from_wined3dformat(format
), multisample_type
, multisample_quality
, lockable
,
2033 (IDirect3DSurface9
**)&d3d_surface
, NULL
);
2036 ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface
, hr
);
2040 *surface
= d3d_surface
->wineD3DSurface
;
2041 d3d_surface
->container
= superior
;
2042 d3d_surface
->isImplicit
= TRUE
;
2043 /* Implicit surfaces are created with an refcount of 0 */
2044 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2049 static HRESULT STDMETHODCALLTYPE
device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent
*iface
,
2050 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
2051 DWORD multisample_quality
, BOOL discard
, IWineD3DSurface
**surface
)
2053 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2054 IDirect3DSurface9Impl
*d3d_surface
;
2057 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2058 "\tmultisample_quality %u, discard %u, surface %p\n",
2059 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, discard
, surface
);
2061 hr
= IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex
*)This
, width
, height
,
2062 d3dformat_from_wined3dformat(format
), multisample_type
, multisample_quality
, discard
,
2063 (IDirect3DSurface9
**)&d3d_surface
, NULL
);
2066 ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface
, hr
);
2070 *surface
= d3d_surface
->wineD3DSurface
;
2071 d3d_surface
->container
= (IUnknown
*)This
;
2072 d3d_surface
->isImplicit
= TRUE
;
2073 /* Implicit surfaces are created with an refcount of 0 */
2074 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2079 static HRESULT STDMETHODCALLTYPE
device_parent_CreateVolume(IWineD3DDeviceParent
*iface
,
2080 IUnknown
*superior
, UINT width
, UINT height
, UINT depth
, WINED3DFORMAT format
,
2081 WINED3DPOOL pool
, DWORD usage
, IWineD3DVolume
**volume
)
2083 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2084 IDirect3DVolume9Impl
*object
;
2087 TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
2088 iface
, superior
, width
, height
, depth
, format
, pool
, usage
, volume
);
2090 /* Allocate the storage for the device */
2091 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2094 FIXME("Allocation of memory failed\n");
2096 return D3DERR_OUTOFVIDEOMEMORY
;
2099 object
->lpVtbl
= &Direct3DVolume9_Vtbl
;
2101 hr
= IWineD3DDevice_CreateVolume(This
->WineD3DDevice
, width
, height
, depth
, usage
& WINED3DUSAGE_MASK
,
2102 format
, pool
, &object
->wineD3DVolume
, (IUnknown
*)object
);
2105 ERR("(%p) CreateVolume failed, returning %#x\n", iface
, hr
);
2106 HeapFree(GetProcessHeap(), 0, object
);
2111 *volume
= object
->wineD3DVolume
;
2112 object
->container
= superior
;
2113 object
->forwardReference
= superior
;
2115 TRACE("(%p) Created volume %p\n", iface
, *volume
);
2120 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSwapChain(IWineD3DDeviceParent
*iface
,
2121 WINED3DPRESENT_PARAMETERS
*present_parameters
, IWineD3DSwapChain
**swapchain
)
2123 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2124 IDirect3DSwapChain9Impl
*d3d_swapchain
;
2125 D3DPRESENT_PARAMETERS local_parameters
;
2128 TRACE("iface %p, present_parameters %p, swapchain %p\n", iface
, present_parameters
, swapchain
);
2130 /* Copy the presentation parameters */
2131 local_parameters
.BackBufferWidth
= present_parameters
->BackBufferWidth
;
2132 local_parameters
.BackBufferHeight
= present_parameters
->BackBufferHeight
;
2133 local_parameters
.BackBufferFormat
= d3dformat_from_wined3dformat(present_parameters
->BackBufferFormat
);
2134 local_parameters
.BackBufferCount
= present_parameters
->BackBufferCount
;
2135 local_parameters
.MultiSampleType
= present_parameters
->MultiSampleType
;
2136 local_parameters
.MultiSampleQuality
= present_parameters
->MultiSampleQuality
;
2137 local_parameters
.SwapEffect
= present_parameters
->SwapEffect
;
2138 local_parameters
.hDeviceWindow
= present_parameters
->hDeviceWindow
;
2139 local_parameters
.Windowed
= present_parameters
->Windowed
;
2140 local_parameters
.EnableAutoDepthStencil
= present_parameters
->EnableAutoDepthStencil
;
2141 local_parameters
.AutoDepthStencilFormat
= d3dformat_from_wined3dformat(present_parameters
->AutoDepthStencilFormat
);
2142 local_parameters
.Flags
= present_parameters
->Flags
;
2143 local_parameters
.FullScreen_RefreshRateInHz
= present_parameters
->FullScreen_RefreshRateInHz
;
2144 local_parameters
.PresentationInterval
= present_parameters
->PresentationInterval
;
2146 hr
= IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex
*)This
,
2147 &local_parameters
, (IDirect3DSwapChain9
**)&d3d_swapchain
);
2150 ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface
, hr
);
2155 *swapchain
= d3d_swapchain
->wineD3DSwapChain
;
2156 d3d_swapchain
->isImplicit
= TRUE
;
2157 /* Implicit swap chains are created with an refcount of 0 */
2158 IDirect3DSwapChain9_Release((IDirect3DSwapChain9
*)d3d_swapchain
);
2160 /* Copy back the presentation parameters */
2161 present_parameters
->BackBufferWidth
= local_parameters
.BackBufferWidth
;
2162 present_parameters
->BackBufferHeight
= local_parameters
.BackBufferHeight
;
2163 present_parameters
->BackBufferFormat
= wined3dformat_from_d3dformat(local_parameters
.BackBufferFormat
);
2164 present_parameters
->BackBufferCount
= local_parameters
.BackBufferCount
;
2165 present_parameters
->MultiSampleType
= local_parameters
.MultiSampleType
;
2166 present_parameters
->MultiSampleQuality
= local_parameters
.MultiSampleQuality
;
2167 present_parameters
->SwapEffect
= local_parameters
.SwapEffect
;
2168 present_parameters
->hDeviceWindow
= local_parameters
.hDeviceWindow
;
2169 present_parameters
->Windowed
= local_parameters
.Windowed
;
2170 present_parameters
->EnableAutoDepthStencil
= local_parameters
.EnableAutoDepthStencil
;
2171 present_parameters
->AutoDepthStencilFormat
= wined3dformat_from_d3dformat(local_parameters
.AutoDepthStencilFormat
);
2172 present_parameters
->Flags
= local_parameters
.Flags
;
2173 present_parameters
->FullScreen_RefreshRateInHz
= local_parameters
.FullScreen_RefreshRateInHz
;
2174 present_parameters
->PresentationInterval
= local_parameters
.PresentationInterval
;
2179 const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl
=
2181 /* IUnknown methods */
2182 device_parent_QueryInterface
,
2183 device_parent_AddRef
,
2184 device_parent_Release
,
2185 /* IWineD3DDeviceParent methods */
2186 device_parent_WineD3DDeviceCreated
,
2187 device_parent_CreateSurface
,
2188 device_parent_CreateRenderTarget
,
2189 device_parent_CreateDepthStencilSurface
,
2190 device_parent_CreateVolume
,
2191 device_parent_CreateSwapChain
,