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 reset_enum_callback(IWineD3DResource *resource, void *data) {
234 BOOL *resources_ok = (BOOL *) data;
235 WINED3DRESOURCETYPE type;
237 WINED3DSURFACE_DESC surface_desc;
238 WINED3DVOLUME_DESC volume_desc;
239 WINED3DINDEXBUFFER_DESC index_desc;
240 WINED3DVERTEXBUFFER_DESC vertex_desc;
241 WINED3DFORMAT dummy_format;
243 WINED3DPOOL pool = WINED3DPOOL_SCRATCH; /* a harmless pool */
246 type = IWineD3DResource_GetType(resource);
248 case WINED3DRTYPE_SURFACE:
249 surface_desc.Format = &dummy_format;
250 surface_desc.Type = &type;
251 surface_desc.Usage = &dummy_dword;
252 surface_desc.Pool = &pool;
253 surface_desc.Size = &dummy_dword;
254 surface_desc.MultiSampleType = &dummy_dword;
255 surface_desc.MultiSampleQuality = &dummy_dword;
256 surface_desc.Width = &dummy_dword;
257 surface_desc.Height = &dummy_dword;
259 IWineD3DSurface_GetDesc((IWineD3DSurface *) resource, &surface_desc);
262 case WINED3DRTYPE_VOLUME:
263 volume_desc.Format = &dummy_format;
264 volume_desc.Type = &type;
265 volume_desc.Usage = &dummy_dword;
266 volume_desc.Pool = &pool;
267 volume_desc.Size = &dummy_dword;
268 volume_desc.Width = &dummy_dword;
269 volume_desc.Height = &dummy_dword;
270 volume_desc.Depth = &dummy_dword;
271 IWineD3DVolume_GetDesc((IWineD3DVolume *) resource, &volume_desc);
274 case WINED3DRTYPE_INDEXBUFFER:
275 IWineD3DIndexBuffer_GetDesc((IWineD3DIndexBuffer *) resource, &index_desc);
276 pool = index_desc.Pool;
279 case WINED3DRTYPE_VERTEXBUFFER:
280 IWineD3DVertexBuffer_GetDesc((IWineD3DVertexBuffer *) resource, &vertex_desc);
281 pool = index_desc.Pool;
284 /* No need to check for textures. If there is a D3DPOOL_DEFAULT texture, there
285 * is a D3DPOOL_DEFAULT surface or volume as well
291 if(pool == WINED3DPOOL_DEFAULT) {
292 IWineD3DResource_GetParent(resource, &parent);
293 if(IUnknown_Release(parent) == 0) {
294 TRACE("Parent %p is an implicit resource with ref 0\n", parent);
296 WARN("Resource %p(wineD3D %p) with pool D3DPOOL_DEFAULT blocks the Reset call\n", parent, resource);
298 *resources_ok = FALSE;
301 IWineD3DResource_Release(resource);
306 static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
307 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
308 WINED3DPRESENT_PARAMETERS localParameters;
310 BOOL resources_ok = TRUE;
313 TRACE("(%p) Relay pPresentationParameters(%p)\n", This, pPresentationParameters);
315 /* Reset states that hold a COM object. WineD3D holds an internal reference to set objects, because
316 * such objects can still be used for rendering after their external d3d9 object has been destroyed.
317 * These objects must not be enumerated. Unsetting them tells WineD3D that the application will not
318 * make use of the hidden reference and destroys the objects.
320 * Unsetting them is no problem, because the states are supposed to be reset anyway. If the validation
321 * below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
323 IWineD3DDevice_SetIndices(This->WineD3DDevice, NULL);
324 for(i = 0; i < 16; i++) {
325 IWineD3DDevice_SetStreamSource(This->WineD3DDevice, i, NULL, 0, 0);
327 for(i = 0; i < 16; i++) {
328 IWineD3DDevice_SetTexture(This->WineD3DDevice, i, NULL);
331 IWineD3DDevice_EnumResources(This->WineD3DDevice, reset_enum_callback, &resources_ok);
333 WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
334 return WINED3DERR_INVALIDCALL;
337 localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
338 localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
339 localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
340 localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
341 localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
342 localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
343 localParameters.SwapEffect = pPresentationParameters->SwapEffect;
344 localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
345 localParameters.Windowed = pPresentationParameters->Windowed;
346 localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
347 localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
348 localParameters.Flags = pPresentationParameters->Flags;
349 localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
350 localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
352 EnterCriticalSection(&d3d9_cs);
353 hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
354 LeaveCriticalSection(&d3d9_cs);
356 pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
357 pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
358 pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
359 pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
360 pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
361 pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
362 pPresentationParameters->SwapEffect = localParameters.SwapEffect;
363 pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
364 pPresentationParameters->Windowed = localParameters.Windowed;
365 pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
366 pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
367 pPresentationParameters->Flags = localParameters.Flags;
368 pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
369 pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
374 static HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA*
376 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
378 TRACE("(%p) Relay\n", This);
380 EnterCriticalSection(&d3d9_cs);
381 hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
382 LeaveCriticalSection(&d3d9_cs);
386 static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 ** ppBackBuffer) {
387 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
388 IWineD3DSurface *retSurface = NULL;
391 TRACE("(%p) Relay\n", This);
393 EnterCriticalSection(&d3d9_cs);
394 rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
395 if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
396 IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
397 IWineD3DSurface_Release(retSurface);
399 LeaveCriticalSection(&d3d9_cs);
402 static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
403 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
405 TRACE("(%p) Relay\n", This);
407 EnterCriticalSection(&d3d9_cs);
408 hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, iSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
409 LeaveCriticalSection(&d3d9_cs);
413 static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface, BOOL bEnableDialogs) {
414 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
416 TRACE("(%p) Relay\n", This);
418 EnterCriticalSection(&d3d9_cs);
419 hr = IWineD3DDevice_SetDialogBoxMode(This->WineD3DDevice, bEnableDialogs);
420 LeaveCriticalSection(&d3d9_cs);
424 static void WINAPI IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
426 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
427 TRACE("(%p) Relay\n", This);
429 EnterCriticalSection(&d3d9_cs);
430 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
431 IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, iSwapChain, Flags, (CONST WINED3DGAMMARAMP *)pRamp);
432 LeaveCriticalSection(&d3d9_cs);
435 static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DGAMMARAMP* pRamp) {
436 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
437 TRACE("(%p) Relay\n", This);
439 EnterCriticalSection(&d3d9_cs);
440 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
441 IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, iSwapChain, (WINED3DGAMMARAMP *) pRamp);
442 LeaveCriticalSection(&d3d9_cs);
446 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 ) {
448 IDirect3DSurface9Impl *object;
449 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
450 TRACE("(%p) Relay\n", This);
452 if(MultisampleQuality > 0){
453 FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality);
456 [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.
459 MultisampleQuality=0;
461 /*FIXME: Check MAX bounds of MultisampleQuality*/
463 /* Allocate the storage for the device */
464 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
465 if (NULL == object) {
466 FIXME("Allocation of memory failed\n");
467 return D3DERR_OUTOFVIDEOMEMORY;
470 object->lpVtbl = &Direct3DSurface9_Vtbl;
473 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
475 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);
477 if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
480 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This);
481 HeapFree(GetProcessHeap(), 0, object);
483 IUnknown_AddRef(iface);
484 object->parentDevice = iface;
485 TRACE("(%p) : Created surface %p\n", This, object);
486 *ppSurface = (LPDIRECT3DSURFACE9) object;
493 static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height,
494 D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
495 DWORD MultisampleQuality, BOOL Lockable,
496 IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
500 /* Is this correct? */
501 EnterCriticalSection(&d3d9_cs);
502 hr = IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,Lockable,FALSE/*Discard*/, 0/*Level*/, ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_RENDERTARGET,D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
503 LeaveCriticalSection(&d3d9_cs);
507 static HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height,
508 D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
509 DWORD MultisampleQuality, BOOL Discard,
510 IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
514 EnterCriticalSection(&d3d9_cs);
515 hr = IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,TRUE/* Lockable */,Discard, 0/* Level */
516 ,ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_DEPTHSTENCIL,
517 D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
518 LeaveCriticalSection(&d3d9_cs);
523 static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) {
524 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
526 TRACE("(%p) Relay\n" , This);
528 EnterCriticalSection(&d3d9_cs);
529 hr = IWineD3DDevice_UpdateSurface(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestinationSurface)->wineD3DSurface, pDestPoint);
530 LeaveCriticalSection(&d3d9_cs);
534 static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9 iface, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) {
535 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
537 TRACE("(%p) Relay\n" , This);
539 EnterCriticalSection(&d3d9_cs);
540 hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture9Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture9Impl *)pDestinationTexture)->wineD3DBaseTexture);
541 LeaveCriticalSection(&d3d9_cs);
545 /* This isn't in MSDN!
546 static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBuffer(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pDestSurface) {
547 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
548 FIXME("(%p) : stub\n", This);
553 static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) {
554 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
555 IDirect3DSurface9Impl *renderTarget = (IDirect3DSurface9Impl *)pRenderTarget;
556 IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
558 TRACE("(%p)->(%p,%p)\n" , This, renderTarget, destSurface);
560 EnterCriticalSection(&d3d9_cs);
561 hr = IWineD3DSurface_BltFast(destSurface->wineD3DSurface, 0, 0, renderTarget->wineD3DSurface, NULL, WINEDDBLTFAST_NOCOLORKEY);
562 LeaveCriticalSection(&d3d9_cs);
566 static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSurface9* pDestSurface) {
567 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
568 IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
570 TRACE("(%p) Relay\n" , This);
572 EnterCriticalSection(&d3d9_cs);
573 hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, iSwapChain, destSurface->wineD3DSurface);
574 LeaveCriticalSection(&d3d9_cs);
578 static HRESULT WINAPI IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) {
579 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
580 IDirect3DSurface9Impl *src = (IDirect3DSurface9Impl *) pSourceSurface;
581 IDirect3DSurface9Impl *dst = (IDirect3DSurface9Impl *) pDestSurface;
584 TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This, src, pSourceRect, dst, pDestRect, Filter);
585 EnterCriticalSection(&d3d9_cs);
586 hr = IWineD3DSurface_Blt(dst->wineD3DSurface, (RECT *) pDestRect, src->wineD3DSurface, (RECT *) pSourceRect, 0, NULL, Filter);
587 LeaveCriticalSection(&d3d9_cs);
591 static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) {
592 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
593 IDirect3DSurface9Impl *surface = (IDirect3DSurface9Impl *)pSurface;
595 TRACE("(%p) Relay\n" , This);
597 /* Note: D3DRECT is compatible with WINED3DRECT */
598 EnterCriticalSection(&d3d9_cs);
599 hr = IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wineD3DSurface, (CONST WINED3DRECT*)pRect, color);
600 LeaveCriticalSection(&d3d9_cs);
604 static HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
607 if(Pool == D3DPOOL_MANAGED ){
608 FIXME("Attempting to create a managed offscreen plain surface\n");
609 return D3DERR_INVALIDCALL;
611 /*MSDN: D3DPOOL_SCRATCH will return a surface that has identical characteristics to a surface created by the Microsoft DirectX 8.x method CreateImageSurface.
613 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
615 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
616 Why, their always lockable?
617 should I change the usage to dynamic?
619 EnterCriticalSection(&d3d9_cs);
620 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);
621 LeaveCriticalSection(&d3d9_cs);
625 /* TODO: move to wineD3D */
626 static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
627 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
628 IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget;
630 TRACE("(%p) Relay\n" , This);
632 EnterCriticalSection(&d3d9_cs);
633 hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, RenderTargetIndex, pSurface ? pSurface->wineD3DSurface : NULL);
634 LeaveCriticalSection(&d3d9_cs);
638 static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) {
639 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
641 IWineD3DSurface *pRenderTarget;
643 TRACE("(%p) Relay\n" , This);
645 if (ppRenderTarget == NULL) {
646 return D3DERR_INVALIDCALL;
649 EnterCriticalSection(&d3d9_cs);
650 hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget);
652 if (hr == D3D_OK && pRenderTarget != NULL) {
653 IWineD3DSurface_GetParent(pRenderTarget,(IUnknown**)ppRenderTarget);
654 IWineD3DSurface_Release(pRenderTarget);
656 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
657 *ppRenderTarget = NULL;
659 LeaveCriticalSection(&d3d9_cs);
664 static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) {
665 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
666 IDirect3DSurface9Impl *pSurface;
668 TRACE("(%p) Relay\n" , This);
670 pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
671 EnterCriticalSection(&d3d9_cs);
672 hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, NULL==pSurface ? NULL : pSurface->wineD3DSurface);
673 LeaveCriticalSection(&d3d9_cs);
677 static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9 **ppZStencilSurface) {
678 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
680 IWineD3DSurface *pZStencilSurface;
682 TRACE("(%p) Relay\n" , This);
683 if(ppZStencilSurface == NULL){
684 return D3DERR_INVALIDCALL;
687 EnterCriticalSection(&d3d9_cs);
688 hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
690 if(pZStencilSurface != NULL){
691 IWineD3DSurface_GetParent(pZStencilSurface,(IUnknown**)ppZStencilSurface);
692 IWineD3DSurface_Release(pZStencilSurface);
694 *ppZStencilSurface = NULL;
697 WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed\n");
698 *ppZStencilSurface = NULL;
700 LeaveCriticalSection(&d3d9_cs);
704 static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9 iface) {
705 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
707 TRACE("(%p) Relay\n" , This);
709 EnterCriticalSection(&d3d9_cs);
710 hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
711 LeaveCriticalSection(&d3d9_cs);
715 static HRESULT WINAPI IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9 iface) {
716 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
718 TRACE("(%p) Relay\n" , This);
720 EnterCriticalSection(&d3d9_cs);
721 hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
722 LeaveCriticalSection(&d3d9_cs);
726 static HRESULT WINAPI IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
727 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
729 TRACE("(%p) Relay\n" , This);
731 /* Note: D3DRECT is compatible with WINED3DRECT */
732 EnterCriticalSection(&d3d9_cs);
733 hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
734 LeaveCriticalSection(&d3d9_cs);
738 static HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
739 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
741 TRACE("(%p) Relay\n" , This);
743 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
744 EnterCriticalSection(&d3d9_cs);
745 hr = IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
746 LeaveCriticalSection(&d3d9_cs);
750 static HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) {
751 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
752 TRACE("(%p) Relay\n" , This);
754 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
755 return IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
758 static HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
759 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
761 TRACE("(%p) Relay\n" , This);
763 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
764 EnterCriticalSection(&d3d9_cs);
765 hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
766 LeaveCriticalSection(&d3d9_cs);
770 static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9 iface, CONST D3DVIEWPORT9* pViewport) {
771 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
773 TRACE("(%p) Relay\n" , This);
775 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
776 EnterCriticalSection(&d3d9_cs);
777 hr = IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
778 LeaveCriticalSection(&d3d9_cs);
782 static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface, D3DVIEWPORT9* pViewport) {
783 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
785 TRACE("(%p) Relay\n" , This);
787 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
788 EnterCriticalSection(&d3d9_cs);
789 hr = IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
790 LeaveCriticalSection(&d3d9_cs);
794 static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface, CONST D3DMATERIAL9* pMaterial) {
795 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
797 TRACE("(%p) Relay\n" , This);
799 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
800 EnterCriticalSection(&d3d9_cs);
801 hr = IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
802 LeaveCriticalSection(&d3d9_cs);
806 static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface, D3DMATERIAL9* pMaterial) {
807 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
809 TRACE("(%p) Relay\n" , This);
811 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
812 EnterCriticalSection(&d3d9_cs);
813 hr = IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
814 LeaveCriticalSection(&d3d9_cs);
818 static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST D3DLIGHT9* pLight) {
819 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
821 TRACE("(%p) Relay\n" , This);
823 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
824 EnterCriticalSection(&d3d9_cs);
825 hr = IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
826 LeaveCriticalSection(&d3d9_cs);
830 static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, D3DLIGHT9* pLight) {
831 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
833 TRACE("(%p) Relay\n" , This);
835 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
836 EnterCriticalSection(&d3d9_cs);
837 hr = IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
838 LeaveCriticalSection(&d3d9_cs);
842 static HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL Enable) {
843 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
845 TRACE("(%p) Relay\n" , This);
847 EnterCriticalSection(&d3d9_cs);
848 hr = IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
849 LeaveCriticalSection(&d3d9_cs);
853 static HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL* pEnable) {
854 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
856 TRACE("(%p) Relay\n" , This);
858 EnterCriticalSection(&d3d9_cs);
859 hr = IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
860 LeaveCriticalSection(&d3d9_cs);
864 static HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST float* pPlane) {
865 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
867 TRACE("(%p) Relay\n" , This);
869 EnterCriticalSection(&d3d9_cs);
870 hr = IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
871 LeaveCriticalSection(&d3d9_cs);
875 static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, float* pPlane) {
876 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
878 TRACE("(%p) Relay\n" , This);
880 EnterCriticalSection(&d3d9_cs);
881 hr = IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
882 LeaveCriticalSection(&d3d9_cs);
886 static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD Value) {
887 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
889 TRACE("(%p) Relay\n" , This);
891 EnterCriticalSection(&d3d9_cs);
892 hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
893 LeaveCriticalSection(&d3d9_cs);
897 static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD* pValue) {
898 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
900 TRACE("(%p) Relay\n" , This);
902 EnterCriticalSection(&d3d9_cs);
903 hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
904 LeaveCriticalSection(&d3d9_cs);
908 static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface, CONST D3DCLIPSTATUS9* pClipStatus) {
909 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
911 TRACE("(%p) Relay\n" , This);
913 EnterCriticalSection(&d3d9_cs);
914 hr = IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
915 LeaveCriticalSection(&d3d9_cs);
919 static HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface, D3DCLIPSTATUS9* pClipStatus) {
920 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
922 TRACE("(%p) Relay\n" , This);
924 EnterCriticalSection(&d3d9_cs);
925 hr = IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
926 LeaveCriticalSection(&d3d9_cs);
930 static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9 **ppTexture) {
931 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
932 IWineD3DBaseTexture *retTexture = NULL;
935 TRACE("(%p) Relay\n" , This);
937 if(ppTexture == NULL){
938 return D3DERR_INVALIDCALL;
941 EnterCriticalSection(&d3d9_cs);
942 rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture);
943 if (rc == D3D_OK && NULL != retTexture) {
944 IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
945 IWineD3DBaseTexture_Release(retTexture);
947 FIXME("Call to get texture (%d) failed (%p)\n", Stage, retTexture);
950 LeaveCriticalSection(&d3d9_cs);
955 static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9* pTexture) {
956 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
958 TRACE("(%p) Relay %d %p\n" , This, Stage, pTexture);
960 EnterCriticalSection(&d3d9_cs);
961 hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
962 pTexture==NULL ? NULL:((IDirect3DBaseTexture9Impl *)pTexture)->wineD3DBaseTexture);
963 LeaveCriticalSection(&d3d9_cs);
967 static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
968 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
970 TRACE("(%p) Relay\n" , This);
972 EnterCriticalSection(&d3d9_cs);
973 hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue);
974 LeaveCriticalSection(&d3d9_cs);
978 static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
979 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
981 TRACE("(%p) Relay\n" , This);
983 EnterCriticalSection(&d3d9_cs);
984 hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value);
985 LeaveCriticalSection(&d3d9_cs);
989 static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) {
990 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
992 TRACE("(%p) Relay\n" , This);
994 EnterCriticalSection(&d3d9_cs);
995 hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Sampler, Type, pValue);
996 LeaveCriticalSection(&d3d9_cs);
1000 static HRESULT WINAPI IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) {
1001 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1003 TRACE("(%p) Relay\n" , This);
1005 EnterCriticalSection(&d3d9_cs);
1006 hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Sampler, Type, Value);
1007 LeaveCriticalSection(&d3d9_cs);
1011 static HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9 iface, DWORD* pNumPasses) {
1012 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1014 TRACE("(%p) Relay\n" , This);
1016 EnterCriticalSection(&d3d9_cs);
1017 hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
1018 LeaveCriticalSection(&d3d9_cs);
1022 static HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
1023 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1025 TRACE("(%p) Relay\n" , This);
1027 EnterCriticalSection(&d3d9_cs);
1028 hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
1029 LeaveCriticalSection(&d3d9_cs);
1033 static HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
1034 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1036 TRACE("(%p) Relay\n" , This);
1038 EnterCriticalSection(&d3d9_cs);
1039 hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
1040 LeaveCriticalSection(&d3d9_cs);
1044 static HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber) {
1045 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1047 TRACE("(%p) Relay\n" , This);
1049 EnterCriticalSection(&d3d9_cs);
1050 hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
1051 LeaveCriticalSection(&d3d9_cs);
1055 static HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT* PaletteNumber) {
1056 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1058 TRACE("(%p) Relay\n" , This);
1060 EnterCriticalSection(&d3d9_cs);
1061 hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
1062 LeaveCriticalSection(&d3d9_cs);
1066 static HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9 iface, CONST RECT* pRect) {
1067 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1069 TRACE("(%p) Relay\n" , This);
1071 EnterCriticalSection(&d3d9_cs);
1072 hr = IWineD3DDevice_SetScissorRect(This->WineD3DDevice, pRect);
1073 LeaveCriticalSection(&d3d9_cs);
1077 static HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9 iface, RECT* pRect) {
1078 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1080 TRACE("(%p) Relay\n" , This);
1082 EnterCriticalSection(&d3d9_cs);
1083 hr = IWineD3DDevice_GetScissorRect(This->WineD3DDevice, pRect);
1084 LeaveCriticalSection(&d3d9_cs);
1088 static HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface, BOOL bSoftware) {
1089 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1091 TRACE("(%p) Relay\n" , This);
1093 EnterCriticalSection(&d3d9_cs);
1094 hr = IWineD3DDevice_SetSoftwareVertexProcessing(This->WineD3DDevice, bSoftware);
1095 LeaveCriticalSection(&d3d9_cs);
1099 static BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface) {
1100 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1102 TRACE("(%p) Relay\n" , This);
1104 EnterCriticalSection(&d3d9_cs);
1105 hr = IWineD3DDevice_GetSoftwareVertexProcessing(This->WineD3DDevice);
1106 LeaveCriticalSection(&d3d9_cs);
1110 static HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9 iface, float nSegments) {
1111 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1113 TRACE("(%p) Relay\n" , This);
1115 EnterCriticalSection(&d3d9_cs);
1116 hr = IWineD3DDevice_SetNPatchMode(This->WineD3DDevice, nSegments);
1117 LeaveCriticalSection(&d3d9_cs);
1121 static float WINAPI IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9 iface) {
1122 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1124 TRACE("(%p) Relay\n" , This);
1126 EnterCriticalSection(&d3d9_cs);
1127 hr = IWineD3DDevice_GetNPatchMode(This->WineD3DDevice);
1128 LeaveCriticalSection(&d3d9_cs);
1132 static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
1133 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1135 TRACE("(%p) Relay\n" , This);
1137 EnterCriticalSection(&d3d9_cs);
1138 hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex, PrimitiveCount);
1139 LeaveCriticalSection(&d3d9_cs);
1143 static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType,
1144 INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) {
1145 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1147 TRACE("(%p) Relay\n" , This);
1149 /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
1150 EnterCriticalSection(&d3d9_cs);
1151 IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, BaseVertexIndex);
1152 hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertices, startIndex, primCount);
1153 LeaveCriticalSection(&d3d9_cs);
1157 static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
1158 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1160 TRACE("(%p) Relay\n" , This);
1162 EnterCriticalSection(&d3d9_cs);
1163 hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
1164 LeaveCriticalSection(&d3d9_cs);
1168 static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex,
1169 UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData,
1170 D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
1171 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1173 TRACE("(%p) Relay\n" , This);
1175 EnterCriticalSection(&d3d9_cs);
1176 hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertexIndices, PrimitiveCount,
1177 pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
1178 LeaveCriticalSection(&d3d9_cs);
1182 static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9 iface, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) {
1183 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1184 IDirect3DVertexDeclaration9Impl *Decl = (IDirect3DVertexDeclaration9Impl *) pVertexDecl;
1186 TRACE("(%p) Relay\n" , This);
1188 EnterCriticalSection(&d3d9_cs);
1189 hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, ((IDirect3DVertexBuffer9Impl *)pDestBuffer)->wineD3DVertexBuffer, Decl ? Decl->wineD3DVertexDeclaration : NULL, Flags);
1190 LeaveCriticalSection(&d3d9_cs);
1194 IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This, DWORD fvf) {
1196 D3DVERTEXELEMENT9* elements = NULL;
1197 IDirect3DVertexDeclaration9* pDecl = NULL;
1198 int p, low, high; /* deliberately signed */
1199 IDirect3DVertexDeclaration9 **convertedDecls = This->convertedDecls;
1201 TRACE("Searching for declaration for fvf %08x... ", fvf);
1204 high = This->numConvertedDecls - 1;
1205 while(low <= high) {
1206 p = (low + high) >> 1;
1208 if(((IDirect3DVertexDeclaration9Impl *) convertedDecls[p])->convFVF == fvf) {
1209 TRACE("found %p\n", convertedDecls[p]);
1210 return convertedDecls[p];
1211 } else if(((IDirect3DVertexDeclaration9Impl *) convertedDecls[p])->convFVF < fvf) {
1217 TRACE("not found. Creating and inserting at position %d.\n", low);
1219 hr = vdecl_convert_fvf(fvf, &elements);
1220 if (hr != S_OK) return NULL;
1222 hr = IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9 *) This, elements, &pDecl);
1223 HeapFree(GetProcessHeap(), 0, elements); /* CreateVertexDeclaration makes a copy */
1224 if (hr != S_OK) return NULL;
1226 if(This->declArraySize == This->numConvertedDecls) {
1227 int grow = max(This->declArraySize / 2, 8);
1228 convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
1229 sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow));
1230 if(!convertedDecls) {
1231 /* This will destroy it */
1232 IDirect3DVertexDeclaration9_Release(pDecl);
1235 This->convertedDecls = convertedDecls;
1236 This->declArraySize += grow;
1239 memmove(convertedDecls + low + 1, convertedDecls + low, sizeof(IDirect3DVertexDeclaration9Impl *) * (This->numConvertedDecls - low));
1240 convertedDecls[low] = pDecl;
1241 This->numConvertedDecls++;
1243 /* Will prevent the decl from being destroyed */
1244 ((IDirect3DVertexDeclaration9Impl *) pDecl)->convFVF = fvf;
1245 IDirect3DVertexDeclaration9_Release(pDecl); /* Does not destroy now */
1247 TRACE("Returning %p. %d decls in array\n", pDecl, This->numConvertedDecls);
1251 HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9 iface, DWORD FVF) {
1252 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1254 TRACE("(%p) Relay\n" , This);
1256 EnterCriticalSection(&d3d9_cs);
1259 IDirect3DVertexDeclaration9* pDecl = getConvertedDecl(This, FVF);
1262 /* Any situation when this should happen, except out of memory? */
1263 ERR("Failed to create a converted vertex declaration\n");
1264 LeaveCriticalSection(&d3d9_cs);
1265 return D3DERR_DRIVERINTERNALERROR;
1268 hr = IDirect3DDevice9Impl_SetVertexDeclaration(iface, pDecl);
1270 LeaveCriticalSection(&d3d9_cs);
1274 hr = IWineD3DDevice_SetFVF(This->WineD3DDevice, FVF);
1275 LeaveCriticalSection(&d3d9_cs);
1280 HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9 iface, DWORD* pFVF) {
1281 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1283 TRACE("(%p) Relay\n" , This);
1285 EnterCriticalSection(&d3d9_cs);
1286 hr = IWineD3DDevice_GetFVF(This->WineD3DDevice, pFVF);
1287 LeaveCriticalSection(&d3d9_cs);
1291 HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
1292 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1294 TRACE("(%p) Relay\n" , This);
1296 EnterCriticalSection(&d3d9_cs);
1297 hr = IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
1298 pStreamData==NULL ? NULL:((IDirect3DVertexBuffer9Impl *)pStreamData)->wineD3DVertexBuffer,
1299 OffsetInBytes, Stride);
1300 LeaveCriticalSection(&d3d9_cs);
1304 HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride) {
1305 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1306 IWineD3DVertexBuffer *retStream = NULL;
1307 HRESULT rc = D3D_OK;
1309 TRACE("(%p) Relay\n" , This);
1311 if(pStream == NULL){
1312 return D3DERR_INVALIDCALL;
1315 EnterCriticalSection(&d3d9_cs);
1316 rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, OffsetInBytes, pStride);
1317 if (rc == D3D_OK && NULL != retStream) {
1318 IWineD3DVertexBuffer_GetParent(retStream, (IUnknown **)pStream);
1319 IWineD3DVertexBuffer_Release(retStream);
1322 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes, pStride);
1326 LeaveCriticalSection(&d3d9_cs);
1331 static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT Divider) {
1332 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1334 TRACE("(%p) Relay\n" , This);
1336 EnterCriticalSection(&d3d9_cs);
1337 hr = IWineD3DDevice_SetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
1338 LeaveCriticalSection(&d3d9_cs);
1342 static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT* Divider) {
1343 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1345 TRACE("(%p) Relay\n" , This);
1347 EnterCriticalSection(&d3d9_cs);
1348 hr = IWineD3DDevice_GetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
1349 LeaveCriticalSection(&d3d9_cs);
1353 static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9* pIndexData) {
1354 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1356 TRACE("(%p) Relay\n", This);
1358 EnterCriticalSection(&d3d9_cs);
1359 hr = IWineD3DDevice_SetIndices(This->WineD3DDevice,
1360 pIndexData ? ((IDirect3DIndexBuffer9Impl *)pIndexData)->wineD3DIndexBuffer : NULL);
1361 LeaveCriticalSection(&d3d9_cs);
1365 static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9 **ppIndexData) {
1366 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1367 IWineD3DIndexBuffer *retIndexData = NULL;
1368 HRESULT rc = D3D_OK;
1370 TRACE("(%p) Relay\n", This);
1372 if(ppIndexData == NULL){
1373 return D3DERR_INVALIDCALL;
1376 EnterCriticalSection(&d3d9_cs);
1377 rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData);
1378 if (SUCCEEDED(rc) && retIndexData) {
1379 IWineD3DIndexBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
1380 IWineD3DIndexBuffer_Release(retIndexData);
1382 if (FAILED(rc)) FIXME("Call to GetIndices failed\n");
1383 *ppIndexData = NULL;
1385 LeaveCriticalSection(&d3d9_cs);
1389 static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
1390 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1392 TRACE("(%p) Relay\n", This);
1394 EnterCriticalSection(&d3d9_cs);
1395 hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
1396 LeaveCriticalSection(&d3d9_cs);
1399 /*http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawTriPatch.asp*/
1400 static HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
1401 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1403 TRACE("(%p) Relay\n", This);
1405 EnterCriticalSection(&d3d9_cs);
1406 hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
1407 LeaveCriticalSection(&d3d9_cs);
1411 static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9 iface, UINT Handle) {
1412 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
1414 TRACE("(%p) Relay\n", This);
1416 EnterCriticalSection(&d3d9_cs);
1417 hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
1418 LeaveCriticalSection(&d3d9_cs);
1422 const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl =
1425 IDirect3DDevice9Impl_QueryInterface,
1426 IDirect3DDevice9Impl_AddRef,
1427 IDirect3DDevice9Impl_Release,
1428 /* IDirect3DDevice9 */
1429 IDirect3DDevice9Impl_TestCooperativeLevel,
1430 IDirect3DDevice9Impl_GetAvailableTextureMem,
1431 IDirect3DDevice9Impl_EvictManagedResources,
1432 IDirect3DDevice9Impl_GetDirect3D,
1433 IDirect3DDevice9Impl_GetDeviceCaps,
1434 IDirect3DDevice9Impl_GetDisplayMode,
1435 IDirect3DDevice9Impl_GetCreationParameters,
1436 IDirect3DDevice9Impl_SetCursorProperties,
1437 IDirect3DDevice9Impl_SetCursorPosition,
1438 IDirect3DDevice9Impl_ShowCursor,
1439 IDirect3DDevice9Impl_CreateAdditionalSwapChain,
1440 IDirect3DDevice9Impl_GetSwapChain,
1441 IDirect3DDevice9Impl_GetNumberOfSwapChains,
1442 IDirect3DDevice9Impl_Reset,
1443 IDirect3DDevice9Impl_Present,
1444 IDirect3DDevice9Impl_GetBackBuffer,
1445 IDirect3DDevice9Impl_GetRasterStatus,
1446 IDirect3DDevice9Impl_SetDialogBoxMode,
1447 IDirect3DDevice9Impl_SetGammaRamp,
1448 IDirect3DDevice9Impl_GetGammaRamp,
1449 IDirect3DDevice9Impl_CreateTexture,
1450 IDirect3DDevice9Impl_CreateVolumeTexture,
1451 IDirect3DDevice9Impl_CreateCubeTexture,
1452 IDirect3DDevice9Impl_CreateVertexBuffer,
1453 IDirect3DDevice9Impl_CreateIndexBuffer,
1454 IDirect3DDevice9Impl_CreateRenderTarget,
1455 IDirect3DDevice9Impl_CreateDepthStencilSurface,
1456 IDirect3DDevice9Impl_UpdateSurface,
1457 IDirect3DDevice9Impl_UpdateTexture,
1458 IDirect3DDevice9Impl_GetRenderTargetData,
1459 IDirect3DDevice9Impl_GetFrontBufferData,
1460 IDirect3DDevice9Impl_StretchRect,
1461 IDirect3DDevice9Impl_ColorFill,
1462 IDirect3DDevice9Impl_CreateOffscreenPlainSurface,
1463 IDirect3DDevice9Impl_SetRenderTarget,
1464 IDirect3DDevice9Impl_GetRenderTarget,
1465 IDirect3DDevice9Impl_SetDepthStencilSurface,
1466 IDirect3DDevice9Impl_GetDepthStencilSurface,
1467 IDirect3DDevice9Impl_BeginScene,
1468 IDirect3DDevice9Impl_EndScene,
1469 IDirect3DDevice9Impl_Clear,
1470 IDirect3DDevice9Impl_SetTransform,
1471 IDirect3DDevice9Impl_GetTransform,
1472 IDirect3DDevice9Impl_MultiplyTransform,
1473 IDirect3DDevice9Impl_SetViewport,
1474 IDirect3DDevice9Impl_GetViewport,
1475 IDirect3DDevice9Impl_SetMaterial,
1476 IDirect3DDevice9Impl_GetMaterial,
1477 IDirect3DDevice9Impl_SetLight,
1478 IDirect3DDevice9Impl_GetLight,
1479 IDirect3DDevice9Impl_LightEnable,
1480 IDirect3DDevice9Impl_GetLightEnable,
1481 IDirect3DDevice9Impl_SetClipPlane,
1482 IDirect3DDevice9Impl_GetClipPlane,
1483 IDirect3DDevice9Impl_SetRenderState,
1484 IDirect3DDevice9Impl_GetRenderState,
1485 IDirect3DDevice9Impl_CreateStateBlock,
1486 IDirect3DDevice9Impl_BeginStateBlock,
1487 IDirect3DDevice9Impl_EndStateBlock,
1488 IDirect3DDevice9Impl_SetClipStatus,
1489 IDirect3DDevice9Impl_GetClipStatus,
1490 IDirect3DDevice9Impl_GetTexture,
1491 IDirect3DDevice9Impl_SetTexture,
1492 IDirect3DDevice9Impl_GetTextureStageState,
1493 IDirect3DDevice9Impl_SetTextureStageState,
1494 IDirect3DDevice9Impl_GetSamplerState,
1495 IDirect3DDevice9Impl_SetSamplerState,
1496 IDirect3DDevice9Impl_ValidateDevice,
1497 IDirect3DDevice9Impl_SetPaletteEntries,
1498 IDirect3DDevice9Impl_GetPaletteEntries,
1499 IDirect3DDevice9Impl_SetCurrentTexturePalette,
1500 IDirect3DDevice9Impl_GetCurrentTexturePalette,
1501 IDirect3DDevice9Impl_SetScissorRect,
1502 IDirect3DDevice9Impl_GetScissorRect,
1503 IDirect3DDevice9Impl_SetSoftwareVertexProcessing,
1504 IDirect3DDevice9Impl_GetSoftwareVertexProcessing,
1505 IDirect3DDevice9Impl_SetNPatchMode,
1506 IDirect3DDevice9Impl_GetNPatchMode,
1507 IDirect3DDevice9Impl_DrawPrimitive,
1508 IDirect3DDevice9Impl_DrawIndexedPrimitive,
1509 IDirect3DDevice9Impl_DrawPrimitiveUP,
1510 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP,
1511 IDirect3DDevice9Impl_ProcessVertices,
1512 IDirect3DDevice9Impl_CreateVertexDeclaration,
1513 IDirect3DDevice9Impl_SetVertexDeclaration,
1514 IDirect3DDevice9Impl_GetVertexDeclaration,
1515 IDirect3DDevice9Impl_SetFVF,
1516 IDirect3DDevice9Impl_GetFVF,
1517 IDirect3DDevice9Impl_CreateVertexShader,
1518 IDirect3DDevice9Impl_SetVertexShader,
1519 IDirect3DDevice9Impl_GetVertexShader,
1520 IDirect3DDevice9Impl_SetVertexShaderConstantF,
1521 IDirect3DDevice9Impl_GetVertexShaderConstantF,
1522 IDirect3DDevice9Impl_SetVertexShaderConstantI,
1523 IDirect3DDevice9Impl_GetVertexShaderConstantI,
1524 IDirect3DDevice9Impl_SetVertexShaderConstantB,
1525 IDirect3DDevice9Impl_GetVertexShaderConstantB,
1526 IDirect3DDevice9Impl_SetStreamSource,
1527 IDirect3DDevice9Impl_GetStreamSource,
1528 IDirect3DDevice9Impl_SetStreamSourceFreq,
1529 IDirect3DDevice9Impl_GetStreamSourceFreq,
1530 IDirect3DDevice9Impl_SetIndices,
1531 IDirect3DDevice9Impl_GetIndices,
1532 IDirect3DDevice9Impl_CreatePixelShader,
1533 IDirect3DDevice9Impl_SetPixelShader,
1534 IDirect3DDevice9Impl_GetPixelShader,
1535 IDirect3DDevice9Impl_SetPixelShaderConstantF,
1536 IDirect3DDevice9Impl_GetPixelShaderConstantF,
1537 IDirect3DDevice9Impl_SetPixelShaderConstantI,
1538 IDirect3DDevice9Impl_GetPixelShaderConstantI,
1539 IDirect3DDevice9Impl_SetPixelShaderConstantB,
1540 IDirect3DDevice9Impl_GetPixelShaderConstantB,
1541 IDirect3DDevice9Impl_DrawRectPatch,
1542 IDirect3DDevice9Impl_DrawTriPatch,
1543 IDirect3DDevice9Impl_DeletePatch,
1544 IDirect3DDevice9Impl_CreateQuery
1548 /* Internal function called back during the CreateDevice to create a render target */
1549 HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
1550 WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
1551 WINED3DCUBEMAP_FACES Face,IWineD3DSurface** ppSurface,
1552 HANDLE* pSharedHandle) {
1554 HRESULT res = D3D_OK;
1555 IDirect3DSurface9Impl *d3dSurface = NULL;
1556 BOOL Lockable = TRUE;
1558 if((Pool == D3DPOOL_DEFAULT && Usage != D3DUSAGE_DYNAMIC))
1562 res = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9 *)device, Width, Height, (D3DFORMAT)Format,
1563 Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface9 **)&d3dSurface, D3DRTYPE_SURFACE,
1564 Usage, (D3DPOOL) Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, pSharedHandle);
1566 if (SUCCEEDED(res)) {
1567 *ppSurface = d3dSurface->wineD3DSurface;
1568 d3dSurface->container = pSuperior;
1569 IUnknown_Release(d3dSurface->parentDevice);
1570 d3dSurface->parentDevice = NULL;
1571 d3dSurface->forwardReference = pSuperior;
1573 FIXME("(%p) IDirect3DDevice9_CreateSurface failed\n", device);
1578 ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface) {
1579 IDirect3DSurface9Impl* surfaceParent;
1580 TRACE("(%p) call back\n", pSurface);
1582 IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
1583 /* GetParent's AddRef was forwarded to an object in destruction.
1584 * Releasing it here again would cause an endless recursion. */
1585 surfaceParent->forwardReference = NULL;
1586 return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);