janitorial: Remove redundant NULL checks before calling HeapFree wrappers.
[wine/wine-kai.git] / dlls / d3d9 / device.c
blobb450cbbb2227daef5c83d1cca126da741f8e5f37
1 /*
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
23 #include "config.h"
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);
36 *ppobj = This;
37 return S_OK;
40 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
41 *ppobj = NULL;
42 return E_NOINTERFACE;
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);
51 return ref;
54 static ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9 iface) {
55 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
56 ULONG ref = InterlockedDecrement(&This->ref);
58 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
60 if (ref == 0) {
61 IWineD3DDevice_Uninit3D(This->WineD3DDevice);
62 IWineD3DDevice_Release(This->WineD3DDevice);
63 HeapFree(GetProcessHeap(), 0, This);
65 return ref;
68 /* IDirect3DDevice Interface follow: */
69 static HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface) {
70 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
72 TRACE("(%p) : Relay\n", This);
73 return IWineD3DDevice_TestCooperativeLevel(This->WineD3DDevice);
76 static UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface) {
77 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
79 TRACE("(%p) Relay\n", This);
80 return IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
83 static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9 iface) {
84 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
86 TRACE("(%p) : Relay\n", This);
87 return IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
90 HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9) {
91 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
92 HRESULT hr = D3D_OK;
93 IWineD3D* pWineD3D;
95 TRACE("(%p) Relay\n", This);
97 if (NULL == ppD3D9) {
98 return D3DERR_INVALIDCALL;
100 hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
101 if (hr == D3D_OK && pWineD3D != NULL)
103 IWineD3DResource_GetParent((IWineD3DResource *)pWineD3D,(IUnknown **)ppD3D9);
104 IWineD3DResource_Release((IWineD3DResource *)pWineD3D);
105 } else {
106 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
107 *ppD3D9 = NULL;
109 TRACE("(%p) returning %p\n", This, *ppD3D9);
110 return hr;
113 static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9 iface, D3DCAPS9* pCaps) {
114 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
115 HRESULT hrc = D3D_OK;
116 WINED3DCAPS *pWineCaps;
118 TRACE("(%p) : Relay pCaps %p\n", This, pCaps);
119 if(NULL == pCaps){
120 return D3DERR_INVALIDCALL;
122 pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
123 if(pWineCaps == NULL){
124 return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
127 D3D9CAPSTOWINECAPS(pCaps, pWineCaps)
128 hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
129 HeapFree(GetProcessHeap(), 0, pWineCaps);
130 TRACE("Returning %p %p\n", This, pCaps);
131 return hrc;
134 static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) {
135 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
136 TRACE("(%p) Relay\n", This);
137 return IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, (WINED3DDISPLAYMODE *) pMode);
140 static HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
141 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
142 TRACE("(%p) Relay\n", This);
143 return IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
146 static HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) {
147 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
148 IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pCursorBitmap;
149 TRACE("(%p) Relay\n", This);
150 if(!pCursorBitmap) {
151 WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
152 return WINED3DERR_INVALIDCALL;
154 return IWineD3DDevice_SetCursorProperties(This->WineD3DDevice,XHotSpot,YHotSpot,(IWineD3DSurface*)pSurface->wineD3DSurface);
157 static void WINAPI IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9 iface, int XScreenSpace, int YScreenSpace, DWORD Flags) {
158 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
159 TRACE("(%p) Relay\n", This);
160 return IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
163 static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9 iface, BOOL bShow) {
164 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
165 TRACE("(%p) Relay\n", This);
167 return IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
170 static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
171 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
172 WINED3DPRESENT_PARAMETERS localParameters;
173 TRACE("(%p) Relay pPresentationParameters(%p)\n", This, pPresentationParameters);
175 localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth;
176 localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight;
177 localParameters.BackBufferFormat = (WINED3DFORMAT *)&pPresentationParameters->BackBufferFormat;
178 localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount;
179 localParameters.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pPresentationParameters->MultiSampleType;
180 localParameters.MultiSampleQuality = &pPresentationParameters->MultiSampleQuality;
181 localParameters.SwapEffect = (WINED3DSWAPEFFECT *) &pPresentationParameters->SwapEffect;
182 localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow;
183 localParameters.Windowed = &pPresentationParameters->Windowed;
184 localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil;
185 localParameters.AutoDepthStencilFormat = (WINED3DFORMAT *)&pPresentationParameters->AutoDepthStencilFormat;
186 localParameters.Flags = &pPresentationParameters->Flags;
187 localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
188 localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval;
189 return IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
192 static HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA*
193 pDirtyRegion) {
194 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
195 TRACE("(%p) Relay\n", This);
196 return IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
199 static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 ** ppBackBuffer) {
200 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
201 IWineD3DSurface *retSurface = NULL;
202 HRESULT rc = D3D_OK;
204 TRACE("(%p) Relay\n", This);
206 rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, (IWineD3DSurface **)&retSurface);
207 if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
208 IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
209 IWineD3DSurface_Release(retSurface);
211 return rc;
213 static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
214 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
215 TRACE("(%p) Relay\n", This);
217 return IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, iSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
220 static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface, BOOL bEnableDialogs) {
221 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
222 TRACE("(%p) Relay\n", This);
224 return IWineD3DDevice_SetDialogBoxMode(This->WineD3DDevice, bEnableDialogs);
227 static void WINAPI IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
229 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
230 TRACE("(%p) Relay\n", This);
232 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
233 return IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, iSwapChain, Flags, (WINED3DGAMMARAMP *) pRamp);
236 static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DGAMMARAMP* pRamp) {
237 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
238 TRACE("(%p) Relay\n", This);
240 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
241 return IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, iSwapChain, (WINED3DGAMMARAMP *) pRamp);
245 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 ) {
246 HRESULT hrc;
247 IDirect3DSurface9Impl *object;
248 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
249 TRACE("(%p) Relay\n", This);
250 if(MultisampleQuality < 0) {
251 FIXME("MultisampleQuality out of range %d, substituting 0\n", MultisampleQuality);
252 /*FIXME: Find out what windows does with a MultisampleQuality < 0 */
253 MultisampleQuality=0;
256 if(MultisampleQuality > 0){
257 FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality);
259 MultisampleQuality
260 [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.
263 MultisampleQuality=0;
265 /*FIXME: Check MAX bounds of MultisampleQuality*/
267 /* Allocate the storage for the device */
268 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
269 if (NULL == object) {
270 FIXME("Allocation of memory failed\n");
271 return D3DERR_OUTOFVIDEOMEMORY;
274 object->lpVtbl = &Direct3DSurface9_Vtbl;
275 object->ref = 1;
277 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
279 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);
281 if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
283 /* free up object */
284 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This);
285 HeapFree(GetProcessHeap(), 0, object);
286 } else {
287 IUnknown_AddRef(iface);
288 object->parentDevice = iface;
289 TRACE("(%p) : Created surface %p\n", This, object);
290 *ppSurface = (LPDIRECT3DSURFACE9) object;
292 return hrc;
297 static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height,
298 D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
299 DWORD MultisampleQuality, BOOL Lockable,
300 IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
301 TRACE("Relay\n");
302 /* Is this correct? */
303 return IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,Lockable,FALSE/*Discard*/, 0/*Level*/, ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_RENDERTARGET,D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
308 static HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height,
309 D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
310 DWORD MultisampleQuality, BOOL Discard,
311 IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
312 TRACE("Relay\n");
313 return IDirect3DDevice9Impl_CreateSurface(iface,Width,Height,Format,TRUE/* Lockable */,Discard, 0/* Level */
314 ,ppSurface,D3DRTYPE_SURFACE,D3DUSAGE_DEPTHSTENCIL,
315 D3DPOOL_DEFAULT,MultiSample,MultisampleQuality,pSharedHandle);
319 static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) {
320 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
321 TRACE("(%p) Relay\n" , This);
322 return IWineD3DDevice_UpdateSurface(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestinationSurface)->wineD3DSurface, pDestPoint);
325 static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9 iface, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) {
326 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
327 TRACE("(%p) Relay\n" , This);
328 return IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture9Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture9Impl *)pDestinationTexture)->wineD3DBaseTexture);
331 /* This isn't in MSDN!
332 static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBuffer(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pDestSurface) {
333 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
334 FIXME("(%p) : stub\n", This);
335 return D3D_OK;
339 static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) {
340 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
341 IDirect3DSurface9Impl *renderTarget = (IDirect3DSurface9Impl *)pRenderTarget;
342 IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
343 TRACE("(%p) Relay\n" , This);
344 return IWineD3DDevice_GetRenderTargetData(This->WineD3DDevice, renderTarget->wineD3DSurface, destSurface->wineD3DSurface);
347 static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSurface9* pDestSurface) {
348 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
349 IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
350 TRACE("(%p) Relay\n" , This);
351 return IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, iSwapChain, destSurface->wineD3DSurface);
354 static HRESULT WINAPI IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) {
355 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
356 TRACE("(%p) Relay\n" , This);
357 return IWineD3DDevice_StretchRect(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface, pDestRect, (WINED3DTEXTUREFILTERTYPE) Filter);
360 static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) {
361 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
362 IDirect3DSurface9Impl *surface = (IDirect3DSurface9Impl *)pSurface;
363 TRACE("(%p) Relay\n" , This);
365 /* Note: D3DRECT is compatible with WINED3DRECT */
366 return IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wineD3DSurface, (CONST WINED3DRECT*)pRect, color);
369 static HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
370 TRACE("Relay\n");
371 if(Pool == D3DPOOL_MANAGED ){
372 FIXME("Attempting to create a managed offscreen plain surface\n");
373 return D3DERR_INVALIDCALL;
375 /*MSDN: D3DPOOL_SCRATCH will return a surface that has identical characteristics to a surface created by the Microsoft DirectX 8.x method CreateImageSurface.
377 'Off-screen plain surfaces are always lockable, regardless of their pool types.'
378 but then...
379 D3DPOOL_DEFAULT is the appropriate pool for use with the IDirect3DDevice9::StretchRect and IDirect3DDevice9::ColorFill.
380 Why, their always lockable?
381 should I change the usage to dynamic?
383 return 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);
386 /* TODO: move to wineD3D */
387 static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
388 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
389 IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget;
390 TRACE("(%p) Relay\n" , This);
391 return IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, RenderTargetIndex, pSurface ? (IWineD3DSurface*)pSurface->wineD3DSurface : NULL);
394 static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) {
395 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
396 HRESULT hr = D3D_OK;
397 IWineD3DSurface *pRenderTarget;
399 TRACE("(%p) Relay\n" , This);
401 if (ppRenderTarget == NULL) {
402 return D3DERR_INVALIDCALL;
404 hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget);
406 if (hr == D3D_OK && pRenderTarget != NULL) {
407 IWineD3DResource_GetParent((IWineD3DResource *)pRenderTarget,(IUnknown**)ppRenderTarget);
408 IWineD3DResource_Release((IWineD3DResource *)pRenderTarget);
409 } else {
410 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
411 *ppRenderTarget = NULL;
413 return hr;
416 static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) {
417 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
418 IDirect3DSurface9Impl *pSurface;
420 TRACE("(%p) Relay\n" , This);
422 pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
423 return IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice,NULL==pSurface?NULL:(IWineD3DSurface*)pSurface->wineD3DSurface);
426 static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9 **ppZStencilSurface) {
427 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
428 HRESULT hr = D3D_OK;
429 IWineD3DSurface *pZStencilSurface;
431 TRACE("(%p) Relay\n" , This);
432 if(ppZStencilSurface == NULL){
433 return D3DERR_INVALIDCALL;
436 hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
437 if(hr == D3D_OK && pZStencilSurface != NULL){
438 IWineD3DResource_GetParent((IWineD3DResource *)pZStencilSurface,(IUnknown**)ppZStencilSurface);
439 IWineD3DResource_Release((IWineD3DResource *)pZStencilSurface);
440 }else{
441 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
442 *ppZStencilSurface = NULL;
444 return D3D_OK;
447 static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9 iface) {
448 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
449 TRACE("(%p) Relay\n" , This);
450 return IWineD3DDevice_BeginScene(This->WineD3DDevice);
453 static HRESULT WINAPI IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9 iface) {
454 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
455 TRACE("(%p) Relay\n" , This);
456 return IWineD3DDevice_EndScene(This->WineD3DDevice);
460 static HRESULT WINAPI IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
461 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
462 TRACE("(%p) Relay\n" , This);
464 /* Note: D3DRECT is compatible with WINED3DRECT */
465 return IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
468 static HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
469 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
470 TRACE("(%p) Relay\n" , This);
472 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
473 return IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
476 static HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) {
477 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
478 TRACE("(%p) Relay\n" , This);
480 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
481 return IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
484 static HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
485 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
486 TRACE("(%p) Relay\n" , This);
488 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
489 return IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
492 static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9 iface, CONST D3DVIEWPORT9* pViewport) {
493 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
494 TRACE("(%p) Relay\n" , This);
496 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
497 return IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
500 static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface, D3DVIEWPORT9* pViewport) {
501 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
502 TRACE("(%p) Relay\n" , This);
504 /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
505 return IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
508 static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface, CONST D3DMATERIAL9* pMaterial) {
509 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
510 TRACE("(%p) Relay\n" , This);
512 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
513 return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
516 static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface, D3DMATERIAL9* pMaterial) {
517 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
518 TRACE("(%p) Relay\n" , This);
520 /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
521 return IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
524 static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST D3DLIGHT9* pLight) {
525 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
526 TRACE("(%p) Relay\n" , This);
528 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
529 return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
532 static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, D3DLIGHT9* pLight) {
533 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
534 TRACE("(%p) Relay\n" , This);
536 /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
537 return IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
540 static HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL Enable) {
541 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
542 TRACE("(%p) Relay\n" , This);
543 return IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
546 static HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9 iface, DWORD Index, BOOL* pEnable) {
547 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
548 TRACE("(%p) Relay\n" , This);
549 return IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
552 static HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST float* pPlane) {
553 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
554 TRACE("(%p) Relay\n" , This);
555 return IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
558 static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9 iface, DWORD Index, float* pPlane) {
559 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
560 TRACE("(%p) Relay\n" , This);
561 return IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
564 static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD Value) {
565 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
566 TRACE("(%p) Relay\n" , This);
567 return IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
570 static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9 iface, D3DRENDERSTATETYPE State, DWORD* pValue) {
571 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
572 TRACE("(%p) Relay\n" , This);
573 return IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
576 static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface, CONST D3DCLIPSTATUS9* pClipStatus) {
577 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
578 TRACE("(%p) Relay\n" , This);
579 return IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
582 static HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface, D3DCLIPSTATUS9* pClipStatus) {
583 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
584 TRACE("(%p) Relay\n" , This);
585 return IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
588 static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9 **ppTexture) {
589 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
590 IWineD3DBaseTexture *retTexture = NULL;
591 HRESULT rc = D3D_OK;
593 TRACE("(%p) Relay\n" , This);
595 if(ppTexture == NULL){
596 return D3DERR_INVALIDCALL;
599 rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, (IWineD3DBaseTexture **)&retTexture);
600 if (rc == D3D_OK && NULL != retTexture) {
601 IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
602 IWineD3DBaseTexture_Release(retTexture);
603 }else{
604 FIXME("Call to get texture (%d) failed (%p)\n", Stage, retTexture);
605 *ppTexture = NULL;
607 return rc;
610 static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9* pTexture) {
611 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
612 TRACE("(%p) Relay %d %p\n" , This, Stage, pTexture);
613 return IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
614 pTexture==NULL ? NULL:((IDirect3DBaseTexture9Impl *)pTexture)->wineD3DBaseTexture);
617 static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
618 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
619 TRACE("(%p) Relay\n" , This);
620 return IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue);
623 static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
624 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
625 TRACE("(%p) Relay\n" , This);
626 return IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value);
629 static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue) {
630 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
631 TRACE("(%p) Relay\n" , This);
632 return IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Sampler, Type, pValue);
635 static HRESULT WINAPI IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9 iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) {
636 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
637 TRACE("(%p) Relay\n" , This);
638 return IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Sampler, Type, Value);
641 static HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9 iface, DWORD* pNumPasses) {
642 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
643 TRACE("(%p) Relay\n" , This);
644 return IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
647 static HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
648 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
649 TRACE("(%p) Relay\n" , This);
650 return IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
653 static HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
654 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
655 TRACE("(%p) Relay\n" , This);
656 return IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
659 static HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT PaletteNumber) {
660 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
661 TRACE("(%p) Relay\n" , This);
662 return IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
665 static HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9 iface, UINT* PaletteNumber) {
666 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
667 TRACE("(%p) Relay\n" , This);
668 return IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
671 static HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9 iface, CONST RECT* pRect) {
672 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
673 TRACE("(%p) Relay\n" , This);
674 return IWineD3DDevice_SetScissorRect(This->WineD3DDevice, pRect);
677 static HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9 iface, RECT* pRect) {
678 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
679 TRACE("(%p) Relay\n" , This);
680 return IWineD3DDevice_GetScissorRect(This->WineD3DDevice, pRect);
683 static HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface, BOOL bSoftware) {
684 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
685 TRACE("(%p) Relay\n" , This);
686 return IWineD3DDevice_SetSoftwareVertexProcessing(This->WineD3DDevice, bSoftware);
689 static BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface) {
690 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
691 TRACE("(%p) Relay\n" , This);
692 return IWineD3DDevice_GetSoftwareVertexProcessing(This->WineD3DDevice);
695 static HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9 iface, float nSegments) {
696 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
697 TRACE("(%p) Relay\n" , This);
698 return IWineD3DDevice_SetNPatchMode(This->WineD3DDevice, nSegments);
701 static float WINAPI IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9 iface) {
702 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
703 TRACE("(%p) Relay\n" , This);
704 return IWineD3DDevice_GetNPatchMode(This->WineD3DDevice);
707 static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
708 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
709 TRACE("(%p) Relay\n" , This);
710 return IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex, PrimitiveCount);
713 static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType,
714 INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) {
715 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
716 TRACE("(%p) Relay\n" , This);
717 return IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
720 static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
721 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
722 TRACE("(%p) Relay\n" , This);
723 return IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
726 static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9 iface, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex,
727 UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData,
728 D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
729 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
730 TRACE("(%p) Relay\n" , This);
731 return IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertexIndices, PrimitiveCount,
732 pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
735 static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9 iface, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) {
736 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
737 TRACE("(%p) Relay\n" , This);
738 return IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, ((IDirect3DVertexBuffer9Impl *)pDestBuffer)->wineD3DVertexBuffer, ((IDirect3DVertexBuffer9Impl *)pVertexDecl)->wineD3DVertexBuffer, Flags);
741 HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9 iface, DWORD FVF) {
742 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
743 TRACE("(%p) Relay\n" , This);
745 if (0 != FVF) {
746 HRESULT hr;
747 D3DVERTEXELEMENT9* elements = NULL;
748 IDirect3DVertexDeclaration9* pDecl = NULL;
750 hr = vdecl_convert_fvf(FVF, &elements);
751 if (hr != S_OK) goto exit;
753 hr = IDirect3DDevice9Impl_CreateVertexDeclaration(iface, elements, &pDecl);
754 if (hr != S_OK) goto exit;
756 hr = IDirect3DDevice9Impl_SetVertexDeclaration(iface, pDecl);
757 if (hr != S_OK) goto exit;
758 pDecl = NULL;
760 exit:
761 HeapFree(GetProcessHeap(), 0, elements);
762 if (pDecl) IUnknown_Release(pDecl);
763 if (hr != S_OK) return hr;
766 return IWineD3DDevice_SetFVF(This->WineD3DDevice, FVF);
769 HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9 iface, DWORD* pFVF) {
770 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
771 TRACE("(%p) Relay\n" , This);
772 return IWineD3DDevice_GetFVF(This->WineD3DDevice, pFVF);
775 HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
776 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
777 TRACE("(%p) Relay\n" , This);
778 return IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
779 pStreamData==NULL ? NULL:((IDirect3DVertexBuffer9Impl *)pStreamData)->wineD3DVertexBuffer,
780 OffsetInBytes, Stride);
783 HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride) {
784 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
785 IWineD3DVertexBuffer *retStream = NULL;
786 HRESULT rc = D3D_OK;
788 TRACE("(%p) Relay\n" , This);
790 if(pStream == NULL){
791 return D3DERR_INVALIDCALL;
794 rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, (IWineD3DVertexBuffer **)&retStream, OffsetInBytes, pStride);
795 if (rc == D3D_OK && NULL != retStream) {
796 IWineD3DVertexBuffer_GetParent(retStream, (IUnknown **)pStream);
797 IWineD3DVertexBuffer_Release(retStream);
798 }else{
799 FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes, pStride);
800 *pStream = NULL;
802 return rc;
805 static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT Divider) {
806 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
807 TRACE("(%p) Relay\n" , This);
808 IWineD3DDevice_SetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
809 return D3D_OK;
812 static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT* Divider) {
813 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
814 TRACE("(%p) Relay\n" , This);
815 return IWineD3DDevice_GetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
816 return D3D_OK;
819 static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9* pIndexData) {
820 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
821 TRACE("(%p) Relay\n", This);
822 return IWineD3DDevice_SetIndices(This->WineD3DDevice,
823 pIndexData==NULL ? NULL:((IDirect3DIndexBuffer9Impl *)pIndexData)->wineD3DIndexBuffer,
827 static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9 **ppIndexData) {
828 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
829 IWineD3DIndexBuffer *retIndexData = NULL;
830 HRESULT rc = D3D_OK;
831 UINT tmp;
833 TRACE("(%p) Relay\n", This);
835 if(ppIndexData == NULL){
836 return D3DERR_INVALIDCALL;
839 rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData, &tmp);
840 if (rc == D3D_OK && NULL != retIndexData) {
841 IWineD3DVertexBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
842 IWineD3DVertexBuffer_Release(retIndexData);
843 }else{
844 if(rc != D3D_OK) FIXME("Call to GetIndices failed\n");
845 *ppIndexData = NULL;
847 return rc;
850 static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
851 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
852 TRACE("(%p) Relay\n", This);
853 return IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (WINED3DRECTPATCH_INFO *)pRectPatchInfo);
855 /*http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3ddevice9/DrawTriPatch.asp*/
856 static HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9 iface, UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
857 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
858 TRACE("(%p) Relay\n", This);
859 return IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (WINED3DTRIPATCH_INFO *) pTriPatchInfo);
862 static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9 iface, UINT Handle) {
863 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
864 TRACE("(%p) Relay\n", This);
865 return IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
868 const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl =
870 /* IUnknown */
871 IDirect3DDevice9Impl_QueryInterface,
872 IDirect3DDevice9Impl_AddRef,
873 IDirect3DDevice9Impl_Release,
874 /* IDirect3DDevice9 */
875 IDirect3DDevice9Impl_TestCooperativeLevel,
876 IDirect3DDevice9Impl_GetAvailableTextureMem,
877 IDirect3DDevice9Impl_EvictManagedResources,
878 IDirect3DDevice9Impl_GetDirect3D,
879 IDirect3DDevice9Impl_GetDeviceCaps,
880 IDirect3DDevice9Impl_GetDisplayMode,
881 IDirect3DDevice9Impl_GetCreationParameters,
882 IDirect3DDevice9Impl_SetCursorProperties,
883 IDirect3DDevice9Impl_SetCursorPosition,
884 IDirect3DDevice9Impl_ShowCursor,
885 IDirect3DDevice9Impl_CreateAdditionalSwapChain,
886 IDirect3DDevice9Impl_GetSwapChain,
887 IDirect3DDevice9Impl_GetNumberOfSwapChains,
888 IDirect3DDevice9Impl_Reset,
889 IDirect3DDevice9Impl_Present,
890 IDirect3DDevice9Impl_GetBackBuffer,
891 IDirect3DDevice9Impl_GetRasterStatus,
892 IDirect3DDevice9Impl_SetDialogBoxMode,
893 IDirect3DDevice9Impl_SetGammaRamp,
894 IDirect3DDevice9Impl_GetGammaRamp,
895 IDirect3DDevice9Impl_CreateTexture,
896 IDirect3DDevice9Impl_CreateVolumeTexture,
897 IDirect3DDevice9Impl_CreateCubeTexture,
898 IDirect3DDevice9Impl_CreateVertexBuffer,
899 IDirect3DDevice9Impl_CreateIndexBuffer,
900 IDirect3DDevice9Impl_CreateRenderTarget,
901 IDirect3DDevice9Impl_CreateDepthStencilSurface,
902 IDirect3DDevice9Impl_UpdateSurface,
903 IDirect3DDevice9Impl_UpdateTexture,
904 IDirect3DDevice9Impl_GetRenderTargetData,
905 IDirect3DDevice9Impl_GetFrontBufferData,
906 IDirect3DDevice9Impl_StretchRect,
907 IDirect3DDevice9Impl_ColorFill,
908 IDirect3DDevice9Impl_CreateOffscreenPlainSurface,
909 IDirect3DDevice9Impl_SetRenderTarget,
910 IDirect3DDevice9Impl_GetRenderTarget,
911 IDirect3DDevice9Impl_SetDepthStencilSurface,
912 IDirect3DDevice9Impl_GetDepthStencilSurface,
913 IDirect3DDevice9Impl_BeginScene,
914 IDirect3DDevice9Impl_EndScene,
915 IDirect3DDevice9Impl_Clear,
916 IDirect3DDevice9Impl_SetTransform,
917 IDirect3DDevice9Impl_GetTransform,
918 IDirect3DDevice9Impl_MultiplyTransform,
919 IDirect3DDevice9Impl_SetViewport,
920 IDirect3DDevice9Impl_GetViewport,
921 IDirect3DDevice9Impl_SetMaterial,
922 IDirect3DDevice9Impl_GetMaterial,
923 IDirect3DDevice9Impl_SetLight,
924 IDirect3DDevice9Impl_GetLight,
925 IDirect3DDevice9Impl_LightEnable,
926 IDirect3DDevice9Impl_GetLightEnable,
927 IDirect3DDevice9Impl_SetClipPlane,
928 IDirect3DDevice9Impl_GetClipPlane,
929 IDirect3DDevice9Impl_SetRenderState,
930 IDirect3DDevice9Impl_GetRenderState,
931 IDirect3DDevice9Impl_CreateStateBlock,
932 IDirect3DDevice9Impl_BeginStateBlock,
933 IDirect3DDevice9Impl_EndStateBlock,
934 IDirect3DDevice9Impl_SetClipStatus,
935 IDirect3DDevice9Impl_GetClipStatus,
936 IDirect3DDevice9Impl_GetTexture,
937 IDirect3DDevice9Impl_SetTexture,
938 IDirect3DDevice9Impl_GetTextureStageState,
939 IDirect3DDevice9Impl_SetTextureStageState,
940 IDirect3DDevice9Impl_GetSamplerState,
941 IDirect3DDevice9Impl_SetSamplerState,
942 IDirect3DDevice9Impl_ValidateDevice,
943 IDirect3DDevice9Impl_SetPaletteEntries,
944 IDirect3DDevice9Impl_GetPaletteEntries,
945 IDirect3DDevice9Impl_SetCurrentTexturePalette,
946 IDirect3DDevice9Impl_GetCurrentTexturePalette,
947 IDirect3DDevice9Impl_SetScissorRect,
948 IDirect3DDevice9Impl_GetScissorRect,
949 IDirect3DDevice9Impl_SetSoftwareVertexProcessing,
950 IDirect3DDevice9Impl_GetSoftwareVertexProcessing,
951 IDirect3DDevice9Impl_SetNPatchMode,
952 IDirect3DDevice9Impl_GetNPatchMode,
953 IDirect3DDevice9Impl_DrawPrimitive,
954 IDirect3DDevice9Impl_DrawIndexedPrimitive,
955 IDirect3DDevice9Impl_DrawPrimitiveUP,
956 IDirect3DDevice9Impl_DrawIndexedPrimitiveUP,
957 IDirect3DDevice9Impl_ProcessVertices,
958 IDirect3DDevice9Impl_CreateVertexDeclaration,
959 IDirect3DDevice9Impl_SetVertexDeclaration,
960 IDirect3DDevice9Impl_GetVertexDeclaration,
961 IDirect3DDevice9Impl_SetFVF,
962 IDirect3DDevice9Impl_GetFVF,
963 IDirect3DDevice9Impl_CreateVertexShader,
964 IDirect3DDevice9Impl_SetVertexShader,
965 IDirect3DDevice9Impl_GetVertexShader,
966 IDirect3DDevice9Impl_SetVertexShaderConstantF,
967 IDirect3DDevice9Impl_GetVertexShaderConstantF,
968 IDirect3DDevice9Impl_SetVertexShaderConstantI,
969 IDirect3DDevice9Impl_GetVertexShaderConstantI,
970 IDirect3DDevice9Impl_SetVertexShaderConstantB,
971 IDirect3DDevice9Impl_GetVertexShaderConstantB,
972 IDirect3DDevice9Impl_SetStreamSource,
973 IDirect3DDevice9Impl_GetStreamSource,
974 IDirect3DDevice9Impl_SetStreamSourceFreq,
975 IDirect3DDevice9Impl_GetStreamSourceFreq,
976 IDirect3DDevice9Impl_SetIndices,
977 IDirect3DDevice9Impl_GetIndices,
978 IDirect3DDevice9Impl_CreatePixelShader,
979 IDirect3DDevice9Impl_SetPixelShader,
980 IDirect3DDevice9Impl_GetPixelShader,
981 IDirect3DDevice9Impl_SetPixelShaderConstantF,
982 IDirect3DDevice9Impl_GetPixelShaderConstantF,
983 IDirect3DDevice9Impl_SetPixelShaderConstantI,
984 IDirect3DDevice9Impl_GetPixelShaderConstantI,
985 IDirect3DDevice9Impl_SetPixelShaderConstantB,
986 IDirect3DDevice9Impl_GetPixelShaderConstantB,
987 IDirect3DDevice9Impl_DrawRectPatch,
988 IDirect3DDevice9Impl_DrawTriPatch,
989 IDirect3DDevice9Impl_DeletePatch,
990 IDirect3DDevice9Impl_CreateQuery
994 /* Internal function called back during the CreateDevice to create a render target */
995 HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
996 WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
997 IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
999 HRESULT res = D3D_OK;
1000 IDirect3DSurface9Impl *d3dSurface = NULL;
1001 BOOL Lockable = TRUE;
1003 if((Pool == D3DPOOL_DEFAULT && Usage != D3DUSAGE_DYNAMIC))
1004 Lockable = FALSE;
1006 TRACE("relay\n");
1007 res = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9 *)device, Width, Height, (D3DFORMAT)Format,
1008 Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface9 **)&d3dSurface, D3DRTYPE_SURFACE,
1009 Usage, (D3DPOOL) Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, pSharedHandle);
1011 if (SUCCEEDED(res)) {
1012 *ppSurface = d3dSurface->wineD3DSurface;
1013 IUnknown_Release(d3dSurface->parentDevice);
1014 d3dSurface->parentDevice = NULL;
1015 } else {
1016 FIXME("(%p) IDirect3DDevice9_CreateSurface failed\n", device);
1018 return res;