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
);
29 /* IDirect3D IUnknown parts follow: */
30 static HRESULT WINAPI
IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX iface
, REFIID riid
, LPVOID
* ppobj
) {
31 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
33 IDirect3D9Impl
*d3dimpl
;
35 if (IsEqualGUID(riid
, &IID_IUnknown
)
36 || IsEqualGUID(riid
, &IID_IDirect3DDevice9
)) {
37 IDirect3DDevice9Ex_AddRef(iface
);
39 TRACE("Returning IDirect3DDevice9 interface at %p\n", *ppobj
);
41 } else if(IsEqualGUID(riid
, &IID_IDirect3DDevice9Ex
)) {
42 /* Find out if the creating d3d9 interface was created with Direct3DCreate9Ex.
43 * It doesn't matter with which function the device was created.
45 IDirect3DDevice9_GetDirect3D(iface
, &d3d
);
46 d3dimpl
= (IDirect3D9Impl
*) d3d
;
48 if(d3dimpl
->extended
) {
50 IDirect3DDevice9Ex_AddRef((IDirect3DDevice9Ex
*) *ppobj
);
51 IDirect3D9_Release(d3d
);
52 TRACE("Returning IDirect3DDevice9Ex interface at %p\n", *ppobj
);
55 WARN("IDirect3D9 instance wasn't created with CreateDirect3D9Ex, returning E_NOINTERFACE\n");
56 IDirect3D9_Release(d3d
);
62 if (IsEqualGUID(riid
, &IID_IWineD3DDeviceParent
))
64 IUnknown_AddRef((IUnknown
*)&This
->device_parent_vtbl
);
65 *ppobj
= &This
->device_parent_vtbl
;
69 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
74 static ULONG WINAPI
IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9EX iface
) {
75 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
76 ULONG ref
= InterlockedIncrement(&This
->ref
);
78 TRACE("(%p) : AddRef from %d\n", This
, ref
- 1);
83 static ULONG WINAPI
IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface
) {
84 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
87 if (This
->inDestruction
) return 0;
88 ref
= InterlockedDecrement(&This
->ref
);
90 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
94 This
->inDestruction
= TRUE
;
96 EnterCriticalSection(&d3d9_cs
);
97 for(i
= 0; i
< This
->numConvertedDecls
; i
++) {
98 /* Unless Wine is buggy or the app has a bug the refcount will be 0, because decls hold a reference to the
101 IDirect3DVertexDeclaration9Impl_Destroy(This
->convertedDecls
[i
]);
103 HeapFree(GetProcessHeap(), 0, This
->convertedDecls
);
105 IWineD3DDevice_Uninit3D(This
->WineD3DDevice
, D3D9CB_DestroyDepthStencilSurface
, D3D9CB_DestroySwapChain
);
106 IWineD3DDevice_Release(This
->WineD3DDevice
);
107 LeaveCriticalSection(&d3d9_cs
);
108 HeapFree(GetProcessHeap(), 0, This
);
113 /* IDirect3DDevice Interface follow: */
114 static HRESULT WINAPI
IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9EX iface
) {
115 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
117 TRACE("(%p)\n", This
);
119 EnterCriticalSection(&d3d9_cs
);
120 hr
= IWineD3DDevice_TestCooperativeLevel(This
->WineD3DDevice
);
121 LeaveCriticalSection(&d3d9_cs
);
122 if(hr
== WINED3D_OK
&& This
->notreset
) {
123 TRACE("D3D9 Device is marked not reset\n");
124 hr
= D3DERR_DEVICENOTRESET
;
130 static UINT WINAPI
IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9EX iface
) {
131 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
133 TRACE("(%p) Relay\n", This
);
135 EnterCriticalSection(&d3d9_cs
);
136 hr
= IWineD3DDevice_GetAvailableTextureMem(This
->WineD3DDevice
);
137 LeaveCriticalSection(&d3d9_cs
);
141 static HRESULT WINAPI
IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9EX iface
) {
142 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
144 TRACE("(%p) : Relay\n", This
);
146 EnterCriticalSection(&d3d9_cs
);
147 hr
= IWineD3DDevice_EvictManagedResources(This
->WineD3DDevice
);
148 LeaveCriticalSection(&d3d9_cs
);
152 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface
, IDirect3D9
** ppD3D9
) {
153 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
157 TRACE("(%p) Relay\n", This
);
159 if (NULL
== ppD3D9
) {
160 return D3DERR_INVALIDCALL
;
163 EnterCriticalSection(&d3d9_cs
);
164 hr
= IWineD3DDevice_GetDirect3D(This
->WineD3DDevice
, &pWineD3D
);
165 if (hr
== D3D_OK
&& pWineD3D
!= NULL
)
167 IWineD3D_GetParent(pWineD3D
,(IUnknown
**)ppD3D9
);
168 IWineD3D_Release(pWineD3D
);
170 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
173 TRACE("(%p) returning %p\n", This
, *ppD3D9
);
174 LeaveCriticalSection(&d3d9_cs
);
178 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9EX iface
, D3DCAPS9
* pCaps
) {
179 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
180 HRESULT hrc
= D3D_OK
;
181 WINED3DCAPS
*pWineCaps
;
183 TRACE("(%p) : Relay pCaps %p\n", This
, pCaps
);
185 return D3DERR_INVALIDCALL
;
187 pWineCaps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINED3DCAPS
));
188 if(pWineCaps
== NULL
){
189 return D3DERR_INVALIDCALL
; /* well this is what MSDN says to return */
192 memset(pCaps
, 0, sizeof(*pCaps
));
193 EnterCriticalSection(&d3d9_cs
);
194 hrc
= IWineD3DDevice_GetDeviceCaps(This
->WineD3DDevice
, pWineCaps
);
195 LeaveCriticalSection(&d3d9_cs
);
196 WINECAPSTOD3D9CAPS(pCaps
, pWineCaps
)
197 HeapFree(GetProcessHeap(), 0, pWineCaps
);
199 /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
200 pCaps
->DevCaps2
|= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
;
204 TRACE("Returning %p %p\n", This
, pCaps
);
208 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DDISPLAYMODE
* pMode
) {
209 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
211 TRACE("(%p) Relay\n", This
);
213 EnterCriticalSection(&d3d9_cs
);
214 hr
= IWineD3DDevice_GetDisplayMode(This
->WineD3DDevice
, iSwapChain
, (WINED3DDISPLAYMODE
*) pMode
);
215 LeaveCriticalSection(&d3d9_cs
);
219 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9EX iface
, D3DDEVICE_CREATION_PARAMETERS
*pParameters
) {
220 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
222 TRACE("(%p) Relay\n", This
);
224 EnterCriticalSection(&d3d9_cs
);
225 hr
= IWineD3DDevice_GetCreationParameters(This
->WineD3DDevice
, (WINED3DDEVICE_CREATION_PARAMETERS
*) pParameters
);
226 LeaveCriticalSection(&d3d9_cs
);
230 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9EX iface
, UINT XHotSpot
, UINT YHotSpot
, IDirect3DSurface9
* pCursorBitmap
) {
231 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
232 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pCursorBitmap
;
235 TRACE("(%p) Relay\n", This
);
237 WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
238 return WINED3DERR_INVALIDCALL
;
241 EnterCriticalSection(&d3d9_cs
);
242 hr
= IWineD3DDevice_SetCursorProperties(This
->WineD3DDevice
, XHotSpot
, YHotSpot
, pSurface
->wineD3DSurface
);
243 LeaveCriticalSection(&d3d9_cs
);
247 static void WINAPI
IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9EX iface
, int XScreenSpace
, int YScreenSpace
, DWORD Flags
) {
248 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
249 TRACE("(%p) Relay\n", This
);
251 EnterCriticalSection(&d3d9_cs
);
252 IWineD3DDevice_SetCursorPosition(This
->WineD3DDevice
, XScreenSpace
, YScreenSpace
, Flags
);
253 LeaveCriticalSection(&d3d9_cs
);
256 static BOOL WINAPI
IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX iface
, BOOL bShow
) {
257 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
259 TRACE("(%p) Relay\n", This
);
261 EnterCriticalSection(&d3d9_cs
);
262 ret
= IWineD3DDevice_ShowCursor(This
->WineD3DDevice
, bShow
);
263 LeaveCriticalSection(&d3d9_cs
);
267 static HRESULT WINAPI
reset_enum_callback(IWineD3DResource
*resource
, void *data
) {
268 BOOL
*resources_ok
= data
;
269 WINED3DRESOURCETYPE type
;
271 WINED3DSURFACE_DESC surface_desc
;
272 WINED3DVOLUME_DESC volume_desc
;
273 WINED3DINDEXBUFFER_DESC index_desc
;
274 WINED3DVERTEXBUFFER_DESC vertex_desc
;
275 WINED3DFORMAT dummy_format
;
276 WINED3DMULTISAMPLE_TYPE dummy_multisampletype
;
278 WINED3DPOOL pool
= WINED3DPOOL_SCRATCH
; /* a harmless pool */
281 type
= IWineD3DResource_GetType(resource
);
283 case WINED3DRTYPE_SURFACE
:
284 surface_desc
.Format
= &dummy_format
;
285 surface_desc
.Type
= &type
;
286 surface_desc
.Usage
= &dummy_dword
;
287 surface_desc
.Pool
= &pool
;
288 surface_desc
.Size
= &dummy_dword
;
289 surface_desc
.MultiSampleType
= &dummy_multisampletype
;
290 surface_desc
.MultiSampleQuality
= &dummy_dword
;
291 surface_desc
.Width
= &dummy_dword
;
292 surface_desc
.Height
= &dummy_dword
;
294 IWineD3DSurface_GetDesc((IWineD3DSurface
*) resource
, &surface_desc
);
297 case WINED3DRTYPE_VOLUME
:
298 volume_desc
.Format
= &dummy_format
;
299 volume_desc
.Type
= &type
;
300 volume_desc
.Usage
= &dummy_dword
;
301 volume_desc
.Pool
= &pool
;
302 volume_desc
.Size
= &dummy_dword
;
303 volume_desc
.Width
= &dummy_dword
;
304 volume_desc
.Height
= &dummy_dword
;
305 volume_desc
.Depth
= &dummy_dword
;
306 IWineD3DVolume_GetDesc((IWineD3DVolume
*) resource
, &volume_desc
);
309 case WINED3DRTYPE_INDEXBUFFER
:
310 IWineD3DIndexBuffer_GetDesc((IWineD3DIndexBuffer
*) resource
, &index_desc
);
311 pool
= index_desc
.Pool
;
314 case WINED3DRTYPE_VERTEXBUFFER
:
315 IWineD3DVertexBuffer_GetDesc((IWineD3DVertexBuffer
*) resource
, &vertex_desc
);
316 pool
= vertex_desc
.Pool
;
319 /* No need to check for textures. If there is a D3DPOOL_DEFAULT texture, there
320 * is a D3DPOOL_DEFAULT surface or volume as well
326 if(pool
== WINED3DPOOL_DEFAULT
) {
327 IWineD3DResource_GetParent(resource
, &parent
);
328 if(IUnknown_Release(parent
) == 0) {
329 TRACE("Parent %p is an implicit resource with ref 0\n", parent
);
331 WARN("Resource %p(wineD3D %p) with pool D3DPOOL_DEFAULT blocks the Reset call\n", parent
, resource
);
333 *resources_ok
= FALSE
;
336 IWineD3DResource_Release(resource
);
341 static HRESULT WINAPI
IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface
, D3DPRESENT_PARAMETERS
* pPresentationParameters
) {
342 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
343 WINED3DPRESENT_PARAMETERS localParameters
;
345 BOOL resources_ok
= TRUE
;
348 TRACE("(%p) Relay pPresentationParameters(%p)\n", This
, pPresentationParameters
);
350 /* Reset states that hold a COM object. WineD3D holds an internal reference to set objects, because
351 * such objects can still be used for rendering after their external d3d9 object has been destroyed.
352 * These objects must not be enumerated. Unsetting them tells WineD3D that the application will not
353 * make use of the hidden reference and destroys the objects.
355 * Unsetting them is no problem, because the states are supposed to be reset anyway. If the validation
356 * below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
358 IWineD3DDevice_SetIndices(This
->WineD3DDevice
, NULL
);
359 for(i
= 0; i
< 16; i
++) {
360 IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, i
, NULL
, 0, 0);
362 for(i
= 0; i
< 16; i
++) {
363 IWineD3DDevice_SetTexture(This
->WineD3DDevice
, i
, NULL
);
366 IWineD3DDevice_EnumResources(This
->WineD3DDevice
, reset_enum_callback
, &resources_ok
);
368 WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
369 This
->notreset
= TRUE
;
370 return WINED3DERR_INVALIDCALL
;
373 localParameters
.BackBufferWidth
= pPresentationParameters
->BackBufferWidth
;
374 localParameters
.BackBufferHeight
= pPresentationParameters
->BackBufferHeight
;
375 localParameters
.BackBufferFormat
= pPresentationParameters
->BackBufferFormat
;
376 localParameters
.BackBufferCount
= pPresentationParameters
->BackBufferCount
;
377 localParameters
.MultiSampleType
= pPresentationParameters
->MultiSampleType
;
378 localParameters
.MultiSampleQuality
= pPresentationParameters
->MultiSampleQuality
;
379 localParameters
.SwapEffect
= pPresentationParameters
->SwapEffect
;
380 localParameters
.hDeviceWindow
= pPresentationParameters
->hDeviceWindow
;
381 localParameters
.Windowed
= pPresentationParameters
->Windowed
;
382 localParameters
.EnableAutoDepthStencil
= pPresentationParameters
->EnableAutoDepthStencil
;
383 localParameters
.AutoDepthStencilFormat
= pPresentationParameters
->AutoDepthStencilFormat
;
384 localParameters
.Flags
= pPresentationParameters
->Flags
;
385 localParameters
.FullScreen_RefreshRateInHz
= pPresentationParameters
->FullScreen_RefreshRateInHz
;
386 localParameters
.PresentationInterval
= pPresentationParameters
->PresentationInterval
;
387 localParameters
.AutoRestoreDisplayMode
= TRUE
;
389 EnterCriticalSection(&d3d9_cs
);
390 hr
= IWineD3DDevice_Reset(This
->WineD3DDevice
, &localParameters
);
391 LeaveCriticalSection(&d3d9_cs
);
393 This
->notreset
= TRUE
;
395 pPresentationParameters
->BackBufferWidth
= localParameters
.BackBufferWidth
;
396 pPresentationParameters
->BackBufferHeight
= localParameters
.BackBufferHeight
;
397 pPresentationParameters
->BackBufferFormat
= localParameters
.BackBufferFormat
;
398 pPresentationParameters
->BackBufferCount
= localParameters
.BackBufferCount
;
399 pPresentationParameters
->MultiSampleType
= localParameters
.MultiSampleType
;
400 pPresentationParameters
->MultiSampleQuality
= localParameters
.MultiSampleQuality
;
401 pPresentationParameters
->SwapEffect
= localParameters
.SwapEffect
;
402 pPresentationParameters
->hDeviceWindow
= localParameters
.hDeviceWindow
;
403 pPresentationParameters
->Windowed
= localParameters
.Windowed
;
404 pPresentationParameters
->EnableAutoDepthStencil
= localParameters
.EnableAutoDepthStencil
;
405 pPresentationParameters
->AutoDepthStencilFormat
= localParameters
.AutoDepthStencilFormat
;
406 pPresentationParameters
->Flags
= localParameters
.Flags
;
407 pPresentationParameters
->FullScreen_RefreshRateInHz
= localParameters
.FullScreen_RefreshRateInHz
;
408 pPresentationParameters
->PresentationInterval
= localParameters
.PresentationInterval
;
410 This
->notreset
= FALSE
;
416 static HRESULT WINAPI
IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface
, CONST RECT
* pSourceRect
,CONST RECT
* pDestRect
,HWND hDestWindowOverride
,CONST RGNDATA
*
418 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
420 TRACE("(%p) Relay\n", This
);
422 EnterCriticalSection(&d3d9_cs
);
423 hr
= IWineD3DDevice_Present(This
->WineD3DDevice
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
);
424 LeaveCriticalSection(&d3d9_cs
);
428 static HRESULT WINAPI
IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, UINT BackBuffer
, D3DBACKBUFFER_TYPE Type
, IDirect3DSurface9
** ppBackBuffer
) {
429 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
430 IWineD3DSurface
*retSurface
= NULL
;
433 TRACE("(%p) Relay\n", This
);
435 EnterCriticalSection(&d3d9_cs
);
436 rc
= IWineD3DDevice_GetBackBuffer(This
->WineD3DDevice
, iSwapChain
, BackBuffer
, (WINED3DBACKBUFFER_TYPE
) Type
, &retSurface
);
437 if (rc
== D3D_OK
&& NULL
!= retSurface
&& NULL
!= ppBackBuffer
) {
438 IWineD3DSurface_GetParent(retSurface
, (IUnknown
**)ppBackBuffer
);
439 IWineD3DSurface_Release(retSurface
);
441 LeaveCriticalSection(&d3d9_cs
);
444 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DRASTER_STATUS
* pRasterStatus
) {
445 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
447 TRACE("(%p) Relay\n", This
);
449 EnterCriticalSection(&d3d9_cs
);
450 hr
= IWineD3DDevice_GetRasterStatus(This
->WineD3DDevice
, iSwapChain
, (WINED3DRASTER_STATUS
*) pRasterStatus
);
451 LeaveCriticalSection(&d3d9_cs
);
455 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9EX iface
, BOOL bEnableDialogs
) {
456 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
458 TRACE("(%p) Relay\n", This
);
460 EnterCriticalSection(&d3d9_cs
);
461 hr
= IWineD3DDevice_SetDialogBoxMode(This
->WineD3DDevice
, bEnableDialogs
);
462 LeaveCriticalSection(&d3d9_cs
);
466 static void WINAPI
IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, DWORD Flags
, CONST D3DGAMMARAMP
* pRamp
) {
468 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
469 TRACE("(%p) Relay\n", This
);
471 EnterCriticalSection(&d3d9_cs
);
472 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
473 IWineD3DDevice_SetGammaRamp(This
->WineD3DDevice
, iSwapChain
, Flags
, (CONST WINED3DGAMMARAMP
*)pRamp
);
474 LeaveCriticalSection(&d3d9_cs
);
477 static void WINAPI
IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DGAMMARAMP
* pRamp
) {
478 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
479 TRACE("(%p) Relay\n", This
);
481 EnterCriticalSection(&d3d9_cs
);
482 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
483 IWineD3DDevice_GetGammaRamp(This
->WineD3DDevice
, iSwapChain
, (WINED3DGAMMARAMP
*) pRamp
);
484 LeaveCriticalSection(&d3d9_cs
);
488 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
) {
490 IDirect3DSurface9Impl
*object
;
491 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
492 TRACE("(%p) Relay\n", This
);
494 if(MultisampleQuality
> 0){
495 FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality
);
498 [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.
501 MultisampleQuality
=0;
503 /*FIXME: Check MAX bounds of MultisampleQuality*/
505 /* Allocate the storage for the device */
506 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DSurface9Impl
));
507 if (NULL
== object
) {
508 FIXME("Allocation of memory failed\n");
509 return D3DERR_OUTOFVIDEOMEMORY
;
512 object
->lpVtbl
= &Direct3DSurface9_Vtbl
;
515 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This
, Width
, Height
, Format
, *ppSurface
);
517 hrc
= IWineD3DDevice_CreateSurface(This
->WineD3DDevice
, Width
, Height
, Format
, Lockable
, Discard
, Level
, &object
->wineD3DSurface
, Type
, Usage
& WINED3DUSAGE_MASK
, (WINED3DPOOL
) Pool
,MultiSample
,MultisampleQuality
,pSharedHandle
,SURFACE_OPENGL
,(IUnknown
*)object
);
519 if (hrc
!= D3D_OK
|| NULL
== object
->wineD3DSurface
) {
522 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This
);
523 HeapFree(GetProcessHeap(), 0, object
);
525 IDirect3DDevice9Ex_AddRef(iface
);
526 object
->parentDevice
= iface
;
527 TRACE("(%p) : Created surface %p\n", This
, object
);
528 *ppSurface
= (LPDIRECT3DSURFACE9
) object
;
535 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
536 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
537 DWORD MultisampleQuality
, BOOL Lockable
,
538 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
542 /* Is this correct? */
543 EnterCriticalSection(&d3d9_cs
);
544 hr
= IDirect3DDevice9Impl_CreateSurface(iface
,Width
,Height
,Format
,Lockable
,FALSE
/*Discard*/, 0/*Level*/, ppSurface
,D3DRTYPE_SURFACE
,D3DUSAGE_RENDERTARGET
,D3DPOOL_DEFAULT
,MultiSample
,MultisampleQuality
,pSharedHandle
);
545 LeaveCriticalSection(&d3d9_cs
);
549 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
,
550 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
551 DWORD MultisampleQuality
, BOOL Discard
,
552 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
556 EnterCriticalSection(&d3d9_cs
);
557 hr
= IDirect3DDevice9Impl_CreateSurface(iface
,Width
,Height
,Format
,TRUE
/* Lockable */,Discard
, 0/* Level */
558 ,ppSurface
,D3DRTYPE_SURFACE
,D3DUSAGE_DEPTHSTENCIL
,
559 D3DPOOL_DEFAULT
,MultiSample
,MultisampleQuality
,pSharedHandle
);
560 LeaveCriticalSection(&d3d9_cs
);
565 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestinationSurface
, CONST POINT
* pDestPoint
) {
566 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
568 TRACE("(%p) Relay\n" , This
);
570 EnterCriticalSection(&d3d9_cs
);
571 hr
= IWineD3DDevice_UpdateSurface(This
->WineD3DDevice
, ((IDirect3DSurface9Impl
*)pSourceSurface
)->wineD3DSurface
, pSourceRect
, ((IDirect3DSurface9Impl
*)pDestinationSurface
)->wineD3DSurface
, pDestPoint
);
572 LeaveCriticalSection(&d3d9_cs
);
576 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9EX iface
, IDirect3DBaseTexture9
* pSourceTexture
, IDirect3DBaseTexture9
* pDestinationTexture
) {
577 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
579 TRACE("(%p) Relay\n" , This
);
581 EnterCriticalSection(&d3d9_cs
);
582 hr
= IWineD3DDevice_UpdateTexture(This
->WineD3DDevice
, ((IDirect3DBaseTexture9Impl
*)pSourceTexture
)->wineD3DBaseTexture
, ((IDirect3DBaseTexture9Impl
*)pDestinationTexture
)->wineD3DBaseTexture
);
583 LeaveCriticalSection(&d3d9_cs
);
587 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pRenderTarget
, IDirect3DSurface9
* pDestSurface
) {
588 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
589 IDirect3DSurface9Impl
*renderTarget
= (IDirect3DSurface9Impl
*)pRenderTarget
;
590 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
592 TRACE("(%p)->(%p,%p)\n" , This
, renderTarget
, destSurface
);
594 EnterCriticalSection(&d3d9_cs
);
595 hr
= IWineD3DSurface_BltFast(destSurface
->wineD3DSurface
, 0, 0, renderTarget
->wineD3DSurface
, NULL
, WINEDDBLTFAST_NOCOLORKEY
);
596 LeaveCriticalSection(&d3d9_cs
);
600 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, IDirect3DSurface9
* pDestSurface
) {
601 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
602 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
604 TRACE("(%p) Relay\n" , This
);
606 EnterCriticalSection(&d3d9_cs
);
607 hr
= IWineD3DDevice_GetFrontBufferData(This
->WineD3DDevice
, iSwapChain
, destSurface
->wineD3DSurface
);
608 LeaveCriticalSection(&d3d9_cs
);
612 static HRESULT WINAPI
IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestSurface
, CONST RECT
* pDestRect
, D3DTEXTUREFILTERTYPE Filter
) {
613 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
614 IDirect3DSurface9Impl
*src
= (IDirect3DSurface9Impl
*) pSourceSurface
;
615 IDirect3DSurface9Impl
*dst
= (IDirect3DSurface9Impl
*) pDestSurface
;
618 TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This
, src
, pSourceRect
, dst
, pDestRect
, Filter
);
619 EnterCriticalSection(&d3d9_cs
);
620 hr
= IWineD3DSurface_Blt(dst
->wineD3DSurface
, pDestRect
, src
->wineD3DSurface
, pSourceRect
, 0, NULL
, Filter
);
621 LeaveCriticalSection(&d3d9_cs
);
625 static HRESULT WINAPI
IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pSurface
, CONST RECT
* pRect
, D3DCOLOR color
) {
626 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
627 IDirect3DSurface9Impl
*surface
= (IDirect3DSurface9Impl
*)pSurface
;
629 WINED3DRESOURCETYPE restype
;
631 WINED3DSURFACE_DESC desc
;
633 TRACE("(%p) Relay\n" , This
);
635 memset(&desc
, 0, sizeof(desc
));
638 desc
.Type
= &restype
;
639 IWineD3DSurface_GetDesc(surface
->wineD3DSurface
, &desc
);
641 /* This method is only allowed with surfaces that are render targets, or offscreen plain surfaces
644 if(!(usage
& WINED3DUSAGE_RENDERTARGET
) && (pool
!= D3DPOOL_DEFAULT
|| restype
!= D3DRTYPE_SURFACE
)) {
645 WARN("Surface is not a render target, or not a stand-alone D3DPOOL_DEFAULT surface\n");
646 return D3DERR_INVALIDCALL
;
649 /* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
650 /* Note: D3DRECT is compatible with WINED3DRECT */
651 EnterCriticalSection(&d3d9_cs
);
652 hr
= IWineD3DDevice_ColorFill(This
->WineD3DDevice
, surface
->wineD3DSurface
, (CONST WINED3DRECT
*)pRect
, color
);
653 LeaveCriticalSection(&d3d9_cs
);
657 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
660 if(Pool
== D3DPOOL_MANAGED
){
661 FIXME("Attempting to create a managed offscreen plain surface\n");
662 return D3DERR_INVALIDCALL
;
665 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
667 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
668 Why, their always lockable?
669 should I change the usage to dynamic?
671 EnterCriticalSection(&d3d9_cs
);
672 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
);
673 LeaveCriticalSection(&d3d9_cs
);
677 /* TODO: move to wineD3D */
678 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
* pRenderTarget
) {
679 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
680 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pRenderTarget
;
682 TRACE("(%p) Relay\n" , This
);
684 EnterCriticalSection(&d3d9_cs
);
685 hr
= IWineD3DDevice_SetRenderTarget(This
->WineD3DDevice
, RenderTargetIndex
, pSurface
? pSurface
->wineD3DSurface
: NULL
);
686 LeaveCriticalSection(&d3d9_cs
);
690 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
**ppRenderTarget
) {
691 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
693 IWineD3DSurface
*pRenderTarget
;
695 TRACE("(%p) Relay\n" , This
);
697 if (ppRenderTarget
== NULL
) {
698 return D3DERR_INVALIDCALL
;
701 EnterCriticalSection(&d3d9_cs
);
702 hr
=IWineD3DDevice_GetRenderTarget(This
->WineD3DDevice
,RenderTargetIndex
,&pRenderTarget
);
704 if (hr
== D3D_OK
&& pRenderTarget
!= NULL
) {
705 IWineD3DSurface_GetParent(pRenderTarget
,(IUnknown
**)ppRenderTarget
);
706 IWineD3DSurface_Release(pRenderTarget
);
708 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
709 *ppRenderTarget
= NULL
;
711 LeaveCriticalSection(&d3d9_cs
);
716 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
* pZStencilSurface
) {
717 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
718 IDirect3DSurface9Impl
*pSurface
;
720 TRACE("(%p) Relay\n" , This
);
722 pSurface
= (IDirect3DSurface9Impl
*)pZStencilSurface
;
723 EnterCriticalSection(&d3d9_cs
);
724 hr
= IWineD3DDevice_SetDepthStencilSurface(This
->WineD3DDevice
, NULL
==pSurface
? NULL
: pSurface
->wineD3DSurface
);
725 LeaveCriticalSection(&d3d9_cs
);
729 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
**ppZStencilSurface
) {
730 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
732 IWineD3DSurface
*pZStencilSurface
;
734 TRACE("(%p) Relay\n" , This
);
735 if(ppZStencilSurface
== NULL
){
736 return D3DERR_INVALIDCALL
;
739 EnterCriticalSection(&d3d9_cs
);
740 hr
= IWineD3DDevice_GetDepthStencilSurface(This
->WineD3DDevice
,&pZStencilSurface
);
741 if (hr
== WINED3D_OK
) {
742 IWineD3DSurface_GetParent(pZStencilSurface
,(IUnknown
**)ppZStencilSurface
);
743 IWineD3DSurface_Release(pZStencilSurface
);
745 if (hr
!= WINED3DERR_NOTFOUND
)
746 WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr
);
747 *ppZStencilSurface
= NULL
;
749 LeaveCriticalSection(&d3d9_cs
);
753 static HRESULT WINAPI
IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX iface
) {
754 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
756 TRACE("(%p) Relay\n" , This
);
758 EnterCriticalSection(&d3d9_cs
);
759 hr
= IWineD3DDevice_BeginScene(This
->WineD3DDevice
);
760 LeaveCriticalSection(&d3d9_cs
);
764 static HRESULT WINAPI
IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface
) {
765 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
767 TRACE("(%p) Relay\n" , This
);
769 EnterCriticalSection(&d3d9_cs
);
770 hr
= IWineD3DDevice_EndScene(This
->WineD3DDevice
);
771 LeaveCriticalSection(&d3d9_cs
);
775 static HRESULT WINAPI
IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9EX iface
, DWORD Count
, CONST D3DRECT
* pRects
, DWORD Flags
, D3DCOLOR Color
, float Z
, DWORD Stencil
) {
776 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
778 TRACE("(%p) Relay\n" , This
);
780 /* Note: D3DRECT is compatible with WINED3DRECT */
781 EnterCriticalSection(&d3d9_cs
);
782 hr
= IWineD3DDevice_Clear(This
->WineD3DDevice
, Count
, (CONST WINED3DRECT
*) pRects
, Flags
, Color
, Z
, Stencil
);
783 LeaveCriticalSection(&d3d9_cs
);
787 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* lpMatrix
) {
788 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
790 TRACE("(%p) Relay\n" , This
);
792 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
793 EnterCriticalSection(&d3d9_cs
);
794 hr
= IWineD3DDevice_SetTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) lpMatrix
);
795 LeaveCriticalSection(&d3d9_cs
);
799 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, D3DMATRIX
* pMatrix
) {
800 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
801 TRACE("(%p) Relay\n" , This
);
803 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
804 return IWineD3DDevice_GetTransform(This
->WineD3DDevice
, State
, (WINED3DMATRIX
*) pMatrix
);
807 static HRESULT WINAPI
IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9EX iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* pMatrix
) {
808 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
810 TRACE("(%p) Relay\n" , This
);
812 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
813 EnterCriticalSection(&d3d9_cs
);
814 hr
= IWineD3DDevice_MultiplyTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) pMatrix
);
815 LeaveCriticalSection(&d3d9_cs
);
819 static HRESULT WINAPI
IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9EX iface
, CONST D3DVIEWPORT9
* pViewport
) {
820 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
822 TRACE("(%p) Relay\n" , This
);
824 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
825 EnterCriticalSection(&d3d9_cs
);
826 hr
= IWineD3DDevice_SetViewport(This
->WineD3DDevice
, (const WINED3DVIEWPORT
*)pViewport
);
827 LeaveCriticalSection(&d3d9_cs
);
831 static HRESULT WINAPI
IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9EX iface
, D3DVIEWPORT9
* pViewport
) {
832 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
834 TRACE("(%p) Relay\n" , This
);
836 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
837 EnterCriticalSection(&d3d9_cs
);
838 hr
= IWineD3DDevice_GetViewport(This
->WineD3DDevice
, (WINED3DVIEWPORT
*)pViewport
);
839 LeaveCriticalSection(&d3d9_cs
);
843 static HRESULT WINAPI
IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9EX iface
, CONST D3DMATERIAL9
* pMaterial
) {
844 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
846 TRACE("(%p) Relay\n" , This
);
848 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
849 EnterCriticalSection(&d3d9_cs
);
850 hr
= IWineD3DDevice_SetMaterial(This
->WineD3DDevice
, (const WINED3DMATERIAL
*)pMaterial
);
851 LeaveCriticalSection(&d3d9_cs
);
855 static HRESULT WINAPI
IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9EX iface
, D3DMATERIAL9
* pMaterial
) {
856 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
858 TRACE("(%p) Relay\n" , This
);
860 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
861 EnterCriticalSection(&d3d9_cs
);
862 hr
= IWineD3DDevice_GetMaterial(This
->WineD3DDevice
, (WINED3DMATERIAL
*)pMaterial
);
863 LeaveCriticalSection(&d3d9_cs
);
867 static HRESULT WINAPI
IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST D3DLIGHT9
* pLight
) {
868 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
870 TRACE("(%p) Relay\n" , This
);
872 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
873 EnterCriticalSection(&d3d9_cs
);
874 hr
= IWineD3DDevice_SetLight(This
->WineD3DDevice
, Index
, (const WINED3DLIGHT
*)pLight
);
875 LeaveCriticalSection(&d3d9_cs
);
879 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, D3DLIGHT9
* pLight
) {
880 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
882 TRACE("(%p) Relay\n" , This
);
884 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
885 EnterCriticalSection(&d3d9_cs
);
886 hr
= IWineD3DDevice_GetLight(This
->WineD3DDevice
, Index
, (WINED3DLIGHT
*)pLight
);
887 LeaveCriticalSection(&d3d9_cs
);
891 static HRESULT WINAPI
IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL Enable
) {
892 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
894 TRACE("(%p) Relay\n" , This
);
896 EnterCriticalSection(&d3d9_cs
);
897 hr
= IWineD3DDevice_SetLightEnable(This
->WineD3DDevice
, Index
, Enable
);
898 LeaveCriticalSection(&d3d9_cs
);
902 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, BOOL
* pEnable
) {
903 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
905 TRACE("(%p) Relay\n" , This
);
907 EnterCriticalSection(&d3d9_cs
);
908 hr
= IWineD3DDevice_GetLightEnable(This
->WineD3DDevice
, Index
, pEnable
);
909 LeaveCriticalSection(&d3d9_cs
);
913 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, CONST
float* pPlane
) {
914 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
916 TRACE("(%p) Relay\n" , This
);
918 EnterCriticalSection(&d3d9_cs
);
919 hr
= IWineD3DDevice_SetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
920 LeaveCriticalSection(&d3d9_cs
);
924 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX iface
, DWORD Index
, float* pPlane
) {
925 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
927 TRACE("(%p) Relay\n" , This
);
929 EnterCriticalSection(&d3d9_cs
);
930 hr
= IWineD3DDevice_GetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
931 LeaveCriticalSection(&d3d9_cs
);
935 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD Value
) {
936 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
938 TRACE("(%p) Relay\n" , This
);
940 EnterCriticalSection(&d3d9_cs
);
941 hr
= IWineD3DDevice_SetRenderState(This
->WineD3DDevice
, State
, Value
);
942 LeaveCriticalSection(&d3d9_cs
);
946 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX iface
, D3DRENDERSTATETYPE State
, DWORD
* pValue
) {
947 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
949 TRACE("(%p) Relay\n" , This
);
951 EnterCriticalSection(&d3d9_cs
);
952 hr
= IWineD3DDevice_GetRenderState(This
->WineD3DDevice
, State
, pValue
);
953 LeaveCriticalSection(&d3d9_cs
);
957 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX iface
, CONST D3DCLIPSTATUS9
* pClipStatus
) {
958 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
960 TRACE("(%p) Relay\n" , This
);
962 EnterCriticalSection(&d3d9_cs
);
963 hr
= IWineD3DDevice_SetClipStatus(This
->WineD3DDevice
, (const WINED3DCLIPSTATUS
*)pClipStatus
);
964 LeaveCriticalSection(&d3d9_cs
);
968 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9EX iface
, D3DCLIPSTATUS9
* pClipStatus
) {
969 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
971 TRACE("(%p) Relay\n" , This
);
973 EnterCriticalSection(&d3d9_cs
);
974 hr
= IWineD3DDevice_GetClipStatus(This
->WineD3DDevice
, (WINED3DCLIPSTATUS
*)pClipStatus
);
975 LeaveCriticalSection(&d3d9_cs
);
979 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
**ppTexture
) {
980 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
981 IWineD3DBaseTexture
*retTexture
= NULL
;
984 TRACE("(%p) Relay\n" , This
);
986 if(ppTexture
== NULL
){
987 return D3DERR_INVALIDCALL
;
990 EnterCriticalSection(&d3d9_cs
);
991 rc
= IWineD3DDevice_GetTexture(This
->WineD3DDevice
, Stage
, &retTexture
);
992 if (SUCCEEDED(rc
) && NULL
!= retTexture
) {
993 IWineD3DBaseTexture_GetParent(retTexture
, (IUnknown
**)ppTexture
);
994 IWineD3DBaseTexture_Release(retTexture
);
997 WARN("Call to get texture (%d) failed (%p)\n", Stage
, retTexture
);
1001 LeaveCriticalSection(&d3d9_cs
);
1006 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, IDirect3DBaseTexture9
* pTexture
) {
1007 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1009 TRACE("(%p) Relay %d %p\n" , This
, Stage
, pTexture
);
1011 EnterCriticalSection(&d3d9_cs
);
1012 hr
= IWineD3DDevice_SetTexture(This
->WineD3DDevice
, Stage
,
1013 pTexture
==NULL
? NULL
:((IDirect3DBaseTexture9Impl
*)pTexture
)->wineD3DBaseTexture
);
1014 LeaveCriticalSection(&d3d9_cs
);
1018 static const WINED3DTEXTURESTAGESTATETYPE tss_lookup
[] =
1020 WINED3DTSS_FORCE_DWORD
, /* 0, unused */
1021 WINED3DTSS_COLOROP
, /* 1, D3DTSS_COLOROP */
1022 WINED3DTSS_COLORARG1
, /* 2, D3DTSS_COLORARG1 */
1023 WINED3DTSS_COLORARG2
, /* 3, D3DTSS_COLORARG2 */
1024 WINED3DTSS_ALPHAOP
, /* 4, D3DTSS_ALPHAOP */
1025 WINED3DTSS_ALPHAARG1
, /* 5, D3DTSS_ALPHAARG1 */
1026 WINED3DTSS_ALPHAARG2
, /* 6, D3DTSS_ALPHAARG2 */
1027 WINED3DTSS_BUMPENVMAT00
, /* 7, D3DTSS_BUMPENVMAT00 */
1028 WINED3DTSS_BUMPENVMAT01
, /* 8, D3DTSS_BUMPENVMAT01 */
1029 WINED3DTSS_BUMPENVMAT10
, /* 9, D3DTSS_BUMPENVMAT10 */
1030 WINED3DTSS_BUMPENVMAT11
, /* 10, D3DTSS_BUMPENVMAT11 */
1031 WINED3DTSS_TEXCOORDINDEX
, /* 11, D3DTSS_TEXCOORDINDEX */
1032 WINED3DTSS_FORCE_DWORD
, /* 12, unused */
1033 WINED3DTSS_FORCE_DWORD
, /* 13, unused */
1034 WINED3DTSS_FORCE_DWORD
, /* 14, unused */
1035 WINED3DTSS_FORCE_DWORD
, /* 15, unused */
1036 WINED3DTSS_FORCE_DWORD
, /* 16, unused */
1037 WINED3DTSS_FORCE_DWORD
, /* 17, unused */
1038 WINED3DTSS_FORCE_DWORD
, /* 18, unused */
1039 WINED3DTSS_FORCE_DWORD
, /* 19, unused */
1040 WINED3DTSS_FORCE_DWORD
, /* 20, unused */
1041 WINED3DTSS_FORCE_DWORD
, /* 21, unused */
1042 WINED3DTSS_BUMPENVLSCALE
, /* 22, D3DTSS_BUMPENVLSCALE */
1043 WINED3DTSS_BUMPENVLOFFSET
, /* 23, D3DTSS_BUMPENVLOFFSET */
1044 WINED3DTSS_TEXTURETRANSFORMFLAGS
, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
1045 WINED3DTSS_FORCE_DWORD
, /* 25, unused */
1046 WINED3DTSS_COLORARG0
, /* 26, D3DTSS_COLORARG0 */
1047 WINED3DTSS_ALPHAARG0
, /* 27, D3DTSS_ALPHAARG0 */
1048 WINED3DTSS_RESULTARG
, /* 28, D3DTSS_RESULTARG */
1049 WINED3DTSS_FORCE_DWORD
, /* 29, unused */
1050 WINED3DTSS_FORCE_DWORD
, /* 30, unused */
1051 WINED3DTSS_FORCE_DWORD
, /* 31, unused */
1052 WINED3DTSS_CONSTANT
, /* 32, D3DTSS_CONSTANT */
1055 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD
* pValue
) {
1056 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1058 TRACE("(%p) Relay\n" , This
);
1060 EnterCriticalSection(&d3d9_cs
);
1061 hr
= IWineD3DDevice_GetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], pValue
);
1062 LeaveCriticalSection(&d3d9_cs
);
1066 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9EX iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD Value
) {
1067 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1069 TRACE("(%p) Relay\n" , This
);
1071 EnterCriticalSection(&d3d9_cs
);
1072 hr
= IWineD3DDevice_SetTextureStageState(This
->WineD3DDevice
, Stage
, tss_lookup
[Type
], Value
);
1073 LeaveCriticalSection(&d3d9_cs
);
1077 static HRESULT WINAPI
IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9EX iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD
* pValue
) {
1078 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1080 TRACE("(%p) Relay\n" , This
);
1082 EnterCriticalSection(&d3d9_cs
);
1083 hr
= IWineD3DDevice_GetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, pValue
);
1084 LeaveCriticalSection(&d3d9_cs
);
1088 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD Value
) {
1089 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1091 TRACE("(%p) Relay\n" , This
);
1093 EnterCriticalSection(&d3d9_cs
);
1094 hr
= IWineD3DDevice_SetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, Value
);
1095 LeaveCriticalSection(&d3d9_cs
);
1099 static HRESULT WINAPI
IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9EX iface
, DWORD
* pNumPasses
) {
1100 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1102 TRACE("(%p) Relay\n" , This
);
1104 EnterCriticalSection(&d3d9_cs
);
1105 hr
= IWineD3DDevice_ValidateDevice(This
->WineD3DDevice
, pNumPasses
);
1106 LeaveCriticalSection(&d3d9_cs
);
1110 static HRESULT WINAPI
IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
, CONST PALETTEENTRY
* pEntries
) {
1111 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1113 TRACE("(%p) Relay\n" , This
);
1115 EnterCriticalSection(&d3d9_cs
);
1116 hr
= IWineD3DDevice_SetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1117 LeaveCriticalSection(&d3d9_cs
);
1121 static HRESULT WINAPI
IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
, PALETTEENTRY
* pEntries
) {
1122 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1124 TRACE("(%p) Relay\n" , This
);
1126 EnterCriticalSection(&d3d9_cs
);
1127 hr
= IWineD3DDevice_GetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
1128 LeaveCriticalSection(&d3d9_cs
);
1132 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT PaletteNumber
) {
1133 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1135 TRACE("(%p) Relay\n" , This
);
1137 EnterCriticalSection(&d3d9_cs
);
1138 hr
= IWineD3DDevice_SetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1139 LeaveCriticalSection(&d3d9_cs
);
1143 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface
, UINT
* PaletteNumber
) {
1144 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1146 TRACE("(%p) Relay\n" , This
);
1148 EnterCriticalSection(&d3d9_cs
);
1149 hr
= IWineD3DDevice_GetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
1150 LeaveCriticalSection(&d3d9_cs
);
1154 static HRESULT WINAPI
IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9EX iface
, CONST RECT
* pRect
) {
1155 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1157 TRACE("(%p) Relay\n" , This
);
1159 EnterCriticalSection(&d3d9_cs
);
1160 hr
= IWineD3DDevice_SetScissorRect(This
->WineD3DDevice
, pRect
);
1161 LeaveCriticalSection(&d3d9_cs
);
1165 static HRESULT WINAPI
IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9EX iface
, RECT
* pRect
) {
1166 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1168 TRACE("(%p) Relay\n" , This
);
1170 EnterCriticalSection(&d3d9_cs
);
1171 hr
= IWineD3DDevice_GetScissorRect(This
->WineD3DDevice
, pRect
);
1172 LeaveCriticalSection(&d3d9_cs
);
1176 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
, BOOL bSoftware
) {
1177 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1179 TRACE("(%p) Relay\n" , This
);
1181 EnterCriticalSection(&d3d9_cs
);
1182 hr
= IWineD3DDevice_SetSoftwareVertexProcessing(This
->WineD3DDevice
, bSoftware
);
1183 LeaveCriticalSection(&d3d9_cs
);
1187 static BOOL WINAPI
IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface
) {
1188 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1190 TRACE("(%p) Relay\n" , This
);
1192 EnterCriticalSection(&d3d9_cs
);
1193 ret
= IWineD3DDevice_GetSoftwareVertexProcessing(This
->WineD3DDevice
);
1194 LeaveCriticalSection(&d3d9_cs
);
1198 static HRESULT WINAPI
IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9EX iface
, float nSegments
) {
1199 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1201 TRACE("(%p) Relay\n" , This
);
1203 EnterCriticalSection(&d3d9_cs
);
1204 hr
= IWineD3DDevice_SetNPatchMode(This
->WineD3DDevice
, nSegments
);
1205 LeaveCriticalSection(&d3d9_cs
);
1209 static float WINAPI
IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9EX iface
) {
1210 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1212 TRACE("(%p) Relay\n" , This
);
1214 EnterCriticalSection(&d3d9_cs
);
1215 ret
= IWineD3DDevice_GetNPatchMode(This
->WineD3DDevice
);
1216 LeaveCriticalSection(&d3d9_cs
);
1220 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT StartVertex
, UINT PrimitiveCount
) {
1221 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1223 TRACE("(%p) Relay\n" , This
);
1225 EnterCriticalSection(&d3d9_cs
);
1226 hr
= IWineD3DDevice_DrawPrimitive(This
->WineD3DDevice
, PrimitiveType
, StartVertex
, PrimitiveCount
);
1227 LeaveCriticalSection(&d3d9_cs
);
1231 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
,
1232 INT BaseVertexIndex
, UINT MinVertexIndex
, UINT NumVertices
, UINT startIndex
, UINT primCount
) {
1233 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1235 TRACE("(%p) Relay\n" , This
);
1237 /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
1238 EnterCriticalSection(&d3d9_cs
);
1239 IWineD3DDevice_SetBaseVertexIndex(This
->WineD3DDevice
, BaseVertexIndex
);
1240 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->WineD3DDevice
, PrimitiveType
, MinVertexIndex
, NumVertices
, startIndex
, primCount
);
1241 LeaveCriticalSection(&d3d9_cs
);
1245 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT PrimitiveCount
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1246 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1248 TRACE("(%p) Relay\n" , This
);
1250 EnterCriticalSection(&d3d9_cs
);
1251 hr
= IWineD3DDevice_DrawPrimitiveUP(This
->WineD3DDevice
, PrimitiveType
, PrimitiveCount
, pVertexStreamZeroData
, VertexStreamZeroStride
);
1252 LeaveCriticalSection(&d3d9_cs
);
1256 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9EX iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT MinVertexIndex
,
1257 UINT NumVertexIndices
, UINT PrimitiveCount
, CONST
void* pIndexData
,
1258 D3DFORMAT IndexDataFormat
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1259 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1261 TRACE("(%p) Relay\n" , This
);
1263 EnterCriticalSection(&d3d9_cs
);
1264 hr
= IWineD3DDevice_DrawIndexedPrimitiveUP(This
->WineD3DDevice
, PrimitiveType
, MinVertexIndex
, NumVertexIndices
, PrimitiveCount
,
1265 pIndexData
, IndexDataFormat
, pVertexStreamZeroData
, VertexStreamZeroStride
);
1266 LeaveCriticalSection(&d3d9_cs
);
1270 static HRESULT WINAPI
IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX iface
, UINT SrcStartIndex
, UINT DestIndex
, UINT VertexCount
, IDirect3DVertexBuffer9
* pDestBuffer
, IDirect3DVertexDeclaration9
* pVertexDecl
, DWORD Flags
) {
1271 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1272 IDirect3DVertexDeclaration9Impl
*Decl
= (IDirect3DVertexDeclaration9Impl
*) pVertexDecl
;
1274 TRACE("(%p) Relay\n" , This
);
1276 EnterCriticalSection(&d3d9_cs
);
1277 hr
= IWineD3DDevice_ProcessVertices(This
->WineD3DDevice
,SrcStartIndex
, DestIndex
, VertexCount
, ((IDirect3DVertexBuffer9Impl
*)pDestBuffer
)->wineD3DVertexBuffer
, Decl
? Decl
->wineD3DVertexDeclaration
: NULL
, Flags
);
1278 LeaveCriticalSection(&d3d9_cs
);
1282 static IDirect3DVertexDeclaration9
*getConvertedDecl(IDirect3DDevice9Impl
*This
, DWORD fvf
) {
1284 D3DVERTEXELEMENT9
* elements
= NULL
;
1285 IDirect3DVertexDeclaration9
* pDecl
= NULL
;
1286 int p
, low
, high
; /* deliberately signed */
1287 IDirect3DVertexDeclaration9
**convertedDecls
= This
->convertedDecls
;
1289 TRACE("Searching for declaration for fvf %08x... ", fvf
);
1292 high
= This
->numConvertedDecls
- 1;
1293 while(low
<= high
) {
1294 p
= (low
+ high
) >> 1;
1296 if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
== fvf
) {
1297 TRACE("found %p\n", convertedDecls
[p
]);
1298 return convertedDecls
[p
];
1299 } else if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
< fvf
) {
1305 TRACE("not found. Creating and inserting at position %d.\n", low
);
1307 hr
= vdecl_convert_fvf(fvf
, &elements
);
1308 if (hr
!= S_OK
) return NULL
;
1310 hr
= IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9Ex
*) This
, elements
, &pDecl
);
1311 HeapFree(GetProcessHeap(), 0, elements
); /* CreateVertexDeclaration makes a copy */
1312 if (hr
!= S_OK
) return NULL
;
1314 if(This
->declArraySize
== This
->numConvertedDecls
) {
1315 int grow
= max(This
->declArraySize
/ 2, 8);
1316 convertedDecls
= HeapReAlloc(GetProcessHeap(), 0, convertedDecls
,
1317 sizeof(convertedDecls
[0]) * (This
->numConvertedDecls
+ grow
));
1318 if(!convertedDecls
) {
1319 /* This will destroy it */
1320 IDirect3DVertexDeclaration9_Release(pDecl
);
1323 This
->convertedDecls
= convertedDecls
;
1324 This
->declArraySize
+= grow
;
1327 memmove(convertedDecls
+ low
+ 1, convertedDecls
+ low
, sizeof(IDirect3DVertexDeclaration9Impl
*) * (This
->numConvertedDecls
- low
));
1328 convertedDecls
[low
] = pDecl
;
1329 This
->numConvertedDecls
++;
1331 /* Will prevent the decl from being destroyed */
1332 ((IDirect3DVertexDeclaration9Impl
*) pDecl
)->convFVF
= fvf
;
1333 IDirect3DVertexDeclaration9_Release(pDecl
); /* Does not destroy now */
1335 TRACE("Returning %p. %d decls in array\n", pDecl
, This
->numConvertedDecls
);
1339 static HRESULT WINAPI
IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface
, DWORD FVF
) {
1340 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1342 TRACE("(%p) Relay\n" , This
);
1344 EnterCriticalSection(&d3d9_cs
);
1346 IDirect3DVertexDeclaration9
* pDecl
= getConvertedDecl(This
, FVF
);
1349 /* Any situation when this should happen, except out of memory? */
1350 ERR("Failed to create a converted vertex declaration\n");
1351 LeaveCriticalSection(&d3d9_cs
);
1352 return D3DERR_DRIVERINTERNALERROR
;
1355 hr
= IDirect3DDevice9Impl_SetVertexDeclaration(iface
, pDecl
);
1357 LeaveCriticalSection(&d3d9_cs
);
1361 LeaveCriticalSection(&d3d9_cs
);
1366 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface
, DWORD
* pFVF
) {
1367 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1368 IDirect3DVertexDeclaration9
*decl
;
1370 TRACE("(%p) Relay\n" , This
);
1372 hr
= IDirect3DDevice9_GetVertexDeclaration(iface
, &decl
);
1375 WARN("Failed to get vertex declaration, %#x\n", hr
);
1382 *pFVF
= ((IDirect3DVertexDeclaration9Impl
*)decl
)->convFVF
;
1383 IDirect3DVertexDeclaration9_Release(decl
);
1390 TRACE("Returning FVF %#x\n", *pFVF
);
1395 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
* pStreamData
, UINT OffsetInBytes
, UINT Stride
) {
1396 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1398 TRACE("(%p) Relay\n" , This
);
1400 EnterCriticalSection(&d3d9_cs
);
1401 hr
= IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, StreamNumber
,
1402 pStreamData
==NULL
? NULL
:((IDirect3DVertexBuffer9Impl
*)pStreamData
)->wineD3DVertexBuffer
,
1403 OffsetInBytes
, Stride
);
1404 LeaveCriticalSection(&d3d9_cs
);
1408 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
**pStream
, UINT
* OffsetInBytes
, UINT
* pStride
) {
1409 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1410 IWineD3DVertexBuffer
*retStream
= NULL
;
1411 HRESULT rc
= D3D_OK
;
1413 TRACE("(%p) Relay\n" , This
);
1415 if(pStream
== NULL
){
1416 return D3DERR_INVALIDCALL
;
1419 EnterCriticalSection(&d3d9_cs
);
1420 rc
= IWineD3DDevice_GetStreamSource(This
->WineD3DDevice
, StreamNumber
, &retStream
, OffsetInBytes
, pStride
);
1421 if (rc
== D3D_OK
&& NULL
!= retStream
) {
1422 IWineD3DVertexBuffer_GetParent(retStream
, (IUnknown
**)pStream
);
1423 IWineD3DVertexBuffer_Release(retStream
);
1426 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes
, pStride
);
1430 LeaveCriticalSection(&d3d9_cs
);
1435 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, UINT Divider
) {
1436 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1438 TRACE("(%p) Relay\n" , This
);
1440 EnterCriticalSection(&d3d9_cs
);
1441 hr
= IWineD3DDevice_SetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1442 LeaveCriticalSection(&d3d9_cs
);
1446 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface
, UINT StreamNumber
, UINT
* Divider
) {
1447 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1449 TRACE("(%p) Relay\n" , This
);
1451 EnterCriticalSection(&d3d9_cs
);
1452 hr
= IWineD3DDevice_GetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1453 LeaveCriticalSection(&d3d9_cs
);
1457 static HRESULT WINAPI
IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
* pIndexData
) {
1458 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1460 TRACE("(%p) Relay\n", This
);
1462 EnterCriticalSection(&d3d9_cs
);
1463 hr
= IWineD3DDevice_SetIndices(This
->WineD3DDevice
,
1464 pIndexData
? ((IDirect3DIndexBuffer9Impl
*)pIndexData
)->wineD3DIndexBuffer
: NULL
);
1465 LeaveCriticalSection(&d3d9_cs
);
1469 static HRESULT WINAPI
IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX iface
, IDirect3DIndexBuffer9
**ppIndexData
) {
1470 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1471 IWineD3DIndexBuffer
*retIndexData
= NULL
;
1472 HRESULT rc
= D3D_OK
;
1474 TRACE("(%p) Relay\n", This
);
1476 if(ppIndexData
== NULL
){
1477 return D3DERR_INVALIDCALL
;
1480 EnterCriticalSection(&d3d9_cs
);
1481 rc
= IWineD3DDevice_GetIndices(This
->WineD3DDevice
, &retIndexData
);
1482 if (SUCCEEDED(rc
) && retIndexData
) {
1483 IWineD3DIndexBuffer_GetParent(retIndexData
, (IUnknown
**)ppIndexData
);
1484 IWineD3DIndexBuffer_Release(retIndexData
);
1486 if (FAILED(rc
)) FIXME("Call to GetIndices failed\n");
1487 *ppIndexData
= NULL
;
1489 LeaveCriticalSection(&d3d9_cs
);
1493 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DRECTPATCH_INFO
* pRectPatchInfo
) {
1494 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1496 TRACE("(%p) Relay\n", This
);
1498 EnterCriticalSection(&d3d9_cs
);
1499 hr
= IWineD3DDevice_DrawRectPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DRECTPATCH_INFO
*)pRectPatchInfo
);
1500 LeaveCriticalSection(&d3d9_cs
);
1504 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DTRIPATCH_INFO
* pTriPatchInfo
) {
1505 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1507 TRACE("(%p) Relay\n", This
);
1509 EnterCriticalSection(&d3d9_cs
);
1510 hr
= IWineD3DDevice_DrawTriPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DTRIPATCH_INFO
*)pTriPatchInfo
);
1511 LeaveCriticalSection(&d3d9_cs
);
1515 static HRESULT WINAPI
IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX iface
, UINT Handle
) {
1516 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1518 TRACE("(%p) Relay\n", This
);
1520 EnterCriticalSection(&d3d9_cs
);
1521 hr
= IWineD3DDevice_DeletePatch(This
->WineD3DDevice
, Handle
);
1522 LeaveCriticalSection(&d3d9_cs
);
1526 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(LPDIRECT3DDEVICE9EX iface
, UINT width
, UINT height
, float *rows
, float *columns
) {
1527 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1528 FIXME("(%p)->(%d, %d, %p, %p) Stub!\n", This
, width
, height
, rows
, columns
);
1529 return WINED3DERR_INVALIDCALL
;
1532 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ComposeRects(LPDIRECT3DDEVICE9EX iface
, IDirect3DSurface9
*pSrc
, IDirect3DDevice9
*pDst
, IDirect3DVertexBuffer9
*pSrcRectDescs
, UINT NumRects
, IDirect3DVertexBuffer9
*pDstRectDescs
, D3DCOMPOSERECTSOP Operation
, int Xoffset
, int Yoffset
) {
1533 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1534 FIXME("(%p)->(%p, %p, %p, %d, %p, %d, %d, %d) Stub!\n", This
, pSrc
, pDst
, pSrcRectDescs
, NumRects
, pDstRectDescs
, Operation
, Xoffset
, Yoffset
);
1535 return WINED3DERR_INVALIDCALL
;
1538 static HRESULT WINAPI
IDirect3DDevice9ExImpl_PresentEx(LPDIRECT3DDEVICE9EX iface
, CONST RECT
*pSourceRect
, CONST RECT
*pDestRect
, HWND hDestWindowOverride
, CONST RGNDATA
*pDirtyRegion
, DWORD dwFlags
) {
1539 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1540 FIXME("(%p= -> (%p), %p, %p, %p, 0x%08x) Stub!\n", This
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
, dwFlags
);
1541 return WINED3DERR_INVALIDCALL
;
1544 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface
, INT
*pPriority
) {
1545 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1546 FIXME("(%p)->(%p) Stub!\n", This
, pPriority
);
1547 return WINED3DERR_INVALIDCALL
;
1550 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetGPUThreadPriority(LPDIRECT3DDEVICE9EX iface
, INT Priority
) {
1551 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1552 FIXME("(%p)->(%d) Stub!\n", This
, Priority
);
1553 return WINED3DERR_INVALIDCALL
;
1556 static HRESULT WINAPI
IDirect3DDevice9ExImpl_WaitForVBlank(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
) {
1557 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1558 FIXME("(%p)->(%d) Stub!\n", This
, iSwapChain
);
1559 return WINED3DERR_INVALIDCALL
;
1562 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckresourceResidency(LPDIRECT3DDEVICE9EX iface
, IDirect3DResource9
** pResourceArray
, UINT32 Numresources
) {
1563 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1564 FIXME("(%p)->(%p, %d) Stub!\n", This
, pResourceArray
, Numresources
);
1565 return WINED3DERR_INVALIDCALL
;
1568 static HRESULT WINAPI
IDirect3DDevice9ExImpl_SetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface
, UINT MaxLatency
) {
1569 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1570 FIXME("(%p)->(%d) Stub!\n", This
, MaxLatency
);
1571 return WINED3DERR_INVALIDCALL
;
1574 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetMaximumFrameLatency(LPDIRECT3DDEVICE9EX iface
, UINT
*pMaxLatency
) {
1575 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1576 FIXME("(%p)->(%p) Stub!\n", This
, pMaxLatency
);
1578 return WINED3DERR_INVALIDCALL
;
1581 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CheckdeviceState(LPDIRECT3DDEVICE9EX iface
, HWND hDestinationWindow
) {
1582 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1583 FIXME("(%p)->(%p) Stub!\n", This
, hDestinationWindow
);
1584 return WINED3DERR_INVALIDCALL
;
1587 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
) {
1588 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1589 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
);
1590 return WINED3DERR_INVALIDCALL
;
1593 static HRESULT WINAPI
IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx(LPDIRECT3DDEVICE9EX iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
*pSharedHandle
, DWORD Usage
) {
1594 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1595 FIXME("(%p)->(%d, %d, %d, %d, %p, %p, 0x%08x) Stub!\n", This
, Width
, Height
, Format
, Pool
, ppSurface
, pSharedHandle
, Usage
);
1596 return WINED3DERR_INVALIDCALL
;
1599 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
) {
1600 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1601 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
);
1602 return WINED3DERR_INVALIDCALL
;
1605 static HRESULT WINAPI
IDirect3DDevice9ExImpl_ResetEx(LPDIRECT3DDEVICE9EX iface
, D3DPRESENT_PARAMETERS
*pPresentationParameters
, D3DDISPLAYMODEEX
*pFullscreenDisplayMode
) {
1606 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1607 FIXME("(%p)->(%p) Stub!\n", This
, pPresentationParameters
);
1608 return WINED3DERR_INVALIDCALL
;
1611 static HRESULT WINAPI
IDirect3DDevice9ExImpl_GetDisplayModeEx(LPDIRECT3DDEVICE9EX iface
, UINT iSwapChain
, D3DDISPLAYMODEEX
*pMode
, D3DDISPLAYROTATION
*pRotation
) {
1612 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*) iface
;
1613 FIXME("(%p)->(%d, %p, %p) Stub!\n", This
, iSwapChain
, pMode
, pRotation
);
1614 return WINED3DERR_INVALIDCALL
;
1617 const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl
=
1620 IDirect3DDevice9Impl_QueryInterface
,
1621 IDirect3DDevice9Impl_AddRef
,
1622 IDirect3DDevice9Impl_Release
,
1623 /* IDirect3DDevice9 */
1624 IDirect3DDevice9Impl_TestCooperativeLevel
,
1625 IDirect3DDevice9Impl_GetAvailableTextureMem
,
1626 IDirect3DDevice9Impl_EvictManagedResources
,
1627 IDirect3DDevice9Impl_GetDirect3D
,
1628 IDirect3DDevice9Impl_GetDeviceCaps
,
1629 IDirect3DDevice9Impl_GetDisplayMode
,
1630 IDirect3DDevice9Impl_GetCreationParameters
,
1631 IDirect3DDevice9Impl_SetCursorProperties
,
1632 IDirect3DDevice9Impl_SetCursorPosition
,
1633 IDirect3DDevice9Impl_ShowCursor
,
1634 IDirect3DDevice9Impl_CreateAdditionalSwapChain
,
1635 IDirect3DDevice9Impl_GetSwapChain
,
1636 IDirect3DDevice9Impl_GetNumberOfSwapChains
,
1637 IDirect3DDevice9Impl_Reset
,
1638 IDirect3DDevice9Impl_Present
,
1639 IDirect3DDevice9Impl_GetBackBuffer
,
1640 IDirect3DDevice9Impl_GetRasterStatus
,
1641 IDirect3DDevice9Impl_SetDialogBoxMode
,
1642 IDirect3DDevice9Impl_SetGammaRamp
,
1643 IDirect3DDevice9Impl_GetGammaRamp
,
1644 IDirect3DDevice9Impl_CreateTexture
,
1645 IDirect3DDevice9Impl_CreateVolumeTexture
,
1646 IDirect3DDevice9Impl_CreateCubeTexture
,
1647 IDirect3DDevice9Impl_CreateVertexBuffer
,
1648 IDirect3DDevice9Impl_CreateIndexBuffer
,
1649 IDirect3DDevice9Impl_CreateRenderTarget
,
1650 IDirect3DDevice9Impl_CreateDepthStencilSurface
,
1651 IDirect3DDevice9Impl_UpdateSurface
,
1652 IDirect3DDevice9Impl_UpdateTexture
,
1653 IDirect3DDevice9Impl_GetRenderTargetData
,
1654 IDirect3DDevice9Impl_GetFrontBufferData
,
1655 IDirect3DDevice9Impl_StretchRect
,
1656 IDirect3DDevice9Impl_ColorFill
,
1657 IDirect3DDevice9Impl_CreateOffscreenPlainSurface
,
1658 IDirect3DDevice9Impl_SetRenderTarget
,
1659 IDirect3DDevice9Impl_GetRenderTarget
,
1660 IDirect3DDevice9Impl_SetDepthStencilSurface
,
1661 IDirect3DDevice9Impl_GetDepthStencilSurface
,
1662 IDirect3DDevice9Impl_BeginScene
,
1663 IDirect3DDevice9Impl_EndScene
,
1664 IDirect3DDevice9Impl_Clear
,
1665 IDirect3DDevice9Impl_SetTransform
,
1666 IDirect3DDevice9Impl_GetTransform
,
1667 IDirect3DDevice9Impl_MultiplyTransform
,
1668 IDirect3DDevice9Impl_SetViewport
,
1669 IDirect3DDevice9Impl_GetViewport
,
1670 IDirect3DDevice9Impl_SetMaterial
,
1671 IDirect3DDevice9Impl_GetMaterial
,
1672 IDirect3DDevice9Impl_SetLight
,
1673 IDirect3DDevice9Impl_GetLight
,
1674 IDirect3DDevice9Impl_LightEnable
,
1675 IDirect3DDevice9Impl_GetLightEnable
,
1676 IDirect3DDevice9Impl_SetClipPlane
,
1677 IDirect3DDevice9Impl_GetClipPlane
,
1678 IDirect3DDevice9Impl_SetRenderState
,
1679 IDirect3DDevice9Impl_GetRenderState
,
1680 IDirect3DDevice9Impl_CreateStateBlock
,
1681 IDirect3DDevice9Impl_BeginStateBlock
,
1682 IDirect3DDevice9Impl_EndStateBlock
,
1683 IDirect3DDevice9Impl_SetClipStatus
,
1684 IDirect3DDevice9Impl_GetClipStatus
,
1685 IDirect3DDevice9Impl_GetTexture
,
1686 IDirect3DDevice9Impl_SetTexture
,
1687 IDirect3DDevice9Impl_GetTextureStageState
,
1688 IDirect3DDevice9Impl_SetTextureStageState
,
1689 IDirect3DDevice9Impl_GetSamplerState
,
1690 IDirect3DDevice9Impl_SetSamplerState
,
1691 IDirect3DDevice9Impl_ValidateDevice
,
1692 IDirect3DDevice9Impl_SetPaletteEntries
,
1693 IDirect3DDevice9Impl_GetPaletteEntries
,
1694 IDirect3DDevice9Impl_SetCurrentTexturePalette
,
1695 IDirect3DDevice9Impl_GetCurrentTexturePalette
,
1696 IDirect3DDevice9Impl_SetScissorRect
,
1697 IDirect3DDevice9Impl_GetScissorRect
,
1698 IDirect3DDevice9Impl_SetSoftwareVertexProcessing
,
1699 IDirect3DDevice9Impl_GetSoftwareVertexProcessing
,
1700 IDirect3DDevice9Impl_SetNPatchMode
,
1701 IDirect3DDevice9Impl_GetNPatchMode
,
1702 IDirect3DDevice9Impl_DrawPrimitive
,
1703 IDirect3DDevice9Impl_DrawIndexedPrimitive
,
1704 IDirect3DDevice9Impl_DrawPrimitiveUP
,
1705 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP
,
1706 IDirect3DDevice9Impl_ProcessVertices
,
1707 IDirect3DDevice9Impl_CreateVertexDeclaration
,
1708 IDirect3DDevice9Impl_SetVertexDeclaration
,
1709 IDirect3DDevice9Impl_GetVertexDeclaration
,
1710 IDirect3DDevice9Impl_SetFVF
,
1711 IDirect3DDevice9Impl_GetFVF
,
1712 IDirect3DDevice9Impl_CreateVertexShader
,
1713 IDirect3DDevice9Impl_SetVertexShader
,
1714 IDirect3DDevice9Impl_GetVertexShader
,
1715 IDirect3DDevice9Impl_SetVertexShaderConstantF
,
1716 IDirect3DDevice9Impl_GetVertexShaderConstantF
,
1717 IDirect3DDevice9Impl_SetVertexShaderConstantI
,
1718 IDirect3DDevice9Impl_GetVertexShaderConstantI
,
1719 IDirect3DDevice9Impl_SetVertexShaderConstantB
,
1720 IDirect3DDevice9Impl_GetVertexShaderConstantB
,
1721 IDirect3DDevice9Impl_SetStreamSource
,
1722 IDirect3DDevice9Impl_GetStreamSource
,
1723 IDirect3DDevice9Impl_SetStreamSourceFreq
,
1724 IDirect3DDevice9Impl_GetStreamSourceFreq
,
1725 IDirect3DDevice9Impl_SetIndices
,
1726 IDirect3DDevice9Impl_GetIndices
,
1727 IDirect3DDevice9Impl_CreatePixelShader
,
1728 IDirect3DDevice9Impl_SetPixelShader
,
1729 IDirect3DDevice9Impl_GetPixelShader
,
1730 IDirect3DDevice9Impl_SetPixelShaderConstantF
,
1731 IDirect3DDevice9Impl_GetPixelShaderConstantF
,
1732 IDirect3DDevice9Impl_SetPixelShaderConstantI
,
1733 IDirect3DDevice9Impl_GetPixelShaderConstantI
,
1734 IDirect3DDevice9Impl_SetPixelShaderConstantB
,
1735 IDirect3DDevice9Impl_GetPixelShaderConstantB
,
1736 IDirect3DDevice9Impl_DrawRectPatch
,
1737 IDirect3DDevice9Impl_DrawTriPatch
,
1738 IDirect3DDevice9Impl_DeletePatch
,
1739 IDirect3DDevice9Impl_CreateQuery
,
1740 /* IDirect3DDevice9Ex */
1741 IDirect3DDevice9ExImpl_SetConvolutionMonoKernel
,
1742 IDirect3DDevice9ExImpl_ComposeRects
,
1743 IDirect3DDevice9ExImpl_PresentEx
,
1744 IDirect3DDevice9ExImpl_GetGPUThreadPriority
,
1745 IDirect3DDevice9ExImpl_SetGPUThreadPriority
,
1746 IDirect3DDevice9ExImpl_WaitForVBlank
,
1747 IDirect3DDevice9ExImpl_CheckresourceResidency
,
1748 IDirect3DDevice9ExImpl_SetMaximumFrameLatency
,
1749 IDirect3DDevice9ExImpl_GetMaximumFrameLatency
,
1750 IDirect3DDevice9ExImpl_CheckdeviceState
,
1751 IDirect3DDevice9ExImpl_CreateRenderTargetEx
,
1752 IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx
,
1753 IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx
,
1754 IDirect3DDevice9ExImpl_ResetEx
,
1755 IDirect3DDevice9ExImpl_GetDisplayModeEx
1758 ULONG WINAPI
D3D9CB_DestroySurface(IWineD3DSurface
*pSurface
) {
1759 IDirect3DSurface9Impl
* surfaceParent
;
1760 TRACE("(%p) call back\n", pSurface
);
1762 IWineD3DSurface_GetParent(pSurface
, (IUnknown
**) &surfaceParent
);
1763 /* GetParent's AddRef was forwarded to an object in destruction.
1764 * Releasing it here again would cause an endless recursion. */
1765 surfaceParent
->forwardReference
= NULL
;
1766 return IDirect3DSurface9_Release((IDirect3DSurface9
*) surfaceParent
);
1769 /* IWineD3DDeviceParent IUnknown methods */
1771 static inline struct IDirect3DDevice9Impl
*device_from_device_parent(IWineD3DDeviceParent
*iface
)
1773 return (struct IDirect3DDevice9Impl
*)((char*)iface
1774 - FIELD_OFFSET(struct IDirect3DDevice9Impl
, device_parent_vtbl
));
1777 static HRESULT STDMETHODCALLTYPE
device_parent_QueryInterface(IWineD3DDeviceParent
*iface
, REFIID riid
, void **object
)
1779 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1780 return IDirect3DDevice9Impl_QueryInterface((IDirect3DDevice9Ex
*)This
, riid
, object
);
1783 static ULONG STDMETHODCALLTYPE
device_parent_AddRef(IWineD3DDeviceParent
*iface
)
1785 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1786 return IDirect3DDevice9Impl_AddRef((IDirect3DDevice9Ex
*)This
);
1789 static ULONG STDMETHODCALLTYPE
device_parent_Release(IWineD3DDeviceParent
*iface
)
1791 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1792 return IDirect3DDevice9Impl_Release((IDirect3DDevice9Ex
*)This
);
1795 /* IWineD3DDeviceParent methods */
1797 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSurface(IWineD3DDeviceParent
*iface
,
1798 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, DWORD usage
,
1799 WINED3DPOOL pool
, UINT level
, WINED3DCUBEMAP_FACES face
, IWineD3DSurface
**surface
)
1801 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1802 IDirect3DSurface9Impl
*d3d_surface
;
1803 BOOL lockable
= TRUE
;
1806 TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
1807 "\tpool %#x, level %u, face %u, surface %p\n",
1808 iface
, superior
, width
, height
, format
, usage
, pool
, level
, face
, surface
);
1810 if (pool
== D3DPOOL_DEFAULT
&& !(usage
& D3DUSAGE_DYNAMIC
)) lockable
= FALSE
;
1812 hr
= IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex
*)This
, width
, height
,
1813 format
, lockable
, FALSE
/* Discard */, level
, (IDirect3DSurface9
**)&d3d_surface
,
1814 D3DRTYPE_SURFACE
, usage
, pool
, D3DMULTISAMPLE_NONE
, 0 /* MultisampleQuality */, NULL
);
1817 ERR("(%p) CreateSurface failed, returning %#x\n", iface
, hr
);
1821 *surface
= d3d_surface
->wineD3DSurface
;
1822 d3d_surface
->container
= superior
;
1823 IDirect3DDevice9Ex_Release(d3d_surface
->parentDevice
);
1824 d3d_surface
->parentDevice
= NULL
;
1825 d3d_surface
->forwardReference
= superior
;
1830 static HRESULT STDMETHODCALLTYPE
device_parent_CreateRenderTarget(IWineD3DDeviceParent
*iface
,
1831 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
1832 DWORD multisample_quality
, BOOL lockable
, IWineD3DSurface
**surface
)
1834 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1835 IDirect3DSurface9Impl
*d3d_surface
;
1838 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
1839 "\tmultisample_quality %u, lockable %u, surface %p\n",
1840 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, lockable
, surface
);
1842 hr
= IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex
*)This
, width
, height
, format
,
1843 multisample_type
, multisample_quality
, lockable
, (IDirect3DSurface9
**)&d3d_surface
, NULL
);
1846 ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface
, hr
);
1850 *surface
= d3d_surface
->wineD3DSurface
;
1851 d3d_surface
->container
= superior
;
1852 d3d_surface
->isImplicit
= TRUE
;
1853 /* Implicit surfaces are created with an refcount of 0 */
1854 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
1859 static HRESULT STDMETHODCALLTYPE
device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent
*iface
,
1860 IUnknown
*superior
, UINT width
, UINT height
, WINED3DFORMAT format
, WINED3DMULTISAMPLE_TYPE multisample_type
,
1861 DWORD multisample_quality
, BOOL discard
, IWineD3DSurface
**surface
)
1863 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1864 IDirect3DSurface9Impl
*d3d_surface
;
1867 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
1868 "\tmultisample_quality %u, discard %u, surface %p\n",
1869 iface
, superior
, width
, height
, format
, multisample_type
, multisample_quality
, discard
, surface
);
1871 hr
= IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex
*)This
, width
, height
, format
,
1872 multisample_type
, multisample_quality
, discard
, (IDirect3DSurface9
**)&d3d_surface
, NULL
);
1875 ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface
, hr
);
1879 *surface
= d3d_surface
->wineD3DSurface
;
1880 d3d_surface
->container
= (IUnknown
*)This
;
1881 d3d_surface
->isImplicit
= TRUE
;
1882 /* Implicit surfaces are created with an refcount of 0 */
1883 IDirect3DSurface9_Release((IDirect3DSurface9
*)d3d_surface
);
1888 static HRESULT STDMETHODCALLTYPE
device_parent_CreateVolume(IWineD3DDeviceParent
*iface
,
1889 IUnknown
*superior
, UINT width
, UINT height
, UINT depth
, WINED3DFORMAT format
,
1890 WINED3DPOOL pool
, DWORD usage
, IWineD3DVolume
**volume
)
1892 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1893 IDirect3DVolume9Impl
*object
;
1896 TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
1897 iface
, superior
, width
, height
, depth
, format
, pool
, usage
, volume
);
1899 /* Allocate the storage for the device */
1900 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
1903 FIXME("Allocation of memory failed\n");
1905 return D3DERR_OUTOFVIDEOMEMORY
;
1908 object
->lpVtbl
= &Direct3DVolume9_Vtbl
;
1910 hr
= IWineD3DDevice_CreateVolume(This
->WineD3DDevice
, width
, height
, depth
, usage
& WINED3DUSAGE_MASK
,
1911 format
, pool
, &object
->wineD3DVolume
, NULL
, (IUnknown
*)object
);
1914 ERR("(%p) CreateVolume failed, returning %#x\n", iface
, hr
);
1915 HeapFree(GetProcessHeap(), 0, object
);
1920 *volume
= object
->wineD3DVolume
;
1921 object
->container
= superior
;
1922 object
->forwardReference
= superior
;
1924 TRACE("(%p) Created volume %p\n", iface
, *volume
);
1929 static HRESULT STDMETHODCALLTYPE
device_parent_CreateSwapChain(IWineD3DDeviceParent
*iface
,
1930 WINED3DPRESENT_PARAMETERS
*present_parameters
, IWineD3DSwapChain
**swapchain
)
1932 struct IDirect3DDevice9Impl
*This
= device_from_device_parent(iface
);
1933 IDirect3DSwapChain9Impl
*d3d_swapchain
;
1934 D3DPRESENT_PARAMETERS local_parameters
;
1937 TRACE("iface %p, present_parameters %p, swapchain %p\n", iface
, present_parameters
, swapchain
);
1939 /* Copy the presentation parameters */
1940 local_parameters
.BackBufferWidth
= present_parameters
->BackBufferWidth
;
1941 local_parameters
.BackBufferHeight
= present_parameters
->BackBufferHeight
;
1942 local_parameters
.BackBufferFormat
= present_parameters
->BackBufferFormat
;
1943 local_parameters
.BackBufferCount
= present_parameters
->BackBufferCount
;
1944 local_parameters
.MultiSampleType
= present_parameters
->MultiSampleType
;
1945 local_parameters
.MultiSampleQuality
= present_parameters
->MultiSampleQuality
;
1946 local_parameters
.SwapEffect
= present_parameters
->SwapEffect
;
1947 local_parameters
.hDeviceWindow
= present_parameters
->hDeviceWindow
;
1948 local_parameters
.Windowed
= present_parameters
->Windowed
;
1949 local_parameters
.EnableAutoDepthStencil
= present_parameters
->EnableAutoDepthStencil
;
1950 local_parameters
.AutoDepthStencilFormat
= present_parameters
->AutoDepthStencilFormat
;
1951 local_parameters
.Flags
= present_parameters
->Flags
;
1952 local_parameters
.FullScreen_RefreshRateInHz
= present_parameters
->FullScreen_RefreshRateInHz
;
1953 local_parameters
.PresentationInterval
= present_parameters
->PresentationInterval
;
1955 hr
= IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex
*)This
,
1956 &local_parameters
, (IDirect3DSwapChain9
**)&d3d_swapchain
);
1959 ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface
, hr
);
1964 *swapchain
= d3d_swapchain
->wineD3DSwapChain
;
1965 d3d_swapchain
->isImplicit
= TRUE
;
1966 /* Implicit swap chains are created with an refcount of 0 */
1967 IDirect3DSwapChain9_Release((IDirect3DSwapChain9
*)d3d_swapchain
);
1969 /* Copy back the presentation parameters */
1970 present_parameters
->BackBufferWidth
= local_parameters
.BackBufferWidth
;
1971 present_parameters
->BackBufferHeight
= local_parameters
.BackBufferHeight
;
1972 present_parameters
->BackBufferFormat
= local_parameters
.BackBufferFormat
;
1973 present_parameters
->BackBufferCount
= local_parameters
.BackBufferCount
;
1974 present_parameters
->MultiSampleType
= local_parameters
.MultiSampleType
;
1975 present_parameters
->MultiSampleQuality
= local_parameters
.MultiSampleQuality
;
1976 present_parameters
->SwapEffect
= local_parameters
.SwapEffect
;
1977 present_parameters
->hDeviceWindow
= local_parameters
.hDeviceWindow
;
1978 present_parameters
->Windowed
= local_parameters
.Windowed
;
1979 present_parameters
->EnableAutoDepthStencil
= local_parameters
.EnableAutoDepthStencil
;
1980 present_parameters
->AutoDepthStencilFormat
= local_parameters
.AutoDepthStencilFormat
;
1981 present_parameters
->Flags
= local_parameters
.Flags
;
1982 present_parameters
->FullScreen_RefreshRateInHz
= local_parameters
.FullScreen_RefreshRateInHz
;
1983 present_parameters
->PresentationInterval
= local_parameters
.PresentationInterval
;
1988 const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl
=
1990 /* IUnknown methods */
1991 device_parent_QueryInterface
,
1992 device_parent_AddRef
,
1993 device_parent_Release
,
1994 /* IWineD3DDeviceParent methods */
1995 device_parent_CreateSurface
,
1996 device_parent_CreateRenderTarget
,
1997 device_parent_CreateDepthStencilSurface
,
1998 device_parent_CreateVolume
,
1999 device_parent_CreateSwapChain
,