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 wined3d_mutex_lock();
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_DestroySwapChain
);
261 IWineD3DDevice_Release(This
->WineD3DDevice
);
262 wined3d_mutex_unlock();
264 HeapFree(GetProcessHeap(), 0, This
);
269 /* IDirect3DDevice Interface follow: */
270 static HRESULT WINAPI
IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9EX iface
) {
271 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
273 TRACE("(%p)\n", This
);
275 wined3d_mutex_lock();
276 hr
= IWineD3DDevice_TestCooperativeLevel(This
->WineD3DDevice
);
277 wined3d_mutex_unlock();
279 if(hr
== WINED3D_OK
&& This
->notreset
) {
280 TRACE("D3D9 Device is marked not reset\n");
281 hr
= D3DERR_DEVICENOTRESET
;
287 static UINT WINAPI
IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9EX iface
) {
288 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
290 TRACE("(%p) Relay\n", This
);
292 wined3d_mutex_lock();
293 hr
= IWineD3DDevice_GetAvailableTextureMem(This
->WineD3DDevice
);
294 wined3d_mutex_unlock();
299 static HRESULT WINAPI
IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9EX iface
) {
300 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
302 TRACE("(%p) : Relay\n", This
);
304 wined3d_mutex_lock();
305 hr
= IWineD3DDevice_EvictManagedResources(This
->WineD3DDevice
);
306 wined3d_mutex_unlock();
311 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface
, IDirect3D9
** ppD3D9
) {
312 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
316 TRACE("(%p) Relay\n", This
);
318 if (NULL
== ppD3D9
) {
319 return D3DERR_INVALIDCALL
;
322 wined3d_mutex_lock();
323 hr
= IWineD3DDevice_GetDirect3D(This
->WineD3DDevice
, &pWineD3D
);
324 if (hr
== D3D_OK
&& pWineD3D
!= NULL
)
326 IWineD3D_GetParent(pWineD3D
,(IUnknown
**)ppD3D9
);
327 IWineD3D_Release(pWineD3D
);
329 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
332 TRACE("(%p) returning %p\n", This
, *ppD3D9
);
333 wined3d_mutex_unlock();
338 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9EX iface
, D3DCAPS9
* pCaps
) {
339 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
340 HRESULT hrc
= D3D_OK
;
341 WINED3DCAPS
*pWineCaps
;
343 TRACE("(%p) : Relay pCaps %p\n", This
, pCaps
);
345 return D3DERR_INVALIDCALL
;
347 pWineCaps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINED3DCAPS
));
348 if(pWineCaps
== NULL
){
349 return D3DERR_INVALIDCALL
; /* well this is what MSDN says to return */
352 memset(pCaps
, 0, sizeof(*pCaps
));
354 wined3d_mutex_lock();
355 hrc
= IWineD3DDevice_GetDeviceCaps(This
->WineD3DDevice
, pWineCaps
);
356 wined3d_mutex_unlock();
358 WINECAPSTOD3D9CAPS(pCaps
, pWineCaps
)
359 HeapFree(GetProcessHeap(), 0, pWineCaps
);
361 /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
362 pCaps
->DevCaps2
|= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
;
366 TRACE("Returning %p %p\n", This
, pCaps
);
370 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DDISPLAYMODE
* pMode
) {
371 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
373 TRACE("(%p) Relay\n", This
);
375 wined3d_mutex_lock();
376 hr
= IWineD3DDevice_GetDisplayMode(This
->WineD3DDevice
, iSwapChain
, (WINED3DDISPLAYMODE
*) pMode
);
377 wined3d_mutex_unlock();
379 if (SUCCEEDED(hr
)) pMode
->Format
= d3dformat_from_wined3dformat(pMode
->Format
);
384 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9EX iface
, D3DDEVICE_CREATION_PARAMETERS
*pParameters
) {
385 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
387 TRACE("(%p) Relay\n", This
);
389 wined3d_mutex_lock();
390 hr
= IWineD3DDevice_GetCreationParameters(This
->WineD3DDevice
, (WINED3DDEVICE_CREATION_PARAMETERS
*) pParameters
);
391 wined3d_mutex_unlock();
396 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9EX iface
, UINT XHotSpot
, UINT YHotSpot
, IDirect3DSurface9
* pCursorBitmap
) {
397 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
398 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pCursorBitmap
;
401 TRACE("(%p) Relay\n", This
);
403 WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
404 return WINED3DERR_INVALIDCALL
;
407 wined3d_mutex_lock();
408 hr
= IWineD3DDevice_SetCursorProperties(This
->WineD3DDevice
, XHotSpot
, YHotSpot
, pSurface
->wineD3DSurface
);
409 wined3d_mutex_unlock();
414 static void WINAPI
IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9EX iface
, int XScreenSpace
, int YScreenSpace
, DWORD Flags
) {
415 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
416 TRACE("(%p) Relay\n", This
);
418 wined3d_mutex_lock();
419 IWineD3DDevice_SetCursorPosition(This
->WineD3DDevice
, XScreenSpace
, YScreenSpace
, Flags
);
420 wined3d_mutex_unlock();
423 static BOOL WINAPI
IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX iface
, BOOL bShow
) {
424 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
426 TRACE("(%p) Relay\n", This
);
428 wined3d_mutex_lock();
429 ret
= IWineD3DDevice_ShowCursor(This
->WineD3DDevice
, bShow
);
430 wined3d_mutex_unlock();
435 static HRESULT WINAPI
reset_enum_callback(IWineD3DResource
*resource
, void *data
) {
436 BOOL
*resources_ok
= data
;
437 D3DRESOURCETYPE type
;
439 WINED3DSURFACE_DESC surface_desc
;
440 WINED3DVOLUME_DESC volume_desc
;
441 D3DINDEXBUFFER_DESC index_desc
;
442 D3DVERTEXBUFFER_DESC vertex_desc
;
444 IDirect3DResource9
*parent
;
446 IWineD3DResource_GetParent(resource
, (IUnknown
**) &parent
);
447 type
= IDirect3DResource9_GetType(parent
);
449 case D3DRTYPE_SURFACE
:
450 IWineD3DSurface_GetDesc((IWineD3DSurface
*) resource
, &surface_desc
);
451 pool
= surface_desc
.pool
;
454 case D3DRTYPE_VOLUME
:
455 IWineD3DVolume_GetDesc((IWineD3DVolume
*) resource
, &volume_desc
);
456 pool
= volume_desc
.Pool
;
459 case D3DRTYPE_INDEXBUFFER
:
460 IDirect3DIndexBuffer9_GetDesc((IDirect3DIndexBuffer9
*) parent
, &index_desc
);
461 pool
= index_desc
.Pool
;
464 case D3DRTYPE_VERTEXBUFFER
:
465 IDirect3DVertexBuffer9_GetDesc((IDirect3DVertexBuffer9
*)parent
, &vertex_desc
);
466 pool
= vertex_desc
.Pool
;
469 /* No need to check for textures. If there is a D3DPOOL_DEFAULT texture, there
470 * is a D3DPOOL_DEFAULT surface or volume as well
473 pool
= WINED3DPOOL_SCRATCH
; /* a harmless pool */
477 if(pool
== WINED3DPOOL_DEFAULT
) {
478 if(IUnknown_Release(parent
) == 0) {
479 TRACE("Parent %p is an implicit resource with ref 0\n", parent
);
481 WARN("Resource %p(wineD3D %p) with pool D3DPOOL_DEFAULT blocks the Reset call\n", parent
, resource
);
483 *resources_ok
= FALSE
;
486 IUnknown_Release(parent
);
488 IWineD3DResource_Release(resource
);
493 static HRESULT WINAPI
IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface
, D3DPRESENT_PARAMETERS
* pPresentationParameters
) {
494 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
495 WINED3DPRESENT_PARAMETERS localParameters
;
497 BOOL resources_ok
= TRUE
;
500 TRACE("(%p) Relay pPresentationParameters(%p)\n", This
, pPresentationParameters
);
502 /* Reset states that hold a COM object. WineD3D holds an internal reference to set objects, because
503 * such objects can still be used for rendering after their external d3d9 object has been destroyed.
504 * These objects must not be enumerated. Unsetting them tells WineD3D that the application will not
505 * make use of the hidden reference and destroys the objects.
507 * Unsetting them is no problem, because the states are supposed to be reset anyway. If the validation
508 * below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
510 wined3d_mutex_lock();
511 IWineD3DDevice_SetIndices(This
->WineD3DDevice
, NULL
, WINED3DFMT_UNKNOWN
);
512 for(i
= 0; i
< 16; i
++) {
513 IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, i
, NULL
, 0, 0);
515 for(i
= 0; i
< 16; i
++) {
516 IWineD3DDevice_SetTexture(This
->WineD3DDevice
, i
, NULL
);
519 IWineD3DDevice_EnumResources(This
->WineD3DDevice
, reset_enum_callback
, &resources_ok
);
521 WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
522 This
->notreset
= TRUE
;
523 wined3d_mutex_unlock();
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 wined3d_mutex_unlock();
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 wined3d_mutex_lock();
578 hr
= IWineD3DDevice_Present(This
->WineD3DDevice
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
);
579 wined3d_mutex_unlock();
584 static HRESULT WINAPI
IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, UINT BackBuffer
, D3DBACKBUFFER_TYPE Type
, IDirect3DSurface9
** ppBackBuffer
) {
585 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
586 IWineD3DSurface
*retSurface
= NULL
;
589 TRACE("(%p) Relay\n", This
);
591 wined3d_mutex_lock();
592 rc
= IWineD3DDevice_GetBackBuffer(This
->WineD3DDevice
, iSwapChain
, BackBuffer
, (WINED3DBACKBUFFER_TYPE
) Type
, &retSurface
);
593 if (rc
== D3D_OK
&& NULL
!= retSurface
&& NULL
!= ppBackBuffer
) {
594 IWineD3DSurface_GetParent(retSurface
, (IUnknown
**)ppBackBuffer
);
595 IWineD3DSurface_Release(retSurface
);
597 wined3d_mutex_unlock();
601 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DRASTER_STATUS
* pRasterStatus
) {
602 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
604 TRACE("(%p) Relay\n", This
);
606 wined3d_mutex_lock();
607 hr
= IWineD3DDevice_GetRasterStatus(This
->WineD3DDevice
, iSwapChain
, (WINED3DRASTER_STATUS
*) pRasterStatus
);
608 wined3d_mutex_unlock();
613 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9EX iface
, BOOL bEnableDialogs
) {
614 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
616 TRACE("(%p) Relay\n", This
);
618 wined3d_mutex_lock();
619 hr
= IWineD3DDevice_SetDialogBoxMode(This
->WineD3DDevice
, bEnableDialogs
);
620 wined3d_mutex_unlock();
625 static void WINAPI
IDirect3DDevice9Impl_SetGammaRamp(IDirect3DDevice9Ex
*iface
, UINT iSwapChain
,
626 DWORD Flags
, const D3DGAMMARAMP
*pRamp
)
628 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
629 TRACE("(%p) Relay\n", This
);
631 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
632 wined3d_mutex_lock();
633 IWineD3DDevice_SetGammaRamp(This
->WineD3DDevice
, iSwapChain
, Flags
, (CONST WINED3DGAMMARAMP
*)pRamp
);
634 wined3d_mutex_unlock();
637 static void WINAPI
IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DGAMMARAMP
* pRamp
) {
638 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
639 TRACE("(%p) Relay\n", This
);
641 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
642 wined3d_mutex_lock();
643 IWineD3DDevice_GetGammaRamp(This
->WineD3DDevice
, iSwapChain
, (WINED3DGAMMARAMP
*) pRamp
);
644 wined3d_mutex_unlock();
647 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateTexture(IDirect3DDevice9Ex
*iface
,
648 UINT width
, UINT height
, UINT levels
, DWORD usage
, D3DFORMAT format
,
649 D3DPOOL pool
, IDirect3DTexture9
**texture
, HANDLE
*shared_handle
)
651 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
652 IDirect3DTexture9Impl
*object
;
655 TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
656 iface
, width
, height
, levels
, usage
, format
, pool
, texture
, shared_handle
);
658 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
661 ERR("Failed to allocate texture memory.\n");
662 return D3DERR_OUTOFVIDEOMEMORY
;
665 hr
= texture_init(object
, This
, width
, height
, levels
, usage
, format
, pool
);
668 WARN("Failed to initialize texture, hr %#x.\n", hr
);
669 HeapFree(GetProcessHeap(), 0, object
);
673 TRACE("Created texture %p.\n", object
);
674 *texture
= (IDirect3DTexture9
*)object
;
679 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9Ex
*iface
,
680 UINT width
, UINT height
, UINT depth
, UINT levels
, DWORD usage
, D3DFORMAT format
,
681 D3DPOOL pool
, IDirect3DVolumeTexture9
**texture
, HANDLE
*shared_handle
)
683 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
684 IDirect3DVolumeTexture9Impl
*object
;
687 TRACE("iface %p, width %u, height %u, depth %u, levels %u\n",
688 iface
, width
, height
, depth
, levels
);
689 TRACE("usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
690 usage
, format
, pool
, texture
, shared_handle
);
692 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
695 ERR("Failed to allocate volume texture memory.\n");
696 return D3DERR_OUTOFVIDEOMEMORY
;
699 hr
= volumetexture_init(object
, This
, width
, height
, depth
, levels
, usage
, format
, pool
);
702 WARN("Failed to initialize volume texture, hr %#x.\n", hr
);
703 HeapFree(GetProcessHeap(), 0, object
);
707 TRACE("Created volume texture %p.\n", object
);
708 *texture
= (IDirect3DVolumeTexture9
*)object
;
713 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateCubeTexture(IDirect3DDevice9Ex
*iface
,
714 UINT edge_length
, UINT levels
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
,
715 IDirect3DCubeTexture9
**texture
, HANDLE
*shared_handle
)
717 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
718 IDirect3DCubeTexture9Impl
*object
;
721 TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
722 iface
, edge_length
, levels
, usage
, format
, pool
, texture
, shared_handle
);
724 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
727 ERR("Failed to allocate cube texture memory.\n");
728 return D3DERR_OUTOFVIDEOMEMORY
;
731 hr
= cubetexture_init(object
, This
, edge_length
, levels
, usage
, format
, pool
);
734 WARN("Failed to initialize cube texture, hr %#x.\n", hr
);
735 HeapFree(GetProcessHeap(), 0, object
);
739 TRACE("Created cube texture %p.\n", object
);
740 *texture
= (IDirect3DCubeTexture9
*)object
;
745 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex
*iface
, UINT size
, DWORD usage
,
746 DWORD fvf
, D3DPOOL pool
, IDirect3DVertexBuffer9
**buffer
, HANDLE
*shared_handle
)
748 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
749 IDirect3DVertexBuffer9Impl
*object
;
752 TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p, shared_handle %p.\n",
753 iface
, size
, usage
, fvf
, pool
, buffer
, shared_handle
);
755 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
758 ERR("Failed to allocate buffer memory.\n");
759 return D3DERR_OUTOFVIDEOMEMORY
;
762 hr
= vertexbuffer_init(object
, This
, size
, usage
, fvf
, pool
);
765 WARN("Failed to initialize vertex buffer, hr %#x.\n", hr
);
766 HeapFree(GetProcessHeap(), 0, object
);
770 TRACE("Created vertex buffer %p.\n", object
);
771 *buffer
= (IDirect3DVertexBuffer9
*)object
;
776 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateIndexBuffer(IDirect3DDevice9Ex
*iface
, UINT size
, DWORD usage
,
777 D3DFORMAT format
, D3DPOOL pool
, IDirect3DIndexBuffer9
**buffer
, HANDLE
*shared_handle
)
779 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
780 IDirect3DIndexBuffer9Impl
*object
;
783 TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p, shared_handle %p.\n",
784 iface
, size
, usage
, format
, pool
, buffer
, shared_handle
);
786 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
789 ERR("Failed to allocate buffer memory.\n");
790 return D3DERR_OUTOFVIDEOMEMORY
;
793 hr
= indexbuffer_init(object
, This
, size
, usage
, format
, pool
);
796 WARN("Failed to initialize index buffer, hr %#x.\n", hr
);
797 HeapFree(GetProcessHeap(), 0, object
);
801 TRACE("Created index buffer %p.\n", object
);
802 *buffer
= (IDirect3DIndexBuffer9
*)object
;
807 static HRESULT
IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
808 D3DFORMAT Format
, BOOL Lockable
, BOOL Discard
, UINT Level
, IDirect3DSurface9
**ppSurface
,
809 UINT Usage
, D3DPOOL Pool
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultisampleQuality
)
811 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
812 IDirect3DSurface9Impl
*object
;
815 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This
, Width
, Height
, Format
, *ppSurface
);
817 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DSurface9Impl
));
820 FIXME("Failed to allocate surface memory.\n");
821 return D3DERR_OUTOFVIDEOMEMORY
;
824 hr
= surface_init(object
, This
, Width
, Height
, Format
, Lockable
, Discard
,
825 Level
, Usage
, Pool
, MultiSample
, MultisampleQuality
);
828 WARN("Failed to initialize surface, hr %#x.\n", hr
);
829 HeapFree(GetProcessHeap(), 0, object
);
833 TRACE("Created surface %p.\n", object
);
834 *ppSurface
= (IDirect3DSurface9
*)object
;
839 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateRenderTarget(IDirect3DDevice9Ex
*iface
, UINT Width
, UINT Height
,
840 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
, DWORD MultisampleQuality
, BOOL Lockable
,
841 IDirect3DSurface9
**ppSurface
, HANDLE
*pSharedHandle
)
846 hr
= IDirect3DDevice9Impl_CreateSurface(iface
, Width
, Height
, Format
, Lockable
, FALSE
/* Discard */,
847 0 /* Level */, ppSurface
, D3DUSAGE_RENDERTARGET
, D3DPOOL_DEFAULT
, MultiSample
, MultisampleQuality
);
852 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
853 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
854 DWORD MultisampleQuality
, BOOL Discard
,
855 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
859 hr
= IDirect3DDevice9Impl_CreateSurface(iface
, Width
, Height
, Format
, TRUE
/* Lockable */, Discard
,
860 0 /* Level */, ppSurface
, D3DUSAGE_DEPTHSTENCIL
, D3DPOOL_DEFAULT
, MultiSample
, MultisampleQuality
);
866 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestinationSurface
, CONST POINT
* pDestPoint
) {
867 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
869 TRACE("(%p) Relay\n" , This
);
871 wined3d_mutex_lock();
872 hr
= IWineD3DDevice_UpdateSurface(This
->WineD3DDevice
, ((IDirect3DSurface9Impl
*)pSourceSurface
)->wineD3DSurface
, pSourceRect
, ((IDirect3DSurface9Impl
*)pDestinationSurface
)->wineD3DSurface
, pDestPoint
);
873 wined3d_mutex_unlock();
878 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9EX iface
, IDirect3DBaseTexture9
* pSourceTexture
, IDirect3DBaseTexture9
* pDestinationTexture
) {
879 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
881 TRACE("(%p) Relay\n" , This
);
883 wined3d_mutex_lock();
884 hr
= IWineD3DDevice_UpdateTexture(This
->WineD3DDevice
, ((IDirect3DBaseTexture9Impl
*)pSourceTexture
)->wineD3DBaseTexture
, ((IDirect3DBaseTexture9Impl
*)pDestinationTexture
)->wineD3DBaseTexture
);
885 wined3d_mutex_unlock();
890 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pRenderTarget
, IDirect3DSurface9
* pDestSurface
) {
891 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
892 IDirect3DSurface9Impl
*renderTarget
= (IDirect3DSurface9Impl
*)pRenderTarget
;
893 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
895 TRACE("(%p)->(%p,%p)\n" , This
, renderTarget
, destSurface
);
897 wined3d_mutex_lock();
898 hr
= IWineD3DSurface_BltFast(destSurface
->wineD3DSurface
, 0, 0, renderTarget
->wineD3DSurface
, NULL
, WINEDDBLTFAST_NOCOLORKEY
);
899 wined3d_mutex_unlock();
904 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, IDirect3DSurface9
* pDestSurface
) {
905 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
906 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
908 TRACE("(%p) Relay\n" , This
);
910 wined3d_mutex_lock();
911 hr
= IWineD3DDevice_GetFrontBufferData(This
->WineD3DDevice
, iSwapChain
, destSurface
->wineD3DSurface
);
912 wined3d_mutex_unlock();
917 static HRESULT WINAPI
IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestSurface
, CONST RECT
* pDestRect
, D3DTEXTUREFILTERTYPE Filter
) {
918 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
919 IDirect3DSurface9Impl
*src
= (IDirect3DSurface9Impl
*) pSourceSurface
;
920 IDirect3DSurface9Impl
*dst
= (IDirect3DSurface9Impl
*) pDestSurface
;
923 TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This
, src
, pSourceRect
, dst
, pDestRect
, Filter
);
925 wined3d_mutex_lock();
926 hr
= IWineD3DSurface_Blt(dst
->wineD3DSurface
, pDestRect
, src
->wineD3DSurface
, pSourceRect
, 0, NULL
, Filter
);
927 wined3d_mutex_unlock();
932 static HRESULT WINAPI
IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSurface
, CONST RECT
* pRect
, D3DCOLOR color
) {
933 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
934 IDirect3DSurface9Impl
*surface
= (IDirect3DSurface9Impl
*)pSurface
;
936 WINED3DRESOURCETYPE restype
;
938 WINED3DSURFACE_DESC desc
;
940 TRACE("(%p) Relay\n" , This
);
942 wined3d_mutex_lock();
944 IWineD3DSurface_GetDesc(surface
->wineD3DSurface
, &desc
);
947 restype
= desc
.resource_type
;
949 /* This method is only allowed with surfaces that are render targets, or offscreen plain surfaces
952 if(!(usage
& WINED3DUSAGE_RENDERTARGET
) && (pool
!= WINED3DPOOL_DEFAULT
|| restype
!= WINED3DRTYPE_SURFACE
)) {
953 wined3d_mutex_unlock();
954 WARN("Surface is not a render target, or not a stand-alone D3DPOOL_DEFAULT surface\n");
955 return D3DERR_INVALIDCALL
;
958 /* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
959 /* Note: D3DRECT is compatible with WINED3DRECT */
960 hr
= IWineD3DDevice_ColorFill(This
->WineD3DDevice
, surface
->wineD3DSurface
, (CONST WINED3DRECT
*)pRect
, color
);
962 wined3d_mutex_unlock();
967 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
970 if(Pool
== D3DPOOL_MANAGED
){
971 FIXME("Attempting to create a managed offscreen plain surface\n");
972 return D3DERR_INVALIDCALL
;
975 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
977 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
978 Why, their always lockable?
979 should I change the usage to dynamic?
981 hr
= IDirect3DDevice9Impl_CreateSurface(iface
, Width
, Height
, Format
, TRUE
/* Lockable */, FALSE
/* Discard */,
982 0 /* Level */, ppSurface
, 0 /* Usage (undefined/none) */, (WINED3DPOOL
)Pool
, D3DMULTISAMPLE_NONE
,
983 0 /* MultisampleQuality */);
988 /* TODO: move to wineD3D */
989 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
* pRenderTarget
) {
990 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
991 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pRenderTarget
;
993 TRACE("(%p) Relay\n" , This
);
995 if (RenderTargetIndex
>= D3D9_MAX_SIMULTANEOUS_RENDERTARGETS
)
997 WARN("Invalid index %u specified.\n", RenderTargetIndex
);
998 return D3DERR_INVALIDCALL
;
1001 wined3d_mutex_lock();
1002 hr
= IWineD3DDevice_SetRenderTarget(This
->WineD3DDevice
, RenderTargetIndex
, pSurface
? pSurface
->wineD3DSurface
: NULL
);
1003 wined3d_mutex_unlock();
1008 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
**ppRenderTarget
) {
1009 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1010 IWineD3DSurface
*pRenderTarget
;
1013 TRACE("(%p) Relay\n" , This
);
1015 if (ppRenderTarget
== NULL
) {
1016 return D3DERR_INVALIDCALL
;
1019 if (RenderTargetIndex
>= D3D9_MAX_SIMULTANEOUS_RENDERTARGETS
)
1021 WARN("Invalid index %u specified.\n", RenderTargetIndex
);
1022 return D3DERR_INVALIDCALL
;
1025 wined3d_mutex_lock();
1027 hr
=IWineD3DDevice_GetRenderTarget(This
->WineD3DDevice
,RenderTargetIndex
,&pRenderTarget
);
1031 FIXME("Call to IWineD3DDevice_GetRenderTarget failed, hr %#x\n", hr
);
1033 else if (!pRenderTarget
)
1035 *ppRenderTarget
= NULL
;
1039 IWineD3DSurface_GetParent(pRenderTarget
, (IUnknown
**)ppRenderTarget
);
1040 IWineD3DSurface_Release(pRenderTarget
);
1043 wined3d_mutex_unlock();
1048 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pZStencilSurface
) {
1049 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1050 IDirect3DSurface9Impl
*pSurface
;
1052 TRACE("(%p) Relay\n" , This
);
1054 pSurface
= (IDirect3DSurface9Impl
*)pZStencilSurface
;
1056 wined3d_mutex_lock();
1057 hr
= IWineD3DDevice_SetDepthStencilSurface(This
->WineD3DDevice
, NULL
==pSurface
? NULL
: pSurface
->wineD3DSurface
);
1058 wined3d_mutex_unlock();
1063 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
**ppZStencilSurface
) {
1064 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1065 HRESULT hr
= D3D_OK
;
1066 IWineD3DSurface
*pZStencilSurface
;
1068 TRACE("(%p) Relay\n" , This
);
1069 if(ppZStencilSurface
== NULL
){
1070 return D3DERR_INVALIDCALL
;
1073 wined3d_mutex_lock();
1074 hr
= IWineD3DDevice_GetDepthStencilSurface(This
->WineD3DDevice
,&pZStencilSurface
);
1075 if (hr
== WINED3D_OK
) {
1076 IWineD3DSurface_GetParent(pZStencilSurface
,(IUnknown
**)ppZStencilSurface
);
1077 IWineD3DSurface_Release(pZStencilSurface
);
1079 if (hr
!= WINED3DERR_NOTFOUND
)
1080 WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr
);
1081 *ppZStencilSurface
= NULL
;
1083 wined3d_mutex_unlock();
1088 static HRESULT WINAPI
IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX iface
) {
1089 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1091 TRACE("(%p) Relay\n" , This
);
1093 wined3d_mutex_lock();
1094 hr
= IWineD3DDevice_BeginScene(This
->WineD3DDevice
);
1095 wined3d_mutex_unlock();
1100 static HRESULT WINAPI
IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface
) {
1101 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1103 TRACE("(%p) Relay\n" , This
);
1105 wined3d_mutex_lock();
1106 hr
= IWineD3DDevice_EndScene(This
->WineD3DDevice
);
1107 wined3d_mutex_unlock();
1112 static HRESULT WINAPI
IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9EX iface
, DWORD Count
, CONST D3DRECT
* pRects
, DWORD Flags
, D3DCOLOR Color
, float Z
, DWORD Stencil
) {
1113 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1115 TRACE("(%p) Relay\n" , This
);
1117 /* Note: D3DRECT is compatible with WINED3DRECT */
1118 wined3d_mutex_lock();
1119 hr
= IWineD3DDevice_Clear(This
->WineD3DDevice
, Count
, (CONST WINED3DRECT
*) pRects
, Flags
, Color
, Z
, Stencil
);
1120 wined3d_mutex_unlock();
1125 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* lpMatrix
) {
1126 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1128 TRACE("(%p) Relay\n" , This
);
1130 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
1131 wined3d_mutex_lock();
1132 hr
= IWineD3DDevice_SetTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) lpMatrix
);
1133 wined3d_mutex_unlock();
1138 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, D3DMATRIX
* pMatrix
) {
1139 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1142 TRACE("(%p) Relay\n" , This
);
1144 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
1145 wined3d_mutex_lock();
1146 hr
= IWineD3DDevice_GetTransform(This
->WineD3DDevice
, State
, (WINED3DMATRIX
*) pMatrix
);
1147 wined3d_mutex_unlock();
1152 static HRESULT WINAPI
IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* pMatrix
) {
1153 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1155 TRACE("(%p) Relay\n" , This
);
1157 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
1158 wined3d_mutex_lock();
1159 hr
= IWineD3DDevice_MultiplyTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) pMatrix
);
1160 wined3d_mutex_unlock();
1165 static HRESULT WINAPI
IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9EX iface
, CONST D3DVIEWPORT9
* pViewport
) {
1166 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1168 TRACE("(%p) Relay\n" , This
);
1170 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
1171 wined3d_mutex_lock();
1172 hr
= IWineD3DDevice_SetViewport(This
->WineD3DDevice
, (const WINED3DVIEWPORT
*)pViewport
);
1173 wined3d_mutex_unlock();
1178 static HRESULT WINAPI
IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9EX iface
, D3DVIEWPORT9
* pViewport
) {
1179 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1181 TRACE("(%p) Relay\n" , This
);
1183 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
1184 wined3d_mutex_lock();
1185 hr
= IWineD3DDevice_GetViewport(This
->WineD3DDevice
, (WINED3DVIEWPORT
*)pViewport
);
1186 wined3d_mutex_unlock();
1191 static HRESULT WINAPI
IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9EX iface
, CONST D3DMATERIAL9
* pMaterial
) {
1192 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1194 TRACE("(%p) Relay\n" , This
);
1196 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
1197 wined3d_mutex_lock();
1198 hr
= IWineD3DDevice_SetMaterial(This
->WineD3DDevice
, (const WINED3DMATERIAL
*)pMaterial
);
1199 wined3d_mutex_unlock();
1204 static HRESULT WINAPI
IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9EX iface
, D3DMATERIAL9
* pMaterial
) {
1205 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1207 TRACE("(%p) Relay\n" , This
);
1209 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
1210 wined3d_mutex_lock();
1211 hr
= IWineD3DDevice_GetMaterial(This
->WineD3DDevice
, (WINED3DMATERIAL
*)pMaterial
);
1212 wined3d_mutex_unlock();
1217 static HRESULT WINAPI
IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST D3DLIGHT9
* pLight
) {
1218 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1220 TRACE("(%p) Relay\n" , This
);
1222 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
1223 wined3d_mutex_lock();
1224 hr
= IWineD3DDevice_SetLight(This
->WineD3DDevice
, Index
, (const WINED3DLIGHT
*)pLight
);
1225 wined3d_mutex_unlock();
1230 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, D3DLIGHT9
* pLight
) {
1231 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1233 TRACE("(%p) Relay\n" , This
);
1235 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
1236 wined3d_mutex_lock();
1237 hr
= IWineD3DDevice_GetLight(This
->WineD3DDevice
, Index
, (WINED3DLIGHT
*)pLight
);
1238 wined3d_mutex_unlock();
1243 static HRESULT WINAPI
IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL Enable
) {
1244 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1246 TRACE("(%p) Relay\n" , This
);
1248 wined3d_mutex_lock();
1249 hr
= IWineD3DDevice_SetLightEnable(This
->WineD3DDevice
, Index
, Enable
);
1250 wined3d_mutex_unlock();
1255 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL
* pEnable
) {
1256 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1258 TRACE("(%p) Relay\n" , This
);
1260 wined3d_mutex_lock();
1261 hr
= IWineD3DDevice_GetLightEnable(This
->WineD3DDevice
, Index
, pEnable
);
1262 wined3d_mutex_unlock();
1267 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST
float* pPlane
) {
1268 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1270 TRACE("(%p) Relay\n" , This
);
1272 wined3d_mutex_lock();
1273 hr
= IWineD3DDevice_SetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
1274 wined3d_mutex_unlock();
1279 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, float* pPlane
) {
1280 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1282 TRACE("(%p) Relay\n" , This
);
1284 wined3d_mutex_lock();
1285 hr
= IWineD3DDevice_GetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
1286 wined3d_mutex_unlock();
1291 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD Value
) {
1292 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1294 TRACE("(%p) Relay\n" , This
);
1296 wined3d_mutex_lock();
1297 hr
= IWineD3DDevice_SetRenderState(This
->WineD3DDevice
, State
, Value
);
1298 wined3d_mutex_unlock();
1303 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD
* pValue
) {
1304 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1306 TRACE("(%p) Relay\n" , This
);
1308 wined3d_mutex_lock();
1309 hr
= IWineD3DDevice_GetRenderState(This
->WineD3DDevice
, State
, pValue
);
1310 wined3d_mutex_unlock();
1315 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX iface
, CONST D3DCLIPSTATUS9
* pClipStatus
) {
1316 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1318 TRACE("(%p) Relay\n" , This
);
1320 wined3d_mutex_lock();
1321 hr
= IWineD3DDevice_SetClipStatus(This
->WineD3DDevice
, (const WINED3DCLIPSTATUS
*)pClipStatus
);
1322 wined3d_mutex_unlock();
1327 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9EX iface
, D3DCLIPSTATUS9
* pClipStatus
) {
1328 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1330 TRACE("(%p) Relay\n" , This
);
1332 wined3d_mutex_lock();
1333 hr
= IWineD3DDevice_GetClipStatus(This
->WineD3DDevice
, (WINED3DCLIPSTATUS
*)pClipStatus
);
1334 wined3d_mutex_unlock();
1339 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
**ppTexture
) {
1340 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1341 IWineD3DBaseTexture
*retTexture
= NULL
;
1342 HRESULT rc
= D3D_OK
;
1344 TRACE("(%p) Relay\n" , This
);
1346 if(ppTexture
== NULL
){
1347 return D3DERR_INVALIDCALL
;
1350 wined3d_mutex_lock();
1351 rc
= IWineD3DDevice_GetTexture(This
->WineD3DDevice
, Stage
, &retTexture
);
1352 if (SUCCEEDED(rc
) && NULL
!= retTexture
) {
1353 IWineD3DBaseTexture_GetParent(retTexture
, (IUnknown
**)ppTexture
);
1354 IWineD3DBaseTexture_Release(retTexture
);
1357 WARN("Call to get texture (%d) failed (%p)\n", Stage
, retTexture
);
1361 wined3d_mutex_unlock();
1366 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
* pTexture
) {
1367 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1369 TRACE("(%p) Relay %d %p\n" , This
, Stage
, pTexture
);
1371 wined3d_mutex_lock();
1372 hr
= IWineD3DDevice_SetTexture(This
->WineD3DDevice
, Stage
,
1373 pTexture
==NULL
? NULL
:((IDirect3DBaseTexture9Impl
*)pTexture
)->wineD3DBaseTexture
);
1374 wined3d_mutex_unlock();
1379 static const WINED3DTEXTURESTAGESTATETYPE tss_lookup
[] =
1381 WINED3DTSS_FORCE_DWORD
, /* 0, unused */
1382 WINED3DTSS_COLOROP
, /* 1, D3DTSS_COLOROP */
1383 WINED3DTSS_COLORARG1
, /* 2, D3DTSS_COLORARG1 */
1384 WINED3DTSS_COLORARG2
, /* 3, D3DTSS_COLORARG2 */
1385 WINED3DTSS_ALPHAOP
, /* 4, D3DTSS_ALPHAOP */
1386 WINED3DTSS_ALPHAARG1
, /* 5, D3DTSS_ALPHAARG1 */
1387 WINED3DTSS_ALPHAARG2
, /* 6, D3DTSS_ALPHAARG2 */
1388 WINED3DTSS_BUMPENVMAT00
, /* 7, D3DTSS_BUMPENVMAT00 */
1389 WINED3DTSS_BUMPENVMAT01
, /* 8, D3DTSS_BUMPENVMAT01 */
1390 WINED3DTSS_BUMPENVMAT10
, /* 9, D3DTSS_BUMPENVMAT10 */
1391 WINED3DTSS_BUMPENVMAT11
, /* 10, D3DTSS_BUMPENVMAT11 */
1392 WINED3DTSS_TEXCOORDINDEX
, /* 11, D3DTSS_TEXCOORDINDEX */
1393 WINED3DTSS_FORCE_DWORD
, /* 12, unused */
1394 WINED3DTSS_FORCE_DWORD
, /* 13, unused */
1395 WINED3DTSS_FORCE_DWORD
, /* 14, unused */
1396 WINED3DTSS_FORCE_DWORD
, /* 15, unused */
1397 WINED3DTSS_FORCE_DWORD
, /* 16, unused */
1398 WINED3DTSS_FORCE_DWORD
, /* 17, unused */
1399 WINED3DTSS_FORCE_DWORD
, /* 18, unused */
1400 WINED3DTSS_FORCE_DWORD
, /* 19, unused */
1401 WINED3DTSS_FORCE_DWORD
, /* 20, unused */
1402 WINED3DTSS_FORCE_DWORD
, /* 21, unused */
1403 WINED3DTSS_BUMPENVLSCALE
, /* 22, D3DTSS_BUMPENVLSCALE */
1404 WINED3DTSS_BUMPENVLOFFSET
, /* 23, D3DTSS_BUMPENVLOFFSET */
1405 WINED3DTSS_TEXTURETRANSFORMFLAGS
, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
1406 WINED3DTSS_FORCE_DWORD
, /* 25, unused */
1407 WINED3DTSS_COLORARG0
, /* 26, D3DTSS_COLORARG0 */
1408 WINED3DTSS_ALPHAARG0
, /* 27, D3DTSS_ALPHAARG0 */
1409 WINED3DTSS_RESULTARG
, /* 28, D3DTSS_RESULTARG */
1410 WINED3DTSS_FORCE_DWORD
, /* 29, unused */
1411 WINED3DTSS_FORCE_DWORD
, /* 30, unused */
1412 WINED3DTSS_FORCE_DWORD
, /* 31, unused */
1413 WINED3DTSS_CONSTANT
, /* 32, D3DTSS_CONSTANT */
1416 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD
* pValue
) {
1417 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1419 TRACE("(%p) Relay\n" , This
);
1421 wined3d_mutex_lock();
1422 hr
= IWineD3DDevice_GetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], pValue
);
1423 wined3d_mutex_unlock();
1428 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD Value
) {
1429 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1431 TRACE("(%p) Relay\n" , This
);
1433 wined3d_mutex_lock();
1434 hr
= IWineD3DDevice_SetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], Value
);
1435 wined3d_mutex_unlock();
1440 static HRESULT WINAPI
IDirect3DDevice9Impl_GetSamplerState(IDirect3DDevice9Ex
*iface
, DWORD Sampler
,
1441 D3DSAMPLERSTATETYPE Type
, DWORD
*pValue
)
1443 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1445 TRACE("(%p) Relay\n" , This
);
1447 wined3d_mutex_lock();
1448 hr
= IWineD3DDevice_GetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, pValue
);
1449 wined3d_mutex_unlock();
1454 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD Value
) {
1455 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1457 TRACE("(%p) Relay\n" , This
);
1459 wined3d_mutex_lock();
1460 hr
= IWineD3DDevice_SetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, Value
);
1461 wined3d_mutex_unlock();
1466 static HRESULT WINAPI
IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9EX iface
, DWORD
* pNumPasses
) {
1467 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1469 TRACE("(%p) Relay\n" , This
);
1471 wined3d_mutex_lock();
1472 hr
= IWineD3DDevice_ValidateDevice(This
->WineD3DDevice
, pNumPasses
);
1473 wined3d_mutex_unlock();
1478 static HRESULT WINAPI
IDirect3DDevice9Impl_SetPaletteEntries(IDirect3DDevice9Ex
*iface
, UINT PaletteNumber
,
1479 const PALETTEENTRY
*pEntries
)
1481 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1483 TRACE("(%p) Relay\n" , This
);
1485 wined3d_mutex_lock();
1486 hr
= IWineD3DDevice_SetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1487 wined3d_mutex_unlock();
1492 static HRESULT WINAPI
IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
, PALETTEENTRY
* pEntries
) {
1493 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1495 TRACE("(%p) Relay\n" , This
);
1497 wined3d_mutex_lock();
1498 hr
= IWineD3DDevice_GetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1499 wined3d_mutex_unlock();
1504 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
) {
1505 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1507 TRACE("(%p) Relay\n" , This
);
1509 wined3d_mutex_lock();
1510 hr
= IWineD3DDevice_SetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1511 wined3d_mutex_unlock();
1516 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT
* PaletteNumber
) {
1517 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1519 TRACE("(%p) Relay\n" , This
);
1521 wined3d_mutex_lock();
1522 hr
= IWineD3DDevice_GetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1523 wined3d_mutex_unlock();
1528 static HRESULT WINAPI
IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9EX iface
, CONST RECT
* pRect
) {
1529 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1531 TRACE("(%p) Relay\n" , This
);
1533 wined3d_mutex_lock();
1534 hr
= IWineD3DDevice_SetScissorRect(This
->WineD3DDevice
, pRect
);
1535 wined3d_mutex_unlock();
1540 static HRESULT WINAPI
IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9EX iface
, RECT
* pRect
) {
1541 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1543 TRACE("(%p) Relay\n" , This
);
1545 wined3d_mutex_lock();
1546 hr
= IWineD3DDevice_GetScissorRect(This
->WineD3DDevice
, pRect
);
1547 wined3d_mutex_unlock();
1552 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
, BOOL bSoftware
) {
1553 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1555 TRACE("(%p) Relay\n" , This
);
1557 wined3d_mutex_lock();
1558 hr
= IWineD3DDevice_SetSoftwareVertexProcessing(This
->WineD3DDevice
, bSoftware
);
1559 wined3d_mutex_unlock();
1564 static BOOL WINAPI
IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
) {
1565 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1567 TRACE("(%p) Relay\n" , This
);
1569 wined3d_mutex_lock();
1570 ret
= IWineD3DDevice_GetSoftwareVertexProcessing(This
->WineD3DDevice
);
1571 wined3d_mutex_unlock();
1576 static HRESULT WINAPI
IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9EX iface
, float nSegments
) {
1577 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1579 TRACE("(%p) Relay\n" , This
);
1581 wined3d_mutex_lock();
1582 hr
= IWineD3DDevice_SetNPatchMode(This
->WineD3DDevice
, nSegments
);
1583 wined3d_mutex_unlock();
1588 static float WINAPI
IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9EX iface
) {
1589 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1591 TRACE("(%p) Relay\n" , This
);
1593 wined3d_mutex_lock();
1594 ret
= IWineD3DDevice_GetNPatchMode(This
->WineD3DDevice
);
1595 wined3d_mutex_unlock();
1600 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitive(IDirect3DDevice9Ex
*iface
, D3DPRIMITIVETYPE PrimitiveType
,
1601 UINT StartVertex
, UINT PrimitiveCount
)
1603 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1605 TRACE("(%p) Relay\n" , This
);
1607 wined3d_mutex_lock();
1608 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1609 hr
= IWineD3DDevice_DrawPrimitive(This
->WineD3DDevice
, StartVertex
,
1610 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
));
1611 wined3d_mutex_unlock();
1616 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
,
1617 INT BaseVertexIndex
, UINT MinVertexIndex
, UINT NumVertices
, UINT startIndex
, UINT primCount
) {
1618 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1620 TRACE("(%p) Relay\n" , This
);
1622 /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
1623 wined3d_mutex_lock();
1624 IWineD3DDevice_SetBaseVertexIndex(This
->WineD3DDevice
, BaseVertexIndex
);
1625 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1626 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->WineD3DDevice
, startIndex
,
1627 vertex_count_from_primitive_count(PrimitiveType
, primCount
));
1628 wined3d_mutex_unlock();
1633 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitiveUP(IDirect3DDevice9Ex
*iface
, D3DPRIMITIVETYPE PrimitiveType
,
1634 UINT PrimitiveCount
, const void *pVertexStreamZeroData
, UINT VertexStreamZeroStride
)
1636 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1638 TRACE("(%p) Relay\n" , This
);
1640 wined3d_mutex_lock();
1641 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1642 hr
= IWineD3DDevice_DrawPrimitiveUP(This
->WineD3DDevice
,
1643 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
),
1644 pVertexStreamZeroData
, VertexStreamZeroStride
);
1645 wined3d_mutex_unlock();
1650 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT MinVertexIndex
,
1651 UINT NumVertexIndices
, UINT PrimitiveCount
, CONST
void* pIndexData
,
1652 D3DFORMAT IndexDataFormat
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1653 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1655 TRACE("(%p) Relay\n" , This
);
1657 wined3d_mutex_lock();
1658 IWineD3DDevice_SetPrimitiveType(This
->WineD3DDevice
, PrimitiveType
);
1659 hr
= IWineD3DDevice_DrawIndexedPrimitiveUP(This
->WineD3DDevice
,
1660 vertex_count_from_primitive_count(PrimitiveType
, PrimitiveCount
), pIndexData
,
1661 wined3dformat_from_d3dformat(IndexDataFormat
), pVertexStreamZeroData
, VertexStreamZeroStride
);
1662 wined3d_mutex_unlock();
1667 static HRESULT WINAPI
IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX iface
, UINT SrcStartIndex
, UINT DestIndex
, UINT VertexCount
, IDirect3DVertexBuffer9
* pDestBuffer
, IDirect3DVertexDeclaration9
* pVertexDecl
, DWORD Flags
) {
1668 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1669 IDirect3DVertexDeclaration9Impl
*Decl
= (IDirect3DVertexDeclaration9Impl
*) pVertexDecl
;
1671 IDirect3DVertexBuffer9Impl
*dest
= (IDirect3DVertexBuffer9Impl
*) pDestBuffer
;
1672 TRACE("(%p) Relay\n" , This
);
1674 wined3d_mutex_lock();
1675 hr
= IWineD3DDevice_ProcessVertices(This
->WineD3DDevice
,SrcStartIndex
, DestIndex
, VertexCount
, dest
->wineD3DVertexBuffer
, Decl
? Decl
->wineD3DVertexDeclaration
: NULL
, Flags
, dest
->fvf
);
1676 wined3d_mutex_unlock();
1681 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateVertexDeclaration(IDirect3DDevice9Ex
*iface
,
1682 const D3DVERTEXELEMENT9
*elements
, IDirect3DVertexDeclaration9
**declaration
)
1684 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1685 IDirect3DVertexDeclaration9Impl
*object
;
1688 TRACE("iface %p, elements %p, declaration %p.\n", iface
, elements
, declaration
);
1692 WARN("Caller passed a NULL declaration, returning D3DERR_INVALIDCALL.\n");
1693 return D3DERR_INVALIDCALL
;
1696 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
1699 ERR("Failed to allocate vertex declaration memory.\n");
1700 return E_OUTOFMEMORY
;
1703 hr
= vertexdeclaration_init(object
, This
, elements
);
1706 WARN("Failed to initialize vertex declaration, hr %#x.\n", hr
);
1707 HeapFree(GetProcessHeap(), 0, object
);
1711 TRACE("Created vertex declaration %p.\n", object
);
1712 *declaration
= (IDirect3DVertexDeclaration9
*)object
;
1717 static IDirect3DVertexDeclaration9
*getConvertedDecl(IDirect3DDevice9Impl
*This
, DWORD fvf
) {
1719 D3DVERTEXELEMENT9
* elements
= NULL
;
1720 IDirect3DVertexDeclaration9
* pDecl
= NULL
;
1721 int p
, low
, high
; /* deliberately signed */
1722 IDirect3DVertexDeclaration9
**convertedDecls
= This
->convertedDecls
;
1724 TRACE("Searching for declaration for fvf %08x... ", fvf
);
1727 high
= This
->numConvertedDecls
- 1;
1728 while(low
<= high
) {
1729 p
= (low
+ high
) >> 1;
1731 if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
== fvf
) {
1732 TRACE("found %p\n", convertedDecls
[p
]);
1733 return convertedDecls
[p
];
1734 } else if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
< fvf
) {
1740 TRACE("not found. Creating and inserting at position %d.\n", low
);
1742 hr
= vdecl_convert_fvf(fvf
, &elements
);
1743 if (hr
!= S_OK
) return NULL
;
1745 hr
= IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9Ex
*) This
, elements
, &pDecl
);
1746 HeapFree(GetProcessHeap(), 0, elements
); /* CreateVertexDeclaration makes a copy */
1747 if (hr
!= S_OK
) return NULL
;
1749 if(This
->declArraySize
== This
->numConvertedDecls
) {
1750 int grow
= max(This
->declArraySize
/ 2, 8);
1751 convertedDecls
= HeapReAlloc(GetProcessHeap(), 0, convertedDecls
,
1752 sizeof(convertedDecls
[0]) * (This
->numConvertedDecls
+ grow
));
1753 if(!convertedDecls
) {
1754 /* This will destroy it */
1755 IDirect3DVertexDeclaration9_Release(pDecl
);
1758 This
->convertedDecls
= convertedDecls
;
1759 This
->declArraySize
+= grow
;
1762 memmove(convertedDecls
+ low
+ 1, convertedDecls
+ low
, sizeof(IDirect3DVertexDeclaration9Impl
*) * (This
->numConvertedDecls
- low
));
1763 convertedDecls
[low
] = pDecl
;
1764 This
->numConvertedDecls
++;
1766 /* Will prevent the decl from being destroyed */
1767 ((IDirect3DVertexDeclaration9Impl
*) pDecl
)->convFVF
= fvf
;
1768 IDirect3DVertexDeclaration9_Release(pDecl
); /* Does not destroy now */
1770 TRACE("Returning %p. %d decls in array\n", pDecl
, This
->numConvertedDecls
);
1774 static HRESULT WINAPI
IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface
, DWORD FVF
) {
1775 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1776 IDirect3DVertexDeclaration9
*decl
;
1779 TRACE("(%p) Relay\n" , This
);
1783 WARN("%#x is not a valid FVF\n", FVF
);
1787 wined3d_mutex_lock();
1788 decl
= getConvertedDecl(This
, FVF
);
1789 wined3d_mutex_unlock();
1793 /* Any situation when this should happen, except out of memory? */
1794 ERR("Failed to create a converted vertex declaration\n");
1795 return D3DERR_DRIVERINTERNALERROR
;
1798 hr
= IDirect3DDevice9Impl_SetVertexDeclaration(iface
, decl
);
1799 if (FAILED(hr
)) ERR("Failed to set vertex declaration\n");
1804 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface
, DWORD
* pFVF
) {
1805 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1806 IDirect3DVertexDeclaration9
*decl
;
1808 TRACE("(%p) Relay\n" , This
);
1810 hr
= IDirect3DDevice9_GetVertexDeclaration(iface
, &decl
);
1813 WARN("Failed to get vertex declaration, %#x\n", hr
);
1820 *pFVF
= ((IDirect3DVertexDeclaration9Impl
*)decl
)->convFVF
;
1821 IDirect3DVertexDeclaration9_Release(decl
);
1828 TRACE("Returning FVF %#x\n", *pFVF
);
1833 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateVertexShader(IDirect3DDevice9Ex
*iface
,
1834 const DWORD
*byte_code
, IDirect3DVertexShader9
**shader
)
1836 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1837 IDirect3DVertexShader9Impl
*object
;
1840 TRACE("iface %p, byte_code %p, shader %p.\n", iface
, byte_code
, shader
);
1842 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
1845 ERR("Failed to allocate vertex shader memory.\n");
1846 return E_OUTOFMEMORY
;
1849 hr
= vertexshader_init(object
, This
, byte_code
);
1852 WARN("Failed to initialize vertex shader, hr %#x.\n", hr
);
1853 HeapFree(GetProcessHeap(), 0, object
);
1857 TRACE("Created vertex shader %p.\n", object
);
1858 *shader
= (IDirect3DVertexShader9
*)object
;
1863 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
* pStreamData
, UINT OffsetInBytes
, UINT Stride
) {
1864 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1866 TRACE("(%p) Relay\n" , This
);
1868 wined3d_mutex_lock();
1869 hr
= IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, StreamNumber
,
1870 pStreamData
? ((IDirect3DVertexBuffer9Impl
*)pStreamData
)->wineD3DVertexBuffer
: NULL
,
1871 OffsetInBytes
, Stride
);
1872 wined3d_mutex_unlock();
1877 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
**pStream
, UINT
* OffsetInBytes
, UINT
* pStride
) {
1878 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1879 IWineD3DBuffer
*retStream
= NULL
;
1880 HRESULT rc
= D3D_OK
;
1882 TRACE("(%p) Relay\n" , This
);
1884 if(pStream
== NULL
){
1885 return D3DERR_INVALIDCALL
;
1888 wined3d_mutex_lock();
1889 rc
= IWineD3DDevice_GetStreamSource(This
->WineD3DDevice
, StreamNumber
, &retStream
, OffsetInBytes
, pStride
);
1890 if (rc
== D3D_OK
&& NULL
!= retStream
) {
1891 IWineD3DBuffer_GetParent(retStream
, (IUnknown
**)pStream
);
1892 IWineD3DBuffer_Release(retStream
);
1895 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes
, pStride
);
1899 wined3d_mutex_unlock();
1904 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSourceFreq(IDirect3DDevice9Ex
*iface
, UINT StreamNumber
,
1907 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1909 TRACE("(%p) Relay\n" , This
);
1911 wined3d_mutex_lock();
1912 hr
= IWineD3DDevice_SetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1913 wined3d_mutex_unlock();
1918 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, UINT
* Divider
) {
1919 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1921 TRACE("(%p) Relay\n" , This
);
1923 wined3d_mutex_lock();
1924 hr
= IWineD3DDevice_GetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1925 wined3d_mutex_unlock();
1930 static HRESULT WINAPI
IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
* pIndexData
) {
1931 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1933 IDirect3DIndexBuffer9Impl
*ib
= (IDirect3DIndexBuffer9Impl
*) pIndexData
;
1934 TRACE("(%p) Relay\n", This
);
1936 wined3d_mutex_lock();
1937 hr
= IWineD3DDevice_SetIndices(This
->WineD3DDevice
,
1938 ib
? ib
->wineD3DIndexBuffer
: NULL
,
1939 ib
? ib
->format
: WINED3DFMT_UNKNOWN
);
1940 wined3d_mutex_unlock();
1945 static HRESULT WINAPI
IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
**ppIndexData
) {
1946 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1947 IWineD3DBuffer
*retIndexData
= NULL
;
1948 HRESULT rc
= D3D_OK
;
1950 TRACE("(%p) Relay\n", This
);
1952 if(ppIndexData
== NULL
){
1953 return D3DERR_INVALIDCALL
;
1956 wined3d_mutex_lock();
1957 rc
= IWineD3DDevice_GetIndices(This
->WineD3DDevice
, &retIndexData
);
1958 if (SUCCEEDED(rc
) && retIndexData
) {
1959 IWineD3DBuffer_GetParent(retIndexData
, (IUnknown
**)ppIndexData
);
1960 IWineD3DBuffer_Release(retIndexData
);
1962 if (FAILED(rc
)) FIXME("Call to GetIndices failed\n");
1963 *ppIndexData
= NULL
;
1965 wined3d_mutex_unlock();
1970 static HRESULT WINAPI
IDirect3DDevice9Impl_CreatePixelShader(IDirect3DDevice9Ex
*iface
,
1971 const DWORD
*byte_code
, IDirect3DPixelShader9
**shader
)
1973 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1974 IDirect3DPixelShader9Impl
*object
;
1977 TRACE("iface %p, byte_code %p, shader %p.\n", iface
, byte_code
, shader
);
1979 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
1982 FIXME("Failed to allocate pixel shader memory.\n");
1983 return E_OUTOFMEMORY
;
1986 hr
= pixelshader_init(object
, This
, byte_code
);
1989 WARN("Failed to initialize pixel shader, hr %#x.\n", hr
);
1990 HeapFree(GetProcessHeap(), 0, object
);
1994 TRACE("Created pixel shader %p.\n", object
);
1995 *shader
= (IDirect3DPixelShader9
*)object
;
2000 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DRECTPATCH_INFO
* pRectPatchInfo
) {
2001 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2003 TRACE("(%p) Relay\n", This
);
2005 wined3d_mutex_lock();
2006 hr
= IWineD3DDevice_DrawRectPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DRECTPATCH_INFO
*)pRectPatchInfo
);
2007 wined3d_mutex_unlock();
2012 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DTRIPATCH_INFO
* pTriPatchInfo
) {
2013 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2015 TRACE("(%p) Relay\n", This
);
2017 wined3d_mutex_lock();
2018 hr
= IWineD3DDevice_DrawTriPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DTRIPATCH_INFO
*)pTriPatchInfo
);
2019 wined3d_mutex_unlock();
2024 static HRESULT WINAPI
IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
) {
2025 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
2027 TRACE("(%p) Relay\n", This
);
2029 wined3d_mutex_lock();
2030 hr
= IWineD3DDevice_DeletePatch(This
->WineD3DDevice
, Handle
);
2031 wined3d_mutex_unlock();
2036 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(LPDIRECT3DDEVICE9EX iface
, UINT width
, UINT height
, float *rows
, float *columns
) {
2037 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2038 FIXME("(%p)->(%d, %d, %p, %p) Stub!\n", This
, width
, height
, rows
, columns
);
2039 return WINED3DERR_INVALIDCALL
;
2042 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ComposeRects(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
*pSrc
, IDirect3DDevice9
*pDst
, IDirect3DVertexBuffer9
*pSrcRectDescs
, UINT NumRects
, IDirect3DVertexBuffer9
*pDstRectDescs
, D3DCOMPOSERECTSOP Operation
, int Xoffset
, int Yoffset
) {
2043 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2044 FIXME("(%p)->(%p, %p, %p, %d, %p, %d, %d, %d) Stub!\n", This
, pSrc
, pDst
, pSrcRectDescs
, NumRects
, pDstRectDescs
, Operation
, Xoffset
, Yoffset
);
2045 return WINED3DERR_INVALIDCALL
;
2048 static HRESULT WINAPI
IDirect3DDevice9ExImpl_PresentEx(LPDIRECT3DDEVICE9EX iface
, CONST RECT
*pSourceRect
, CONST RECT
*pDestRect
, HWND hDestWindowOverride
, CONST RGNDATA
*pDirtyRegion
, DWORD dwFlags
) {
2049 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2050 FIXME("(%p= -> (%p), %p, %p, %p, 0x%08x) Stub!\n", This
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
, dwFlags
);
2051 return WINED3DERR_INVALIDCALL
;
2054 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface
, INT
*pPriority
) {
2055 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2056 FIXME("(%p)->(%p) Stub!\n", This
, pPriority
);
2057 return WINED3DERR_INVALIDCALL
;
2060 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface
, INT Priority
) {
2061 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2062 FIXME("(%p)->(%d) Stub!\n", This
, Priority
);
2063 return WINED3DERR_INVALIDCALL
;
2066 static HRESULT WINAPI
IDirect3DDevice9ExImpl_WaitForVBlank(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
) {
2067 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2068 FIXME("(%p)->(%d) Stub!\n", This
, iSwapChain
);
2069 return WINED3DERR_INVALIDCALL
;
2072 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckresourceResidency(LPDIRECT3DDEVICE9EX iface
, IDirect3DResource9
** pResourceArray
, UINT32 Numresources
) {
2073 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2074 FIXME("(%p)->(%p, %d) Stub!\n", This
, pResourceArray
, Numresources
);
2075 return WINED3DERR_INVALIDCALL
;
2078 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface
, UINT MaxLatency
) {
2079 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2080 FIXME("(%p)->(%d) Stub!\n", This
, MaxLatency
);
2081 return WINED3DERR_INVALIDCALL
;
2084 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface
, UINT
*pMaxLatency
) {
2085 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2086 FIXME("(%p)->(%p) Stub!\n", This
, pMaxLatency
);
2088 return WINED3DERR_INVALIDCALL
;
2091 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckdeviceState(LPDIRECT3DDEVICE9EX iface
, HWND hDestinationWindow
) {
2092 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2093 FIXME("(%p)->(%p) Stub!\n", This
, hDestinationWindow
);
2094 return WINED3DERR_INVALIDCALL
;
2097 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
) {
2098 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2099 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
);
2100 return WINED3DERR_INVALIDCALL
;
2103 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
*pSharedHandle
, DWORD Usage
) {
2104 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2105 FIXME("(%p)->(%d, %d, %d, %d, %p, %p, 0x%08x) Stub!\n", This
, Width
, Height
, Format
, Pool
, ppSurface
, pSharedHandle
, Usage
);
2106 return WINED3DERR_INVALIDCALL
;
2109 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
) {
2110 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2111 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
);
2112 return WINED3DERR_INVALIDCALL
;
2115 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ResetEx(LPDIRECT3DDEVICE9EX iface
, D3DPRESENT_PARAMETERS
*pPresentationParameters
, D3DDISPLAYMODEEX
*pFullscreenDisplayMode
) {
2116 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2117 FIXME("(%p)->(%p) Stub!\n", This
, pPresentationParameters
);
2118 return WINED3DERR_INVALIDCALL
;
2121 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetDisplayModeEx(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DDISPLAYMODEEX
*pMode
, D3DDISPLAYROTATION
*pRotation
) {
2122 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
2123 FIXME("(%p)->(%d, %p, %p) Stub!\n", This
, iSwapChain
, pMode
, pRotation
);
2124 return WINED3DERR_INVALIDCALL
;
2127 const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl
=
2130 IDirect3DDevice9Impl_QueryInterface
,
2131 IDirect3DDevice9Impl_AddRef
,
2132 IDirect3DDevice9Impl_Release
,
2133 /* IDirect3DDevice9 */
2134 IDirect3DDevice9Impl_TestCooperativeLevel
,
2135 IDirect3DDevice9Impl_GetAvailableTextureMem
,
2136 IDirect3DDevice9Impl_EvictManagedResources
,
2137 IDirect3DDevice9Impl_GetDirect3D
,
2138 IDirect3DDevice9Impl_GetDeviceCaps
,
2139 IDirect3DDevice9Impl_GetDisplayMode
,
2140 IDirect3DDevice9Impl_GetCreationParameters
,
2141 IDirect3DDevice9Impl_SetCursorProperties
,
2142 IDirect3DDevice9Impl_SetCursorPosition
,
2143 IDirect3DDevice9Impl_ShowCursor
,
2144 IDirect3DDevice9Impl_CreateAdditionalSwapChain
,
2145 IDirect3DDevice9Impl_GetSwapChain
,
2146 IDirect3DDevice9Impl_GetNumberOfSwapChains
,
2147 IDirect3DDevice9Impl_Reset
,
2148 IDirect3DDevice9Impl_Present
,
2149 IDirect3DDevice9Impl_GetBackBuffer
,
2150 IDirect3DDevice9Impl_GetRasterStatus
,
2151 IDirect3DDevice9Impl_SetDialogBoxMode
,
2152 IDirect3DDevice9Impl_SetGammaRamp
,
2153 IDirect3DDevice9Impl_GetGammaRamp
,
2154 IDirect3DDevice9Impl_CreateTexture
,
2155 IDirect3DDevice9Impl_CreateVolumeTexture
,
2156 IDirect3DDevice9Impl_CreateCubeTexture
,
2157 IDirect3DDevice9Impl_CreateVertexBuffer
,
2158 IDirect3DDevice9Impl_CreateIndexBuffer
,
2159 IDirect3DDevice9Impl_CreateRenderTarget
,
2160 IDirect3DDevice9Impl_CreateDepthStencilSurface
,
2161 IDirect3DDevice9Impl_UpdateSurface
,
2162 IDirect3DDevice9Impl_UpdateTexture
,
2163 IDirect3DDevice9Impl_GetRenderTargetData
,
2164 IDirect3DDevice9Impl_GetFrontBufferData
,
2165 IDirect3DDevice9Impl_StretchRect
,
2166 IDirect3DDevice9Impl_ColorFill
,
2167 IDirect3DDevice9Impl_CreateOffscreenPlainSurface
,
2168 IDirect3DDevice9Impl_SetRenderTarget
,
2169 IDirect3DDevice9Impl_GetRenderTarget
,
2170 IDirect3DDevice9Impl_SetDepthStencilSurface
,
2171 IDirect3DDevice9Impl_GetDepthStencilSurface
,
2172 IDirect3DDevice9Impl_BeginScene
,
2173 IDirect3DDevice9Impl_EndScene
,
2174 IDirect3DDevice9Impl_Clear
,
2175 IDirect3DDevice9Impl_SetTransform
,
2176 IDirect3DDevice9Impl_GetTransform
,
2177 IDirect3DDevice9Impl_MultiplyTransform
,
2178 IDirect3DDevice9Impl_SetViewport
,
2179 IDirect3DDevice9Impl_GetViewport
,
2180 IDirect3DDevice9Impl_SetMaterial
,
2181 IDirect3DDevice9Impl_GetMaterial
,
2182 IDirect3DDevice9Impl_SetLight
,
2183 IDirect3DDevice9Impl_GetLight
,
2184 IDirect3DDevice9Impl_LightEnable
,
2185 IDirect3DDevice9Impl_GetLightEnable
,
2186 IDirect3DDevice9Impl_SetClipPlane
,
2187 IDirect3DDevice9Impl_GetClipPlane
,
2188 IDirect3DDevice9Impl_SetRenderState
,
2189 IDirect3DDevice9Impl_GetRenderState
,
2190 IDirect3DDevice9Impl_CreateStateBlock
,
2191 IDirect3DDevice9Impl_BeginStateBlock
,
2192 IDirect3DDevice9Impl_EndStateBlock
,
2193 IDirect3DDevice9Impl_SetClipStatus
,
2194 IDirect3DDevice9Impl_GetClipStatus
,
2195 IDirect3DDevice9Impl_GetTexture
,
2196 IDirect3DDevice9Impl_SetTexture
,
2197 IDirect3DDevice9Impl_GetTextureStageState
,
2198 IDirect3DDevice9Impl_SetTextureStageState
,
2199 IDirect3DDevice9Impl_GetSamplerState
,
2200 IDirect3DDevice9Impl_SetSamplerState
,
2201 IDirect3DDevice9Impl_ValidateDevice
,
2202 IDirect3DDevice9Impl_SetPaletteEntries
,
2203 IDirect3DDevice9Impl_GetPaletteEntries
,
2204 IDirect3DDevice9Impl_SetCurrentTexturePalette
,
2205 IDirect3DDevice9Impl_GetCurrentTexturePalette
,
2206 IDirect3DDevice9Impl_SetScissorRect
,
2207 IDirect3DDevice9Impl_GetScissorRect
,
2208 IDirect3DDevice9Impl_SetSoftwareVertexProcessing
,
2209 IDirect3DDevice9Impl_GetSoftwareVertexProcessing
,
2210 IDirect3DDevice9Impl_SetNPatchMode
,
2211 IDirect3DDevice9Impl_GetNPatchMode
,
2212 IDirect3DDevice9Impl_DrawPrimitive
,
2213 IDirect3DDevice9Impl_DrawIndexedPrimitive
,
2214 IDirect3DDevice9Impl_DrawPrimitiveUP
,
2215 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP
,
2216 IDirect3DDevice9Impl_ProcessVertices
,
2217 IDirect3DDevice9Impl_CreateVertexDeclaration
,
2218 IDirect3DDevice9Impl_SetVertexDeclaration
,
2219 IDirect3DDevice9Impl_GetVertexDeclaration
,
2220 IDirect3DDevice9Impl_SetFVF
,
2221 IDirect3DDevice9Impl_GetFVF
,
2222 IDirect3DDevice9Impl_CreateVertexShader
,
2223 IDirect3DDevice9Impl_SetVertexShader
,
2224 IDirect3DDevice9Impl_GetVertexShader
,
2225 IDirect3DDevice9Impl_SetVertexShaderConstantF
,
2226 IDirect3DDevice9Impl_GetVertexShaderConstantF
,
2227 IDirect3DDevice9Impl_SetVertexShaderConstantI
,
2228 IDirect3DDevice9Impl_GetVertexShaderConstantI
,
2229 IDirect3DDevice9Impl_SetVertexShaderConstantB
,
2230 IDirect3DDevice9Impl_GetVertexShaderConstantB
,
2231 IDirect3DDevice9Impl_SetStreamSource
,
2232 IDirect3DDevice9Impl_GetStreamSource
,
2233 IDirect3DDevice9Impl_SetStreamSourceFreq
,
2234 IDirect3DDevice9Impl_GetStreamSourceFreq
,
2235 IDirect3DDevice9Impl_SetIndices
,
2236 IDirect3DDevice9Impl_GetIndices
,
2237 IDirect3DDevice9Impl_CreatePixelShader
,
2238 IDirect3DDevice9Impl_SetPixelShader
,
2239 IDirect3DDevice9Impl_GetPixelShader
,
2240 IDirect3DDevice9Impl_SetPixelShaderConstantF
,
2241 IDirect3DDevice9Impl_GetPixelShaderConstantF
,
2242 IDirect3DDevice9Impl_SetPixelShaderConstantI
,
2243 IDirect3DDevice9Impl_GetPixelShaderConstantI
,
2244 IDirect3DDevice9Impl_SetPixelShaderConstantB
,
2245 IDirect3DDevice9Impl_GetPixelShaderConstantB
,
2246 IDirect3DDevice9Impl_DrawRectPatch
,
2247 IDirect3DDevice9Impl_DrawTriPatch
,
2248 IDirect3DDevice9Impl_DeletePatch
,
2249 IDirect3DDevice9Impl_CreateQuery
,
2250 /* IDirect3DDevice9Ex */
2251 IDirect3DDevice9ExImpl_SetConvolutionMonoKernel
,
2252 IDirect3DDevice9ExImpl_ComposeRects
,
2253 IDirect3DDevice9ExImpl_PresentEx
,
2254 IDirect3DDevice9ExImpl_GetGPUThreadPriority
,
2255 IDirect3DDevice9ExImpl_SetGPUThreadPriority
,
2256 IDirect3DDevice9ExImpl_WaitForVBlank
,
2257 IDirect3DDevice9ExImpl_CheckresourceResidency
,
2258 IDirect3DDevice9ExImpl_SetMaximumFrameLatency
,
2259 IDirect3DDevice9ExImpl_GetMaximumFrameLatency
,
2260 IDirect3DDevice9ExImpl_CheckdeviceState
,
2261 IDirect3DDevice9ExImpl_CreateRenderTargetEx
,
2262 IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx
,
2263 IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx
,
2264 IDirect3DDevice9ExImpl_ResetEx
,
2265 IDirect3DDevice9ExImpl_GetDisplayModeEx
2268 /* IWineD3DDeviceParent IUnknown methods */
2270 static inline struct IDirect3DDevice9Impl
*device_from_device_parent(IWineD3DDeviceParent
*iface
)
2272 return (struct IDirect3DDevice9Impl
*)((char*)iface
2273 - FIELD_OFFSET(struct IDirect3DDevice9Impl
, device_parent_vtbl
));
2276 static HRESULT STDMETHODCALLTYPE
device_parent_QueryInterface(IWineD3DDeviceParent
*iface
, REFIID riid
, void **object
)
2278 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2279 return IDirect3DDevice9Impl_QueryInterface((IDirect3DDevice9Ex
*)This
, riid
, object
);
2282 static ULONG STDMETHODCALLTYPE
device_parent_AddRef(IWineD3DDeviceParent
*iface
)
2284 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2285 return IDirect3DDevice9Impl_AddRef((IDirect3DDevice9Ex
*)This
);
2288 static ULONG STDMETHODCALLTYPE
device_parent_Release(IWineD3DDeviceParent
*iface
)
2290 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2291 return IDirect3DDevice9Impl_Release((IDirect3DDevice9Ex
*)This
);
2294 /* IWineD3DDeviceParent methods */
2296 static void STDMETHODCALLTYPE
device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent
*iface
, IWineD3DDevice
*device
)
2298 TRACE("iface %p, device %p\n", iface
, device
);
2301 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSurface(IWineD3DDeviceParent
*iface
,
2302 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, DWORD usage
,
2303 WINED3DPOOL pool
, UINT level
, WINED3DCUBEMAP_FACES face
, IWineD3DSurface
**surface
)
2305 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2306 IDirect3DSurface9Impl
*d3d_surface
;
2307 BOOL lockable
= TRUE
;
2310 TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
2311 "\tpool %#x, level %u, face %u, surface %p\n",
2312 iface
, superior
, width
, height
, format
, usage
, pool
, level
, face
, surface
);
2314 if (pool
== WINED3DPOOL_DEFAULT
&& !(usage
& D3DUSAGE_DYNAMIC
))
2317 hr
= IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex
*)This
, width
, height
,
2318 d3dformat_from_wined3dformat(format
), lockable
, FALSE
/* Discard */, level
,
2319 (IDirect3DSurface9
**)&d3d_surface
, usage
, pool
, D3DMULTISAMPLE_NONE
, 0 /* MultisampleQuality */);
2322 ERR("(%p) CreateSurface failed, returning %#x\n", iface
, hr
);
2326 *surface
= d3d_surface
->wineD3DSurface
;
2327 IWineD3DSurface_AddRef(*surface
);
2329 d3d_surface
->container
= superior
;
2330 IDirect3DDevice9Ex_Release(d3d_surface
->parentDevice
);
2331 d3d_surface
->parentDevice
= NULL
;
2333 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2334 d3d_surface
->forwardReference
= superior
;
2339 static HRESULT STDMETHODCALLTYPE
device_parent_CreateRenderTarget(IWineD3DDeviceParent
*iface
,
2340 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
2341 DWORD multisample_quality
, BOOL lockable
, IWineD3DSurface
**surface
)
2343 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2344 IDirect3DSurface9Impl
*d3d_surface
;
2347 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2348 "\tmultisample_quality %u, lockable %u, surface %p\n",
2349 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, lockable
, surface
);
2351 hr
= IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex
*)This
, width
, height
,
2352 d3dformat_from_wined3dformat(format
), multisample_type
, multisample_quality
, lockable
,
2353 (IDirect3DSurface9
**)&d3d_surface
, NULL
);
2356 ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface
, hr
);
2360 *surface
= d3d_surface
->wineD3DSurface
;
2361 IWineD3DSurface_AddRef(*surface
);
2363 d3d_surface
->container
= superior
;
2364 /* Implicit surfaces are created with an refcount of 0 */
2365 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2370 static HRESULT STDMETHODCALLTYPE
device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent
*iface
,
2371 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
2372 DWORD multisample_quality
, BOOL discard
, IWineD3DSurface
**surface
)
2374 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2375 IDirect3DSurface9Impl
*d3d_surface
;
2378 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2379 "\tmultisample_quality %u, discard %u, surface %p\n",
2380 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, discard
, surface
);
2382 hr
= IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex
*)This
, width
, height
,
2383 d3dformat_from_wined3dformat(format
), multisample_type
, multisample_quality
, discard
,
2384 (IDirect3DSurface9
**)&d3d_surface
, NULL
);
2387 ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface
, hr
);
2391 *surface
= d3d_surface
->wineD3DSurface
;
2392 IWineD3DSurface_AddRef(*surface
);
2393 d3d_surface
->container
= (IUnknown
*)This
;
2394 /* Implicit surfaces are created with an refcount of 0 */
2395 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
2400 static HRESULT STDMETHODCALLTYPE
device_parent_CreateVolume(IWineD3DDeviceParent
*iface
,
2401 IUnknown
*superior
, UINT width
, UINT height
, UINT depth
, WINED3DFORMAT format
,
2402 WINED3DPOOL pool
, DWORD usage
, IWineD3DVolume
**volume
)
2404 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2405 IDirect3DVolume9Impl
*object
;
2408 TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
2409 iface
, superior
, width
, height
, depth
, format
, pool
, usage
, volume
);
2411 /* Allocate the storage for the device */
2412 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
2415 FIXME("Allocation of memory failed\n");
2417 return D3DERR_OUTOFVIDEOMEMORY
;
2420 hr
= volume_init(object
, This
, width
, height
, depth
, usage
, format
, pool
);
2423 WARN("Failed to initialize volume, hr %#x.\n", hr
);
2424 HeapFree(GetProcessHeap(), 0, object
);
2428 *volume
= object
->wineD3DVolume
;
2429 IWineD3DVolume_AddRef(*volume
);
2430 IDirect3DVolume9_Release((IDirect3DVolume9
*)object
);
2432 object
->container
= superior
;
2433 object
->forwardReference
= superior
;
2435 TRACE("(%p) Created volume %p\n", iface
, object
);
2440 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSwapChain(IWineD3DDeviceParent
*iface
,
2441 WINED3DPRESENT_PARAMETERS
*present_parameters
, IWineD3DSwapChain
**swapchain
)
2443 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
2444 IDirect3DSwapChain9Impl
*d3d_swapchain
;
2445 D3DPRESENT_PARAMETERS local_parameters
;
2448 TRACE("iface %p, present_parameters %p, swapchain %p\n", iface
, present_parameters
, swapchain
);
2450 /* Copy the presentation parameters */
2451 local_parameters
.BackBufferWidth
= present_parameters
->BackBufferWidth
;
2452 local_parameters
.BackBufferHeight
= present_parameters
->BackBufferHeight
;
2453 local_parameters
.BackBufferFormat
= d3dformat_from_wined3dformat(present_parameters
->BackBufferFormat
);
2454 local_parameters
.BackBufferCount
= present_parameters
->BackBufferCount
;
2455 local_parameters
.MultiSampleType
= present_parameters
->MultiSampleType
;
2456 local_parameters
.MultiSampleQuality
= present_parameters
->MultiSampleQuality
;
2457 local_parameters
.SwapEffect
= present_parameters
->SwapEffect
;
2458 local_parameters
.hDeviceWindow
= present_parameters
->hDeviceWindow
;
2459 local_parameters
.Windowed
= present_parameters
->Windowed
;
2460 local_parameters
.EnableAutoDepthStencil
= present_parameters
->EnableAutoDepthStencil
;
2461 local_parameters
.AutoDepthStencilFormat
= d3dformat_from_wined3dformat(present_parameters
->AutoDepthStencilFormat
);
2462 local_parameters
.Flags
= present_parameters
->Flags
;
2463 local_parameters
.FullScreen_RefreshRateInHz
= present_parameters
->FullScreen_RefreshRateInHz
;
2464 local_parameters
.PresentationInterval
= present_parameters
->PresentationInterval
;
2466 hr
= IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex
*)This
,
2467 &local_parameters
, (IDirect3DSwapChain9
**)&d3d_swapchain
);
2470 ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface
, hr
);
2475 *swapchain
= d3d_swapchain
->wineD3DSwapChain
;
2476 d3d_swapchain
->isImplicit
= TRUE
;
2477 /* Implicit swap chains are created with an refcount of 0 */
2478 IDirect3DSwapChain9_Release((IDirect3DSwapChain9
*)d3d_swapchain
);
2480 /* Copy back the presentation parameters */
2481 present_parameters
->BackBufferWidth
= local_parameters
.BackBufferWidth
;
2482 present_parameters
->BackBufferHeight
= local_parameters
.BackBufferHeight
;
2483 present_parameters
->BackBufferFormat
= wined3dformat_from_d3dformat(local_parameters
.BackBufferFormat
);
2484 present_parameters
->BackBufferCount
= local_parameters
.BackBufferCount
;
2485 present_parameters
->MultiSampleType
= local_parameters
.MultiSampleType
;
2486 present_parameters
->MultiSampleQuality
= local_parameters
.MultiSampleQuality
;
2487 present_parameters
->SwapEffect
= local_parameters
.SwapEffect
;
2488 present_parameters
->hDeviceWindow
= local_parameters
.hDeviceWindow
;
2489 present_parameters
->Windowed
= local_parameters
.Windowed
;
2490 present_parameters
->EnableAutoDepthStencil
= local_parameters
.EnableAutoDepthStencil
;
2491 present_parameters
->AutoDepthStencilFormat
= wined3dformat_from_d3dformat(local_parameters
.AutoDepthStencilFormat
);
2492 present_parameters
->Flags
= local_parameters
.Flags
;
2493 present_parameters
->FullScreen_RefreshRateInHz
= local_parameters
.FullScreen_RefreshRateInHz
;
2494 present_parameters
->PresentationInterval
= local_parameters
.PresentationInterval
;
2499 const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl
=
2501 /* IUnknown methods */
2502 device_parent_QueryInterface
,
2503 device_parent_AddRef
,
2504 device_parent_Release
,
2505 /* IWineD3DDeviceParent methods */
2506 device_parent_WineD3DDeviceCreated
,
2507 device_parent_CreateSurface
,
2508 device_parent_CreateRenderTarget
,
2509 device_parent_CreateDepthStencilSurface
,
2510 device_parent_CreateVolume
,
2511 device_parent_CreateSwapChain
,