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(LPDIRECT3DDEVICE9 iface
, REFIID riid
, LPVOID
* ppobj
) {
31 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
33 if (IsEqualGUID(riid
, &IID_IUnknown
)
34 || IsEqualGUID(riid
, &IID_IDirect3DDevice9
)) {
35 IUnknown_AddRef(iface
);
40 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
45 static ULONG WINAPI
IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9 iface
) {
46 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
47 ULONG ref
= InterlockedIncrement(&This
->ref
);
49 TRACE("(%p) : AddRef from %d\n", This
, ref
- 1);
54 static ULONG WINAPI
IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface
) {
55 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
58 if (This
->inDestruction
) return 0;
59 ref
= InterlockedDecrement(&This
->ref
);
61 TRACE("(%p) : ReleaseRef to %d\n", This
, ref
);
65 This
->inDestruction
= TRUE
;
67 EnterCriticalSection(&d3d9_cs
);
68 for(i
= 0; i
< This
->numConvertedDecls
; i
++) {
69 /* Unless Wine is buggy or the app has a bug the refcount will be 0, because decls hold a reference to the
72 IDirect3DVertexDeclaration9Impl_Destroy(This
->convertedDecls
[i
]);
74 HeapFree(GetProcessHeap(), 0, This
->convertedDecls
);
76 IWineD3DDevice_Uninit3D(This
->WineD3DDevice
, D3D9CB_DestroyDepthStencilSurface
, D3D9CB_DestroySwapChain
);
77 IWineD3DDevice_Release(This
->WineD3DDevice
);
78 LeaveCriticalSection(&d3d9_cs
);
79 HeapFree(GetProcessHeap(), 0, This
);
84 /* IDirect3DDevice Interface follow: */
85 static HRESULT WINAPI
IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface
) {
86 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
88 TRACE("(%p) : Relay\n", This
);
90 EnterCriticalSection(&d3d9_cs
);
91 hr
= IWineD3DDevice_TestCooperativeLevel(This
->WineD3DDevice
);
92 LeaveCriticalSection(&d3d9_cs
);
96 static UINT WINAPI
IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface
) {
97 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
99 TRACE("(%p) Relay\n", This
);
101 EnterCriticalSection(&d3d9_cs
);
102 hr
= IWineD3DDevice_GetAvailableTextureMem(This
->WineD3DDevice
);
103 LeaveCriticalSection(&d3d9_cs
);
107 static HRESULT WINAPI
IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9 iface
) {
108 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
110 TRACE("(%p) : Relay\n", This
);
112 EnterCriticalSection(&d3d9_cs
);
113 hr
= IWineD3DDevice_EvictManagedResources(This
->WineD3DDevice
);
114 LeaveCriticalSection(&d3d9_cs
);
118 HRESULT WINAPI
IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface
, IDirect3D9
** ppD3D9
) {
119 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
123 TRACE("(%p) Relay\n", This
);
125 if (NULL
== ppD3D9
) {
126 return D3DERR_INVALIDCALL
;
129 EnterCriticalSection(&d3d9_cs
);
130 hr
= IWineD3DDevice_GetDirect3D(This
->WineD3DDevice
, &pWineD3D
);
131 if (hr
== D3D_OK
&& pWineD3D
!= NULL
)
133 IWineD3D_GetParent(pWineD3D
,(IUnknown
**)ppD3D9
);
134 IWineD3D_Release(pWineD3D
);
136 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
139 TRACE("(%p) returning %p\n", This
, *ppD3D9
);
140 LeaveCriticalSection(&d3d9_cs
);
144 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9 iface
, D3DCAPS9
* pCaps
) {
145 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
146 HRESULT hrc
= D3D_OK
;
147 WINED3DCAPS
*pWineCaps
;
149 TRACE("(%p) : Relay pCaps %p\n", This
, pCaps
);
151 return D3DERR_INVALIDCALL
;
153 pWineCaps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WINED3DCAPS
));
154 if(pWineCaps
== NULL
){
155 return D3DERR_INVALIDCALL
; /* well this is what MSDN says to return */
158 memset(pCaps
, 0, sizeof(*pCaps
));
159 D3D9CAPSTOWINECAPS(pCaps
, pWineCaps
)
160 EnterCriticalSection(&d3d9_cs
);
161 hrc
= IWineD3DDevice_GetDeviceCaps(This
->WineD3DDevice
, pWineCaps
);
162 LeaveCriticalSection(&d3d9_cs
);
163 HeapFree(GetProcessHeap(), 0, pWineCaps
);
165 /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
166 pCaps
->DevCaps2
|= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
;
170 TRACE("Returning %p %p\n", This
, pCaps
);
174 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, D3DDISPLAYMODE
* pMode
) {
175 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
177 TRACE("(%p) Relay\n", This
);
179 EnterCriticalSection(&d3d9_cs
);
180 hr
= IWineD3DDevice_GetDisplayMode(This
->WineD3DDevice
, iSwapChain
, (WINED3DDISPLAYMODE
*) pMode
);
181 LeaveCriticalSection(&d3d9_cs
);
185 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9 iface
, D3DDEVICE_CREATION_PARAMETERS
*pParameters
) {
186 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
188 TRACE("(%p) Relay\n", This
);
190 EnterCriticalSection(&d3d9_cs
);
191 hr
= IWineD3DDevice_GetCreationParameters(This
->WineD3DDevice
, (WINED3DDEVICE_CREATION_PARAMETERS
*) pParameters
);
192 LeaveCriticalSection(&d3d9_cs
);
196 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 iface
, UINT XHotSpot
, UINT YHotSpot
, IDirect3DSurface9
* pCursorBitmap
) {
197 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
198 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pCursorBitmap
;
201 TRACE("(%p) Relay\n", This
);
203 WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
204 return WINED3DERR_INVALIDCALL
;
207 EnterCriticalSection(&d3d9_cs
);
208 hr
= IWineD3DDevice_SetCursorProperties(This
->WineD3DDevice
, XHotSpot
, YHotSpot
, pSurface
->wineD3DSurface
);
209 LeaveCriticalSection(&d3d9_cs
);
213 static void WINAPI
IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9 iface
, int XScreenSpace
, int YScreenSpace
, DWORD Flags
) {
214 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
215 TRACE("(%p) Relay\n", This
);
217 EnterCriticalSection(&d3d9_cs
);
218 IWineD3DDevice_SetCursorPosition(This
->WineD3DDevice
, XScreenSpace
, YScreenSpace
, Flags
);
219 LeaveCriticalSection(&d3d9_cs
);
222 static BOOL WINAPI
IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9 iface
, BOOL bShow
) {
223 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
225 TRACE("(%p) Relay\n", This
);
227 EnterCriticalSection(&d3d9_cs
);
228 ret
= IWineD3DDevice_ShowCursor(This
->WineD3DDevice
, bShow
);
229 LeaveCriticalSection(&d3d9_cs
);
233 static HRESULT WINAPI
IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9 iface
, D3DPRESENT_PARAMETERS
* pPresentationParameters
) {
234 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
235 WINED3DPRESENT_PARAMETERS localParameters
;
238 TRACE("(%p) Relay pPresentationParameters(%p)\n", This
, pPresentationParameters
);
240 localParameters
.BackBufferWidth
= pPresentationParameters
->BackBufferWidth
;
241 localParameters
.BackBufferHeight
= pPresentationParameters
->BackBufferHeight
;
242 localParameters
.BackBufferFormat
= pPresentationParameters
->BackBufferFormat
;
243 localParameters
.BackBufferCount
= pPresentationParameters
->BackBufferCount
;
244 localParameters
.MultiSampleType
= pPresentationParameters
->MultiSampleType
;
245 localParameters
.MultiSampleQuality
= pPresentationParameters
->MultiSampleQuality
;
246 localParameters
.SwapEffect
= pPresentationParameters
->SwapEffect
;
247 localParameters
.hDeviceWindow
= pPresentationParameters
->hDeviceWindow
;
248 localParameters
.Windowed
= pPresentationParameters
->Windowed
;
249 localParameters
.EnableAutoDepthStencil
= pPresentationParameters
->EnableAutoDepthStencil
;
250 localParameters
.AutoDepthStencilFormat
= pPresentationParameters
->AutoDepthStencilFormat
;
251 localParameters
.Flags
= pPresentationParameters
->Flags
;
252 localParameters
.FullScreen_RefreshRateInHz
= pPresentationParameters
->FullScreen_RefreshRateInHz
;
253 localParameters
.PresentationInterval
= pPresentationParameters
->PresentationInterval
;
255 EnterCriticalSection(&d3d9_cs
);
256 hr
= IWineD3DDevice_Reset(This
->WineD3DDevice
, &localParameters
);
257 LeaveCriticalSection(&d3d9_cs
);
259 pPresentationParameters
->BackBufferWidth
= localParameters
.BackBufferWidth
;
260 pPresentationParameters
->BackBufferHeight
= localParameters
.BackBufferHeight
;
261 pPresentationParameters
->BackBufferFormat
= localParameters
.BackBufferFormat
;
262 pPresentationParameters
->BackBufferCount
= localParameters
.BackBufferCount
;
263 pPresentationParameters
->MultiSampleType
= localParameters
.MultiSampleType
;
264 pPresentationParameters
->MultiSampleQuality
= localParameters
.MultiSampleQuality
;
265 pPresentationParameters
->SwapEffect
= localParameters
.SwapEffect
;
266 pPresentationParameters
->hDeviceWindow
= localParameters
.hDeviceWindow
;
267 pPresentationParameters
->Windowed
= localParameters
.Windowed
;
268 pPresentationParameters
->EnableAutoDepthStencil
= localParameters
.EnableAutoDepthStencil
;
269 pPresentationParameters
->AutoDepthStencilFormat
= localParameters
.AutoDepthStencilFormat
;
270 pPresentationParameters
->Flags
= localParameters
.Flags
;
271 pPresentationParameters
->FullScreen_RefreshRateInHz
= localParameters
.FullScreen_RefreshRateInHz
;
272 pPresentationParameters
->PresentationInterval
= localParameters
.PresentationInterval
;
277 static HRESULT WINAPI
IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9 iface
, CONST RECT
* pSourceRect
,CONST RECT
* pDestRect
,HWND hDestWindowOverride
,CONST RGNDATA
*
279 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
281 TRACE("(%p) Relay\n", This
);
283 EnterCriticalSection(&d3d9_cs
);
284 hr
= IWineD3DDevice_Present(This
->WineD3DDevice
, pSourceRect
, pDestRect
, hDestWindowOverride
, pDirtyRegion
);
285 LeaveCriticalSection(&d3d9_cs
);
289 static HRESULT WINAPI
IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, UINT BackBuffer
, D3DBACKBUFFER_TYPE Type
, IDirect3DSurface9
** ppBackBuffer
) {
290 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
291 IWineD3DSurface
*retSurface
= NULL
;
294 TRACE("(%p) Relay\n", This
);
296 EnterCriticalSection(&d3d9_cs
);
297 rc
= IWineD3DDevice_GetBackBuffer(This
->WineD3DDevice
, iSwapChain
, BackBuffer
, (WINED3DBACKBUFFER_TYPE
) Type
, &retSurface
);
298 if (rc
== D3D_OK
&& NULL
!= retSurface
&& NULL
!= ppBackBuffer
) {
299 IWineD3DSurface_GetParent(retSurface
, (IUnknown
**)ppBackBuffer
);
300 IWineD3DSurface_Release(retSurface
);
302 LeaveCriticalSection(&d3d9_cs
);
305 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, D3DRASTER_STATUS
* pRasterStatus
) {
306 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
308 TRACE("(%p) Relay\n", This
);
310 EnterCriticalSection(&d3d9_cs
);
311 hr
= IWineD3DDevice_GetRasterStatus(This
->WineD3DDevice
, iSwapChain
, (WINED3DRASTER_STATUS
*) pRasterStatus
);
312 LeaveCriticalSection(&d3d9_cs
);
316 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface
, BOOL bEnableDialogs
) {
317 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
319 TRACE("(%p) Relay\n", This
);
321 EnterCriticalSection(&d3d9_cs
);
322 hr
= IWineD3DDevice_SetDialogBoxMode(This
->WineD3DDevice
, bEnableDialogs
);
323 LeaveCriticalSection(&d3d9_cs
);
327 static void WINAPI
IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, DWORD Flags
, CONST D3DGAMMARAMP
* pRamp
) {
329 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
330 TRACE("(%p) Relay\n", This
);
332 EnterCriticalSection(&d3d9_cs
);
333 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
334 IWineD3DDevice_SetGammaRamp(This
->WineD3DDevice
, iSwapChain
, Flags
, (CONST WINED3DGAMMARAMP
*)pRamp
);
335 LeaveCriticalSection(&d3d9_cs
);
338 static void WINAPI
IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, D3DGAMMARAMP
* pRamp
) {
339 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
340 TRACE("(%p) Relay\n", This
);
342 EnterCriticalSection(&d3d9_cs
);
343 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
344 IWineD3DDevice_GetGammaRamp(This
->WineD3DDevice
, iSwapChain
, (WINED3DGAMMARAMP
*) pRamp
);
345 LeaveCriticalSection(&d3d9_cs
);
349 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9 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
) {
351 IDirect3DSurface9Impl
*object
;
352 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
353 TRACE("(%p) Relay\n", This
);
354 if(MultisampleQuality
< 0) {
355 FIXME("MultisampleQuality out of range %d, substituting 0\n", MultisampleQuality
);
356 /*FIXME: Find out what windows does with a MultisampleQuality < 0 */
357 MultisampleQuality
=0;
360 if(MultisampleQuality
> 0){
361 FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality
);
364 [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.
367 MultisampleQuality
=0;
369 /*FIXME: Check MAX bounds of MultisampleQuality*/
371 /* Allocate the storage for the device */
372 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DSurface9Impl
));
373 if (NULL
== object
) {
374 FIXME("Allocation of memory failed\n");
375 return D3DERR_OUTOFVIDEOMEMORY
;
378 object
->lpVtbl
= &Direct3DSurface9_Vtbl
;
381 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This
, Width
, Height
, Format
, *ppSurface
);
383 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
);
385 if (hrc
!= D3D_OK
|| NULL
== object
->wineD3DSurface
) {
388 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This
);
389 HeapFree(GetProcessHeap(), 0, object
);
391 IUnknown_AddRef(iface
);
392 object
->parentDevice
= iface
;
393 TRACE("(%p) : Created surface %p\n", This
, object
);
394 *ppSurface
= (LPDIRECT3DSURFACE9
) object
;
401 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
,
402 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
403 DWORD MultisampleQuality
, BOOL Lockable
,
404 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
408 /* Is this correct? */
409 EnterCriticalSection(&d3d9_cs
);
410 hr
= IDirect3DDevice9Impl_CreateSurface(iface
,Width
,Height
,Format
,Lockable
,FALSE
/*Discard*/, 0/*Level*/, ppSurface
,D3DRTYPE_SURFACE
,D3DUSAGE_RENDERTARGET
,D3DPOOL_DEFAULT
,MultiSample
,MultisampleQuality
,pSharedHandle
);
411 LeaveCriticalSection(&d3d9_cs
);
415 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
,
416 D3DFORMAT Format
, D3DMULTISAMPLE_TYPE MultiSample
,
417 DWORD MultisampleQuality
, BOOL Discard
,
418 IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
422 EnterCriticalSection(&d3d9_cs
);
423 hr
= IDirect3DDevice9Impl_CreateSurface(iface
,Width
,Height
,Format
,TRUE
/* Lockable */,Discard
, 0/* Level */
424 ,ppSurface
,D3DRTYPE_SURFACE
,D3DUSAGE_DEPTHSTENCIL
,
425 D3DPOOL_DEFAULT
,MultiSample
,MultisampleQuality
,pSharedHandle
);
426 LeaveCriticalSection(&d3d9_cs
);
431 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestinationSurface
, CONST POINT
* pDestPoint
) {
432 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
434 TRACE("(%p) Relay\n" , This
);
436 EnterCriticalSection(&d3d9_cs
);
437 hr
= IWineD3DDevice_UpdateSurface(This
->WineD3DDevice
, ((IDirect3DSurface9Impl
*)pSourceSurface
)->wineD3DSurface
, pSourceRect
, ((IDirect3DSurface9Impl
*)pDestinationSurface
)->wineD3DSurface
, pDestPoint
);
438 LeaveCriticalSection(&d3d9_cs
);
442 static HRESULT WINAPI
IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9 iface
, IDirect3DBaseTexture9
* pSourceTexture
, IDirect3DBaseTexture9
* pDestinationTexture
) {
443 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
445 TRACE("(%p) Relay\n" , This
);
447 EnterCriticalSection(&d3d9_cs
);
448 hr
= IWineD3DDevice_UpdateTexture(This
->WineD3DDevice
, ((IDirect3DBaseTexture9Impl
*)pSourceTexture
)->wineD3DBaseTexture
, ((IDirect3DBaseTexture9Impl
*)pDestinationTexture
)->wineD3DBaseTexture
);
449 LeaveCriticalSection(&d3d9_cs
);
453 /* This isn't in MSDN!
454 static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBuffer(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pDestSurface) {
455 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
456 FIXME("(%p) : stub\n", This);
461 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pRenderTarget
, IDirect3DSurface9
* pDestSurface
) {
462 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
463 IDirect3DSurface9Impl
*renderTarget
= (IDirect3DSurface9Impl
*)pRenderTarget
;
464 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
466 TRACE("(%p)->(%p,%p)\n" , This
, renderTarget
, destSurface
);
468 EnterCriticalSection(&d3d9_cs
);
469 hr
= IWineD3DSurface_BltFast(destSurface
->wineD3DSurface
, 0, 0, renderTarget
->wineD3DSurface
, NULL
, WINEDDBLTFAST_NOCOLORKEY
);
470 LeaveCriticalSection(&d3d9_cs
);
474 static HRESULT WINAPI
IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9 iface
, UINT iSwapChain
, IDirect3DSurface9
* pDestSurface
) {
475 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
476 IDirect3DSurface9Impl
*destSurface
= (IDirect3DSurface9Impl
*)pDestSurface
;
478 TRACE("(%p) Relay\n" , This
);
480 EnterCriticalSection(&d3d9_cs
);
481 hr
= IWineD3DDevice_GetFrontBufferData(This
->WineD3DDevice
, iSwapChain
, destSurface
->wineD3DSurface
);
482 LeaveCriticalSection(&d3d9_cs
);
486 static HRESULT WINAPI
IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pSourceSurface
, CONST RECT
* pSourceRect
, IDirect3DSurface9
* pDestSurface
, CONST RECT
* pDestRect
, D3DTEXTUREFILTERTYPE Filter
) {
487 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
488 IDirect3DSurface9Impl
*src
= (IDirect3DSurface9Impl
*) pSourceSurface
;
489 IDirect3DSurface9Impl
*dst
= (IDirect3DSurface9Impl
*) pDestSurface
;
492 TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This
, src
, pSourceRect
, dst
, pDestRect
, Filter
);
493 EnterCriticalSection(&d3d9_cs
);
494 hr
= IWineD3DSurface_Blt(dst
->wineD3DSurface
, (RECT
*) pDestRect
, src
->wineD3DSurface
, (RECT
*) pSourceRect
, 0, NULL
, Filter
);
495 LeaveCriticalSection(&d3d9_cs
);
499 static HRESULT WINAPI
IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pSurface
, CONST RECT
* pRect
, D3DCOLOR color
) {
500 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
501 IDirect3DSurface9Impl
*surface
= (IDirect3DSurface9Impl
*)pSurface
;
503 TRACE("(%p) Relay\n" , This
);
505 /* Note: D3DRECT is compatible with WINED3DRECT */
506 EnterCriticalSection(&d3d9_cs
);
507 hr
= IWineD3DDevice_ColorFill(This
->WineD3DDevice
, surface
->wineD3DSurface
, (CONST WINED3DRECT
*)pRect
, color
);
508 LeaveCriticalSection(&d3d9_cs
);
512 static HRESULT WINAPI
IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface
, UINT Width
, UINT Height
, D3DFORMAT Format
, D3DPOOL Pool
, IDirect3DSurface9
**ppSurface
, HANDLE
* pSharedHandle
) {
515 if(Pool
== D3DPOOL_MANAGED
){
516 FIXME("Attempting to create a managed offscreen plain surface\n");
517 return D3DERR_INVALIDCALL
;
519 /*MSDN: D3DPOOL_SCRATCH will return a surface that has identical characteristics to a surface created by the Microsoft DirectX 8.x method CreateImageSurface.
521 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
523 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
524 Why, their always lockable?
525 should I change the usage to dynamic?
527 EnterCriticalSection(&d3d9_cs
);
528 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
);
529 LeaveCriticalSection(&d3d9_cs
);
533 /* TODO: move to wineD3D */
534 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
* pRenderTarget
) {
535 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
536 IDirect3DSurface9Impl
*pSurface
= (IDirect3DSurface9Impl
*)pRenderTarget
;
538 TRACE("(%p) Relay\n" , This
);
540 EnterCriticalSection(&d3d9_cs
);
541 hr
= IWineD3DDevice_SetRenderTarget(This
->WineD3DDevice
, RenderTargetIndex
, pSurface
? pSurface
->wineD3DSurface
: NULL
);
542 LeaveCriticalSection(&d3d9_cs
);
546 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface
, DWORD RenderTargetIndex
, IDirect3DSurface9
**ppRenderTarget
) {
547 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
549 IWineD3DSurface
*pRenderTarget
;
551 TRACE("(%p) Relay\n" , This
);
553 if (ppRenderTarget
== NULL
) {
554 return D3DERR_INVALIDCALL
;
557 EnterCriticalSection(&d3d9_cs
);
558 hr
=IWineD3DDevice_GetRenderTarget(This
->WineD3DDevice
,RenderTargetIndex
,&pRenderTarget
);
560 if (hr
== D3D_OK
&& pRenderTarget
!= NULL
) {
561 IWineD3DSurface_GetParent(pRenderTarget
,(IUnknown
**)ppRenderTarget
);
562 IWineD3DSurface_Release(pRenderTarget
);
564 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
565 *ppRenderTarget
= NULL
;
567 LeaveCriticalSection(&d3d9_cs
);
572 static HRESULT WINAPI
IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
* pZStencilSurface
) {
573 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
574 IDirect3DSurface9Impl
*pSurface
;
576 TRACE("(%p) Relay\n" , This
);
578 pSurface
= (IDirect3DSurface9Impl
*)pZStencilSurface
;
579 EnterCriticalSection(&d3d9_cs
);
580 hr
= IWineD3DDevice_SetDepthStencilSurface(This
->WineD3DDevice
, NULL
==pSurface
? NULL
: pSurface
->wineD3DSurface
);
581 LeaveCriticalSection(&d3d9_cs
);
585 static HRESULT WINAPI
IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface
, IDirect3DSurface9
**ppZStencilSurface
) {
586 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
588 IWineD3DSurface
*pZStencilSurface
;
590 TRACE("(%p) Relay\n" , This
);
591 if(ppZStencilSurface
== NULL
){
592 return D3DERR_INVALIDCALL
;
595 EnterCriticalSection(&d3d9_cs
);
596 hr
= IWineD3DDevice_GetDepthStencilSurface(This
->WineD3DDevice
,&pZStencilSurface
);
598 if(pZStencilSurface
!= NULL
){
599 IWineD3DSurface_GetParent(pZStencilSurface
,(IUnknown
**)ppZStencilSurface
);
600 IWineD3DSurface_Release(pZStencilSurface
);
602 *ppZStencilSurface
= NULL
;
605 WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed\n");
606 *ppZStencilSurface
= NULL
;
608 LeaveCriticalSection(&d3d9_cs
);
612 static HRESULT WINAPI
IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9 iface
) {
613 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
615 TRACE("(%p) Relay\n" , This
);
617 EnterCriticalSection(&d3d9_cs
);
618 hr
= IWineD3DDevice_BeginScene(This
->WineD3DDevice
);
619 LeaveCriticalSection(&d3d9_cs
);
623 static HRESULT WINAPI
IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9 iface
) {
624 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
626 TRACE("(%p) Relay\n" , This
);
628 EnterCriticalSection(&d3d9_cs
);
629 hr
= IWineD3DDevice_EndScene(This
->WineD3DDevice
);
630 LeaveCriticalSection(&d3d9_cs
);
634 static HRESULT WINAPI
IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9 iface
, DWORD Count
, CONST D3DRECT
* pRects
, DWORD Flags
, D3DCOLOR Color
, float Z
, DWORD Stencil
) {
635 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
637 TRACE("(%p) Relay\n" , This
);
639 /* Note: D3DRECT is compatible with WINED3DRECT */
640 EnterCriticalSection(&d3d9_cs
);
641 hr
= IWineD3DDevice_Clear(This
->WineD3DDevice
, Count
, (CONST WINED3DRECT
*) pRects
, Flags
, Color
, Z
, Stencil
);
642 LeaveCriticalSection(&d3d9_cs
);
646 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9 iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* lpMatrix
) {
647 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
649 TRACE("(%p) Relay\n" , This
);
651 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
652 EnterCriticalSection(&d3d9_cs
);
653 hr
= IWineD3DDevice_SetTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) lpMatrix
);
654 LeaveCriticalSection(&d3d9_cs
);
658 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9 iface
, D3DTRANSFORMSTATETYPE State
, D3DMATRIX
* pMatrix
) {
659 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
660 TRACE("(%p) Relay\n" , This
);
662 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
663 return IWineD3DDevice_GetTransform(This
->WineD3DDevice
, State
, (WINED3DMATRIX
*) pMatrix
);
666 static HRESULT WINAPI
IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9 iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* pMatrix
) {
667 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
669 TRACE("(%p) Relay\n" , This
);
671 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
672 EnterCriticalSection(&d3d9_cs
);
673 hr
= IWineD3DDevice_MultiplyTransform(This
->WineD3DDevice
, State
, (CONST WINED3DMATRIX
*) pMatrix
);
674 LeaveCriticalSection(&d3d9_cs
);
678 static HRESULT WINAPI
IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9 iface
, CONST D3DVIEWPORT9
* pViewport
) {
679 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
681 TRACE("(%p) Relay\n" , This
);
683 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
684 EnterCriticalSection(&d3d9_cs
);
685 hr
= IWineD3DDevice_SetViewport(This
->WineD3DDevice
, (const WINED3DVIEWPORT
*)pViewport
);
686 LeaveCriticalSection(&d3d9_cs
);
690 static HRESULT WINAPI
IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface
, D3DVIEWPORT9
* pViewport
) {
691 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
693 TRACE("(%p) Relay\n" , This
);
695 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
696 EnterCriticalSection(&d3d9_cs
);
697 hr
= IWineD3DDevice_GetViewport(This
->WineD3DDevice
, (WINED3DVIEWPORT
*)pViewport
);
698 LeaveCriticalSection(&d3d9_cs
);
702 static HRESULT WINAPI
IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface
, CONST D3DMATERIAL9
* pMaterial
) {
703 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
705 TRACE("(%p) Relay\n" , This
);
707 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
708 EnterCriticalSection(&d3d9_cs
);
709 hr
= IWineD3DDevice_SetMaterial(This
->WineD3DDevice
, (const WINED3DMATERIAL
*)pMaterial
);
710 LeaveCriticalSection(&d3d9_cs
);
714 static HRESULT WINAPI
IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface
, D3DMATERIAL9
* pMaterial
) {
715 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
717 TRACE("(%p) Relay\n" , This
);
719 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
720 EnterCriticalSection(&d3d9_cs
);
721 hr
= IWineD3DDevice_GetMaterial(This
->WineD3DDevice
, (WINED3DMATERIAL
*)pMaterial
);
722 LeaveCriticalSection(&d3d9_cs
);
726 static HRESULT WINAPI
IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface
, DWORD Index
, CONST D3DLIGHT9
* pLight
) {
727 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
729 TRACE("(%p) Relay\n" , This
);
731 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
732 EnterCriticalSection(&d3d9_cs
);
733 hr
= IWineD3DDevice_SetLight(This
->WineD3DDevice
, Index
, (const WINED3DLIGHT
*)pLight
);
734 LeaveCriticalSection(&d3d9_cs
);
738 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface
, DWORD Index
, D3DLIGHT9
* pLight
) {
739 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
741 TRACE("(%p) Relay\n" , This
);
743 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
744 EnterCriticalSection(&d3d9_cs
);
745 hr
= IWineD3DDevice_GetLight(This
->WineD3DDevice
, Index
, (WINED3DLIGHT
*)pLight
);
746 LeaveCriticalSection(&d3d9_cs
);
750 static HRESULT WINAPI
IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9 iface
, DWORD Index
, BOOL Enable
) {
751 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
753 TRACE("(%p) Relay\n" , This
);
755 EnterCriticalSection(&d3d9_cs
);
756 hr
= IWineD3DDevice_SetLightEnable(This
->WineD3DDevice
, Index
, Enable
);
757 LeaveCriticalSection(&d3d9_cs
);
761 static HRESULT WINAPI
IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9 iface
, DWORD Index
, BOOL
* pEnable
) {
762 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
764 TRACE("(%p) Relay\n" , This
);
766 EnterCriticalSection(&d3d9_cs
);
767 hr
= IWineD3DDevice_GetLightEnable(This
->WineD3DDevice
, Index
, pEnable
);
768 LeaveCriticalSection(&d3d9_cs
);
772 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9 iface
, DWORD Index
, CONST
float* pPlane
) {
773 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
775 TRACE("(%p) Relay\n" , This
);
777 EnterCriticalSection(&d3d9_cs
);
778 hr
= IWineD3DDevice_SetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
779 LeaveCriticalSection(&d3d9_cs
);
783 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9 iface
, DWORD Index
, float* pPlane
) {
784 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
786 TRACE("(%p) Relay\n" , This
);
788 EnterCriticalSection(&d3d9_cs
);
789 hr
= IWineD3DDevice_GetClipPlane(This
->WineD3DDevice
, Index
, pPlane
);
790 LeaveCriticalSection(&d3d9_cs
);
794 static HRESULT WINAPI
IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9 iface
, D3DRENDERSTATETYPE State
, DWORD Value
) {
795 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
797 TRACE("(%p) Relay\n" , This
);
799 EnterCriticalSection(&d3d9_cs
);
800 hr
= IWineD3DDevice_SetRenderState(This
->WineD3DDevice
, State
, Value
);
801 LeaveCriticalSection(&d3d9_cs
);
805 static HRESULT WINAPI
IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9 iface
, D3DRENDERSTATETYPE State
, DWORD
* pValue
) {
806 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
808 TRACE("(%p) Relay\n" , This
);
810 EnterCriticalSection(&d3d9_cs
);
811 hr
= IWineD3DDevice_GetRenderState(This
->WineD3DDevice
, State
, pValue
);
812 LeaveCriticalSection(&d3d9_cs
);
816 static HRESULT WINAPI
IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface
, CONST D3DCLIPSTATUS9
* pClipStatus
) {
817 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
819 TRACE("(%p) Relay\n" , This
);
821 EnterCriticalSection(&d3d9_cs
);
822 hr
= IWineD3DDevice_SetClipStatus(This
->WineD3DDevice
, (const WINED3DCLIPSTATUS
*)pClipStatus
);
823 LeaveCriticalSection(&d3d9_cs
);
827 static HRESULT WINAPI
IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface
, D3DCLIPSTATUS9
* pClipStatus
) {
828 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
830 TRACE("(%p) Relay\n" , This
);
832 EnterCriticalSection(&d3d9_cs
);
833 hr
= IWineD3DDevice_GetClipStatus(This
->WineD3DDevice
, (WINED3DCLIPSTATUS
*)pClipStatus
);
834 LeaveCriticalSection(&d3d9_cs
);
838 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, IDirect3DBaseTexture9
**ppTexture
) {
839 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
840 IWineD3DBaseTexture
*retTexture
= NULL
;
843 TRACE("(%p) Relay\n" , This
);
845 if(ppTexture
== NULL
){
846 return D3DERR_INVALIDCALL
;
849 EnterCriticalSection(&d3d9_cs
);
850 rc
= IWineD3DDevice_GetTexture(This
->WineD3DDevice
, Stage
, &retTexture
);
851 if (rc
== D3D_OK
&& NULL
!= retTexture
) {
852 IWineD3DBaseTexture_GetParent(retTexture
, (IUnknown
**)ppTexture
);
853 IWineD3DBaseTexture_Release(retTexture
);
855 FIXME("Call to get texture (%d) failed (%p)\n", Stage
, retTexture
);
858 LeaveCriticalSection(&d3d9_cs
);
863 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, IDirect3DBaseTexture9
* pTexture
) {
864 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
866 TRACE("(%p) Relay %d %p\n" , This
, Stage
, pTexture
);
868 EnterCriticalSection(&d3d9_cs
);
869 hr
= IWineD3DDevice_SetTexture(This
->WineD3DDevice
, Stage
,
870 pTexture
==NULL
? NULL
:((IDirect3DBaseTexture9Impl
*)pTexture
)->wineD3DBaseTexture
);
871 LeaveCriticalSection(&d3d9_cs
);
875 static HRESULT WINAPI
IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD
* pValue
) {
876 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
878 TRACE("(%p) Relay\n" , This
);
880 EnterCriticalSection(&d3d9_cs
);
881 hr
= IWineD3DDevice_GetTextureStageState(This
->WineD3DDevice
, Stage
, Type
, pValue
);
882 LeaveCriticalSection(&d3d9_cs
);
886 static HRESULT WINAPI
IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD Value
) {
887 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
889 TRACE("(%p) Relay\n" , This
);
891 EnterCriticalSection(&d3d9_cs
);
892 hr
= IWineD3DDevice_SetTextureStageState(This
->WineD3DDevice
, Stage
, Type
, Value
);
893 LeaveCriticalSection(&d3d9_cs
);
897 static HRESULT WINAPI
IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9 iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD
* pValue
) {
898 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
900 TRACE("(%p) Relay\n" , This
);
902 EnterCriticalSection(&d3d9_cs
);
903 hr
= IWineD3DDevice_GetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, pValue
);
904 LeaveCriticalSection(&d3d9_cs
);
908 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9 iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD Value
) {
909 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
911 TRACE("(%p) Relay\n" , This
);
913 EnterCriticalSection(&d3d9_cs
);
914 hr
= IWineD3DDevice_SetSamplerState(This
->WineD3DDevice
, Sampler
, Type
, Value
);
915 LeaveCriticalSection(&d3d9_cs
);
919 static HRESULT WINAPI
IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9 iface
, DWORD
* pNumPasses
) {
920 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
922 TRACE("(%p) Relay\n" , This
);
924 EnterCriticalSection(&d3d9_cs
);
925 hr
= IWineD3DDevice_ValidateDevice(This
->WineD3DDevice
, pNumPasses
);
926 LeaveCriticalSection(&d3d9_cs
);
930 static HRESULT WINAPI
IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9 iface
, UINT PaletteNumber
, CONST PALETTEENTRY
* pEntries
) {
931 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
933 TRACE("(%p) Relay\n" , This
);
935 EnterCriticalSection(&d3d9_cs
);
936 hr
= IWineD3DDevice_SetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
937 LeaveCriticalSection(&d3d9_cs
);
941 static HRESULT WINAPI
IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9 iface
, UINT PaletteNumber
, PALETTEENTRY
* pEntries
) {
942 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
944 TRACE("(%p) Relay\n" , This
);
946 EnterCriticalSection(&d3d9_cs
);
947 hr
= IWineD3DDevice_GetPaletteEntries(This
->WineD3DDevice
, PaletteNumber
, pEntries
);
948 LeaveCriticalSection(&d3d9_cs
);
952 static HRESULT WINAPI
IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface
, UINT PaletteNumber
) {
953 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
955 TRACE("(%p) Relay\n" , This
);
957 EnterCriticalSection(&d3d9_cs
);
958 hr
= IWineD3DDevice_SetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
959 LeaveCriticalSection(&d3d9_cs
);
963 static HRESULT WINAPI
IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface
, UINT
* PaletteNumber
) {
964 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
966 TRACE("(%p) Relay\n" , This
);
968 EnterCriticalSection(&d3d9_cs
);
969 hr
= IWineD3DDevice_GetCurrentTexturePalette(This
->WineD3DDevice
, PaletteNumber
);
970 LeaveCriticalSection(&d3d9_cs
);
974 static HRESULT WINAPI
IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9 iface
, CONST RECT
* pRect
) {
975 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
977 TRACE("(%p) Relay\n" , This
);
979 EnterCriticalSection(&d3d9_cs
);
980 hr
= IWineD3DDevice_SetScissorRect(This
->WineD3DDevice
, pRect
);
981 LeaveCriticalSection(&d3d9_cs
);
985 static HRESULT WINAPI
IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9 iface
, RECT
* pRect
) {
986 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
988 TRACE("(%p) Relay\n" , This
);
990 EnterCriticalSection(&d3d9_cs
);
991 hr
= IWineD3DDevice_GetScissorRect(This
->WineD3DDevice
, pRect
);
992 LeaveCriticalSection(&d3d9_cs
);
996 static HRESULT WINAPI
IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface
, BOOL bSoftware
) {
997 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
999 TRACE("(%p) Relay\n" , This
);
1001 EnterCriticalSection(&d3d9_cs
);
1002 hr
= IWineD3DDevice_SetSoftwareVertexProcessing(This
->WineD3DDevice
, bSoftware
);
1003 LeaveCriticalSection(&d3d9_cs
);
1007 static BOOL WINAPI
IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface
) {
1008 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1010 TRACE("(%p) Relay\n" , This
);
1012 EnterCriticalSection(&d3d9_cs
);
1013 hr
= IWineD3DDevice_GetSoftwareVertexProcessing(This
->WineD3DDevice
);
1014 LeaveCriticalSection(&d3d9_cs
);
1018 static HRESULT WINAPI
IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9 iface
, float nSegments
) {
1019 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1021 TRACE("(%p) Relay\n" , This
);
1023 EnterCriticalSection(&d3d9_cs
);
1024 hr
= IWineD3DDevice_SetNPatchMode(This
->WineD3DDevice
, nSegments
);
1025 LeaveCriticalSection(&d3d9_cs
);
1029 static float WINAPI
IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9 iface
) {
1030 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1032 TRACE("(%p) Relay\n" , This
);
1034 EnterCriticalSection(&d3d9_cs
);
1035 hr
= IWineD3DDevice_GetNPatchMode(This
->WineD3DDevice
);
1036 LeaveCriticalSection(&d3d9_cs
);
1040 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT StartVertex
, UINT PrimitiveCount
) {
1041 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1043 TRACE("(%p) Relay\n" , This
);
1045 EnterCriticalSection(&d3d9_cs
);
1046 hr
= IWineD3DDevice_DrawPrimitive(This
->WineD3DDevice
, PrimitiveType
, StartVertex
, PrimitiveCount
);
1047 LeaveCriticalSection(&d3d9_cs
);
1051 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
,
1052 INT BaseVertexIndex
, UINT MinVertexIndex
, UINT NumVertices
, UINT startIndex
, UINT primCount
) {
1053 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1055 TRACE("(%p) Relay\n" , This
);
1057 /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
1058 EnterCriticalSection(&d3d9_cs
);
1059 IWineD3DDevice_SetBaseVertexIndex(This
->WineD3DDevice
, BaseVertexIndex
);
1060 hr
= IWineD3DDevice_DrawIndexedPrimitive(This
->WineD3DDevice
, PrimitiveType
, MinVertexIndex
, NumVertices
, startIndex
, primCount
);
1061 LeaveCriticalSection(&d3d9_cs
);
1065 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT PrimitiveCount
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1066 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1068 TRACE("(%p) Relay\n" , This
);
1070 EnterCriticalSection(&d3d9_cs
);
1071 hr
= IWineD3DDevice_DrawPrimitiveUP(This
->WineD3DDevice
, PrimitiveType
, PrimitiveCount
, pVertexStreamZeroData
, VertexStreamZeroStride
);
1072 LeaveCriticalSection(&d3d9_cs
);
1076 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT MinVertexIndex
,
1077 UINT NumVertexIndices
, UINT PrimitiveCount
, CONST
void* pIndexData
,
1078 D3DFORMAT IndexDataFormat
, CONST
void* pVertexStreamZeroData
, UINT VertexStreamZeroStride
) {
1079 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1081 TRACE("(%p) Relay\n" , This
);
1083 EnterCriticalSection(&d3d9_cs
);
1084 hr
= IWineD3DDevice_DrawIndexedPrimitiveUP(This
->WineD3DDevice
, PrimitiveType
, MinVertexIndex
, NumVertexIndices
, PrimitiveCount
,
1085 pIndexData
, IndexDataFormat
, pVertexStreamZeroData
, VertexStreamZeroStride
);
1086 LeaveCriticalSection(&d3d9_cs
);
1090 static HRESULT WINAPI
IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9 iface
, UINT SrcStartIndex
, UINT DestIndex
, UINT VertexCount
, IDirect3DVertexBuffer9
* pDestBuffer
, IDirect3DVertexDeclaration9
* pVertexDecl
, DWORD Flags
) {
1091 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1092 IDirect3DVertexDeclaration9Impl
*Decl
= (IDirect3DVertexDeclaration9Impl
*) pVertexDecl
;
1094 TRACE("(%p) Relay\n" , This
);
1096 EnterCriticalSection(&d3d9_cs
);
1097 hr
= IWineD3DDevice_ProcessVertices(This
->WineD3DDevice
,SrcStartIndex
, DestIndex
, VertexCount
, ((IDirect3DVertexBuffer9Impl
*)pDestBuffer
)->wineD3DVertexBuffer
, Decl
? Decl
->wineD3DVertexDeclaration
: NULL
, Flags
);
1098 LeaveCriticalSection(&d3d9_cs
);
1102 IDirect3DVertexDeclaration9
*getConvertedDecl(IDirect3DDevice9Impl
*This
, DWORD fvf
) {
1104 D3DVERTEXELEMENT9
* elements
= NULL
;
1105 IDirect3DVertexDeclaration9
* pDecl
= NULL
;
1106 int p
, low
, high
; /* deliberately signed */
1107 IDirect3DVertexDeclaration9
**convertedDecls
= This
->convertedDecls
;
1109 TRACE("Searching for declaration for fvf %08x... ", fvf
);
1112 high
= This
->numConvertedDecls
- 1;
1113 while(low
<= high
) {
1114 p
= (low
+ high
) >> 1;
1116 if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
== fvf
) {
1117 TRACE("found %p\n", convertedDecls
[p
]);
1118 return convertedDecls
[p
];
1119 } else if(((IDirect3DVertexDeclaration9Impl
*) convertedDecls
[p
])->convFVF
< fvf
) {
1125 TRACE("not found. Creating and inserting at position %d.\n", low
);
1127 hr
= vdecl_convert_fvf(fvf
, &elements
);
1128 if (hr
!= S_OK
) return NULL
;
1130 hr
= IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9
*) This
, elements
, &pDecl
);
1131 HeapFree(GetProcessHeap(), 0, elements
); /* CreateVertexDeclaration makes a copy */
1132 if (hr
!= S_OK
) return NULL
;
1134 if(This
->declArraySize
== This
->numConvertedDecls
) {
1135 int grow
= max(This
->declArraySize
/ 2, 8);
1136 convertedDecls
= HeapReAlloc(GetProcessHeap(), 0, convertedDecls
,
1137 sizeof(convertedDecls
[0]) * (This
->numConvertedDecls
+ grow
));
1138 if(!convertedDecls
) {
1139 /* This will destroy it */
1140 IDirect3DVertexDeclaration9_Release(pDecl
);
1143 This
->convertedDecls
= convertedDecls
;
1144 This
->declArraySize
+= grow
;
1147 memmove(convertedDecls
+ low
+ 1, convertedDecls
+ low
, sizeof(IDirect3DVertexDeclaration9Impl
*) * (This
->numConvertedDecls
- low
));
1148 convertedDecls
[low
] = pDecl
;
1149 This
->numConvertedDecls
++;
1151 /* Will prevent the decl from being destroyed */
1152 ((IDirect3DVertexDeclaration9Impl
*) pDecl
)->convFVF
= fvf
;
1153 IDirect3DVertexDeclaration9_Release(pDecl
); /* Does not destroy now */
1155 TRACE("Returning %p. %d decls in array\n", pDecl
, This
->numConvertedDecls
);
1159 HRESULT WINAPI
IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9 iface
, DWORD FVF
) {
1160 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1162 TRACE("(%p) Relay\n" , This
);
1164 EnterCriticalSection(&d3d9_cs
);
1167 IDirect3DVertexDeclaration9
* pDecl
= getConvertedDecl(This
, FVF
);
1170 /* Any situation when this should happen, except out of memory? */
1171 ERR("Failed to create a converted vertex declaration\n");
1172 LeaveCriticalSection(&d3d9_cs
);
1173 return D3DERR_DRIVERINTERNALERROR
;
1176 hr
= IDirect3DDevice9Impl_SetVertexDeclaration(iface
, pDecl
);
1178 LeaveCriticalSection(&d3d9_cs
);
1182 hr
= IWineD3DDevice_SetFVF(This
->WineD3DDevice
, FVF
);
1183 LeaveCriticalSection(&d3d9_cs
);
1188 HRESULT WINAPI
IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9 iface
, DWORD
* pFVF
) {
1189 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1191 TRACE("(%p) Relay\n" , This
);
1193 EnterCriticalSection(&d3d9_cs
);
1194 hr
= IWineD3DDevice_GetFVF(This
->WineD3DDevice
, pFVF
);
1195 LeaveCriticalSection(&d3d9_cs
);
1199 HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
* pStreamData
, UINT OffsetInBytes
, UINT Stride
) {
1200 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1202 TRACE("(%p) Relay\n" , This
);
1204 EnterCriticalSection(&d3d9_cs
);
1205 hr
= IWineD3DDevice_SetStreamSource(This
->WineD3DDevice
, StreamNumber
,
1206 pStreamData
==NULL
? NULL
:((IDirect3DVertexBuffer9Impl
*)pStreamData
)->wineD3DVertexBuffer
,
1207 OffsetInBytes
, Stride
);
1208 LeaveCriticalSection(&d3d9_cs
);
1212 HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
, IDirect3DVertexBuffer9
**pStream
, UINT
* OffsetInBytes
, UINT
* pStride
) {
1213 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1214 IWineD3DVertexBuffer
*retStream
= NULL
;
1215 HRESULT rc
= D3D_OK
;
1217 TRACE("(%p) Relay\n" , This
);
1219 if(pStream
== NULL
){
1220 return D3DERR_INVALIDCALL
;
1223 EnterCriticalSection(&d3d9_cs
);
1224 rc
= IWineD3DDevice_GetStreamSource(This
->WineD3DDevice
, StreamNumber
, &retStream
, OffsetInBytes
, pStride
);
1225 if (rc
== D3D_OK
&& NULL
!= retStream
) {
1226 IWineD3DVertexBuffer_GetParent(retStream
, (IUnknown
**)pStream
);
1227 IWineD3DVertexBuffer_Release(retStream
);
1230 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes
, pStride
);
1234 LeaveCriticalSection(&d3d9_cs
);
1239 static HRESULT WINAPI
IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
, UINT Divider
) {
1240 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1242 TRACE("(%p) Relay\n" , This
);
1244 EnterCriticalSection(&d3d9_cs
);
1245 hr
= IWineD3DDevice_SetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1246 LeaveCriticalSection(&d3d9_cs
);
1250 static HRESULT WINAPI
IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
, UINT
* Divider
) {
1251 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1253 TRACE("(%p) Relay\n" , This
);
1255 EnterCriticalSection(&d3d9_cs
);
1256 hr
= IWineD3DDevice_GetStreamSourceFreq(This
->WineD3DDevice
, StreamNumber
, Divider
);
1257 LeaveCriticalSection(&d3d9_cs
);
1261 static HRESULT WINAPI
IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9 iface
, IDirect3DIndexBuffer9
* pIndexData
) {
1262 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1264 TRACE("(%p) Relay\n", This
);
1266 EnterCriticalSection(&d3d9_cs
);
1267 hr
= IWineD3DDevice_SetIndices(This
->WineD3DDevice
,
1268 pIndexData
? ((IDirect3DIndexBuffer9Impl
*)pIndexData
)->wineD3DIndexBuffer
: NULL
);
1269 LeaveCriticalSection(&d3d9_cs
);
1273 static HRESULT WINAPI
IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9 iface
, IDirect3DIndexBuffer9
**ppIndexData
) {
1274 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1275 IWineD3DIndexBuffer
*retIndexData
= NULL
;
1276 HRESULT rc
= D3D_OK
;
1278 TRACE("(%p) Relay\n", This
);
1280 if(ppIndexData
== NULL
){
1281 return D3DERR_INVALIDCALL
;
1284 EnterCriticalSection(&d3d9_cs
);
1285 rc
= IWineD3DDevice_GetIndices(This
->WineD3DDevice
, &retIndexData
);
1286 if (SUCCEEDED(rc
) && retIndexData
) {
1287 IWineD3DIndexBuffer_GetParent(retIndexData
, (IUnknown
**)ppIndexData
);
1288 IWineD3DIndexBuffer_Release(retIndexData
);
1290 if (FAILED(rc
)) FIXME("Call to GetIndices failed\n");
1291 *ppIndexData
= NULL
;
1293 LeaveCriticalSection(&d3d9_cs
);
1297 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9 iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DRECTPATCH_INFO
* pRectPatchInfo
) {
1298 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1300 TRACE("(%p) Relay\n", This
);
1302 EnterCriticalSection(&d3d9_cs
);
1303 hr
= IWineD3DDevice_DrawRectPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DRECTPATCH_INFO
*)pRectPatchInfo
);
1304 LeaveCriticalSection(&d3d9_cs
);
1307 /*http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawTriPatch.asp*/
1308 static HRESULT WINAPI
IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9 iface
, UINT Handle
, CONST
float* pNumSegs
, CONST D3DTRIPATCH_INFO
* pTriPatchInfo
) {
1309 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1311 TRACE("(%p) Relay\n", This
);
1313 EnterCriticalSection(&d3d9_cs
);
1314 hr
= IWineD3DDevice_DrawTriPatch(This
->WineD3DDevice
, Handle
, pNumSegs
, (CONST WINED3DTRIPATCH_INFO
*)pTriPatchInfo
);
1315 LeaveCriticalSection(&d3d9_cs
);
1319 static HRESULT WINAPI
IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9 iface
, UINT Handle
) {
1320 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
1322 TRACE("(%p) Relay\n", This
);
1324 EnterCriticalSection(&d3d9_cs
);
1325 hr
= IWineD3DDevice_DeletePatch(This
->WineD3DDevice
, Handle
);
1326 LeaveCriticalSection(&d3d9_cs
);
1330 const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl
=
1333 IDirect3DDevice9Impl_QueryInterface
,
1334 IDirect3DDevice9Impl_AddRef
,
1335 IDirect3DDevice9Impl_Release
,
1336 /* IDirect3DDevice9 */
1337 IDirect3DDevice9Impl_TestCooperativeLevel
,
1338 IDirect3DDevice9Impl_GetAvailableTextureMem
,
1339 IDirect3DDevice9Impl_EvictManagedResources
,
1340 IDirect3DDevice9Impl_GetDirect3D
,
1341 IDirect3DDevice9Impl_GetDeviceCaps
,
1342 IDirect3DDevice9Impl_GetDisplayMode
,
1343 IDirect3DDevice9Impl_GetCreationParameters
,
1344 IDirect3DDevice9Impl_SetCursorProperties
,
1345 IDirect3DDevice9Impl_SetCursorPosition
,
1346 IDirect3DDevice9Impl_ShowCursor
,
1347 IDirect3DDevice9Impl_CreateAdditionalSwapChain
,
1348 IDirect3DDevice9Impl_GetSwapChain
,
1349 IDirect3DDevice9Impl_GetNumberOfSwapChains
,
1350 IDirect3DDevice9Impl_Reset
,
1351 IDirect3DDevice9Impl_Present
,
1352 IDirect3DDevice9Impl_GetBackBuffer
,
1353 IDirect3DDevice9Impl_GetRasterStatus
,
1354 IDirect3DDevice9Impl_SetDialogBoxMode
,
1355 IDirect3DDevice9Impl_SetGammaRamp
,
1356 IDirect3DDevice9Impl_GetGammaRamp
,
1357 IDirect3DDevice9Impl_CreateTexture
,
1358 IDirect3DDevice9Impl_CreateVolumeTexture
,
1359 IDirect3DDevice9Impl_CreateCubeTexture
,
1360 IDirect3DDevice9Impl_CreateVertexBuffer
,
1361 IDirect3DDevice9Impl_CreateIndexBuffer
,
1362 IDirect3DDevice9Impl_CreateRenderTarget
,
1363 IDirect3DDevice9Impl_CreateDepthStencilSurface
,
1364 IDirect3DDevice9Impl_UpdateSurface
,
1365 IDirect3DDevice9Impl_UpdateTexture
,
1366 IDirect3DDevice9Impl_GetRenderTargetData
,
1367 IDirect3DDevice9Impl_GetFrontBufferData
,
1368 IDirect3DDevice9Impl_StretchRect
,
1369 IDirect3DDevice9Impl_ColorFill
,
1370 IDirect3DDevice9Impl_CreateOffscreenPlainSurface
,
1371 IDirect3DDevice9Impl_SetRenderTarget
,
1372 IDirect3DDevice9Impl_GetRenderTarget
,
1373 IDirect3DDevice9Impl_SetDepthStencilSurface
,
1374 IDirect3DDevice9Impl_GetDepthStencilSurface
,
1375 IDirect3DDevice9Impl_BeginScene
,
1376 IDirect3DDevice9Impl_EndScene
,
1377 IDirect3DDevice9Impl_Clear
,
1378 IDirect3DDevice9Impl_SetTransform
,
1379 IDirect3DDevice9Impl_GetTransform
,
1380 IDirect3DDevice9Impl_MultiplyTransform
,
1381 IDirect3DDevice9Impl_SetViewport
,
1382 IDirect3DDevice9Impl_GetViewport
,
1383 IDirect3DDevice9Impl_SetMaterial
,
1384 IDirect3DDevice9Impl_GetMaterial
,
1385 IDirect3DDevice9Impl_SetLight
,
1386 IDirect3DDevice9Impl_GetLight
,
1387 IDirect3DDevice9Impl_LightEnable
,
1388 IDirect3DDevice9Impl_GetLightEnable
,
1389 IDirect3DDevice9Impl_SetClipPlane
,
1390 IDirect3DDevice9Impl_GetClipPlane
,
1391 IDirect3DDevice9Impl_SetRenderState
,
1392 IDirect3DDevice9Impl_GetRenderState
,
1393 IDirect3DDevice9Impl_CreateStateBlock
,
1394 IDirect3DDevice9Impl_BeginStateBlock
,
1395 IDirect3DDevice9Impl_EndStateBlock
,
1396 IDirect3DDevice9Impl_SetClipStatus
,
1397 IDirect3DDevice9Impl_GetClipStatus
,
1398 IDirect3DDevice9Impl_GetTexture
,
1399 IDirect3DDevice9Impl_SetTexture
,
1400 IDirect3DDevice9Impl_GetTextureStageState
,
1401 IDirect3DDevice9Impl_SetTextureStageState
,
1402 IDirect3DDevice9Impl_GetSamplerState
,
1403 IDirect3DDevice9Impl_SetSamplerState
,
1404 IDirect3DDevice9Impl_ValidateDevice
,
1405 IDirect3DDevice9Impl_SetPaletteEntries
,
1406 IDirect3DDevice9Impl_GetPaletteEntries
,
1407 IDirect3DDevice9Impl_SetCurrentTexturePalette
,
1408 IDirect3DDevice9Impl_GetCurrentTexturePalette
,
1409 IDirect3DDevice9Impl_SetScissorRect
,
1410 IDirect3DDevice9Impl_GetScissorRect
,
1411 IDirect3DDevice9Impl_SetSoftwareVertexProcessing
,
1412 IDirect3DDevice9Impl_GetSoftwareVertexProcessing
,
1413 IDirect3DDevice9Impl_SetNPatchMode
,
1414 IDirect3DDevice9Impl_GetNPatchMode
,
1415 IDirect3DDevice9Impl_DrawPrimitive
,
1416 IDirect3DDevice9Impl_DrawIndexedPrimitive
,
1417 IDirect3DDevice9Impl_DrawPrimitiveUP
,
1418 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP
,
1419 IDirect3DDevice9Impl_ProcessVertices
,
1420 IDirect3DDevice9Impl_CreateVertexDeclaration
,
1421 IDirect3DDevice9Impl_SetVertexDeclaration
,
1422 IDirect3DDevice9Impl_GetVertexDeclaration
,
1423 IDirect3DDevice9Impl_SetFVF
,
1424 IDirect3DDevice9Impl_GetFVF
,
1425 IDirect3DDevice9Impl_CreateVertexShader
,
1426 IDirect3DDevice9Impl_SetVertexShader
,
1427 IDirect3DDevice9Impl_GetVertexShader
,
1428 IDirect3DDevice9Impl_SetVertexShaderConstantF
,
1429 IDirect3DDevice9Impl_GetVertexShaderConstantF
,
1430 IDirect3DDevice9Impl_SetVertexShaderConstantI
,
1431 IDirect3DDevice9Impl_GetVertexShaderConstantI
,
1432 IDirect3DDevice9Impl_SetVertexShaderConstantB
,
1433 IDirect3DDevice9Impl_GetVertexShaderConstantB
,
1434 IDirect3DDevice9Impl_SetStreamSource
,
1435 IDirect3DDevice9Impl_GetStreamSource
,
1436 IDirect3DDevice9Impl_SetStreamSourceFreq
,
1437 IDirect3DDevice9Impl_GetStreamSourceFreq
,
1438 IDirect3DDevice9Impl_SetIndices
,
1439 IDirect3DDevice9Impl_GetIndices
,
1440 IDirect3DDevice9Impl_CreatePixelShader
,
1441 IDirect3DDevice9Impl_SetPixelShader
,
1442 IDirect3DDevice9Impl_GetPixelShader
,
1443 IDirect3DDevice9Impl_SetPixelShaderConstantF
,
1444 IDirect3DDevice9Impl_GetPixelShaderConstantF
,
1445 IDirect3DDevice9Impl_SetPixelShaderConstantI
,
1446 IDirect3DDevice9Impl_GetPixelShaderConstantI
,
1447 IDirect3DDevice9Impl_SetPixelShaderConstantB
,
1448 IDirect3DDevice9Impl_GetPixelShaderConstantB
,
1449 IDirect3DDevice9Impl_DrawRectPatch
,
1450 IDirect3DDevice9Impl_DrawTriPatch
,
1451 IDirect3DDevice9Impl_DeletePatch
,
1452 IDirect3DDevice9Impl_CreateQuery
1456 /* Internal function called back during the CreateDevice to create a render target */
1457 HRESULT WINAPI
D3D9CB_CreateSurface(IUnknown
*device
, IUnknown
*pSuperior
, UINT Width
, UINT Height
,
1458 WINED3DFORMAT Format
, DWORD Usage
, WINED3DPOOL Pool
, UINT Level
,
1459 WINED3DCUBEMAP_FACES Face
,IWineD3DSurface
** ppSurface
,
1460 HANDLE
* pSharedHandle
) {
1462 HRESULT res
= D3D_OK
;
1463 IDirect3DSurface9Impl
*d3dSurface
= NULL
;
1464 BOOL Lockable
= TRUE
;
1466 if((Pool
== D3DPOOL_DEFAULT
&& Usage
!= D3DUSAGE_DYNAMIC
))
1470 res
= IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9
*)device
, Width
, Height
, (D3DFORMAT
)Format
,
1471 Lockable
, FALSE
/*Discard*/, Level
, (IDirect3DSurface9
**)&d3dSurface
, D3DRTYPE_SURFACE
,
1472 Usage
, (D3DPOOL
) Pool
, D3DMULTISAMPLE_NONE
, 0 /* MultisampleQuality */, pSharedHandle
);
1474 if (SUCCEEDED(res
)) {
1475 *ppSurface
= d3dSurface
->wineD3DSurface
;
1476 d3dSurface
->container
= pSuperior
;
1477 IUnknown_Release(d3dSurface
->parentDevice
);
1478 d3dSurface
->parentDevice
= NULL
;
1479 d3dSurface
->forwardReference
= pSuperior
;
1481 FIXME("(%p) IDirect3DDevice9_CreateSurface failed\n", device
);
1486 ULONG WINAPI
D3D9CB_DestroySurface(IWineD3DSurface
*pSurface
) {
1487 IDirect3DSurface9Impl
* surfaceParent
;
1488 TRACE("(%p) call back\n", pSurface
);
1490 IWineD3DSurface_GetParent(pSurface
, (IUnknown
**) &surfaceParent
);
1491 /* GetParent's AddRef was forwarded to an object in destruction.
1492 * Releasing it here again would cause an endless recursion. */
1493 surfaceParent
->forwardReference
= NULL
;
1494 return IDirect3DSurface9_Release((IDirect3DSurface9
*) surfaceParent
);