2 * IDirect3DDevice8 implementation
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2004 Christian Costa
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
33 #include "wine/debug.h"
35 #include "d3d8_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
39 /* IDirect3D IUnknown parts follow: */
40 static HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID riid,LPVOID *ppobj)
42 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
44 if (IsEqualGUID(riid, &IID_IUnknown)
45 || IsEqualGUID(riid, &IID_IDirect3DDevice8)) {
46 IUnknown_AddRef(iface);
51 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
56 static ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface) {
57 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
58 ULONG ref = InterlockedIncrement(&This->ref);
60 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
65 static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
66 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
67 ULONG ref = InterlockedDecrement(&This->ref);
69 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
72 TRACE("Releasing wined3d device %p\n", This->WineD3DDevice);
73 IWineD3DDevice_Uninit3D(This->WineD3DDevice);
74 IWineD3DDevice_Release(This->WineD3DDevice);
75 HeapFree(GetProcessHeap(), 0, This);
80 /* IDirect3DDevice Interface follow: */
81 static HRESULT WINAPI IDirect3DDevice8Impl_TestCooperativeLevel(LPDIRECT3DDEVICE8 iface) {
82 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
84 TRACE("(%p) : Relay\n", This);
85 return IWineD3DDevice_TestCooperativeLevel(This->WineD3DDevice);
88 static UINT WINAPI IDirect3DDevice8Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE8 iface) {
89 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
91 TRACE("(%p) Relay\n", This);
92 return IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
95 static HRESULT WINAPI IDirect3DDevice8Impl_ResourceManagerDiscardBytes(LPDIRECT3DDEVICE8 iface, DWORD Bytes) {
96 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
98 TRACE("(%p) : Relay bytes(%ld)\n", This, Bytes);
99 return IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
102 static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(LPDIRECT3DDEVICE8 iface, IDirect3D8** ppD3D8) {
103 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
107 TRACE("(%p) Relay\n", This);
109 if (NULL == ppD3D8) {
110 return D3DERR_INVALIDCALL;
112 hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
113 if (hr == D3D_OK && pWineD3D != NULL)
115 IWineD3DResource_GetParent((IWineD3DResource *)pWineD3D,(IUnknown **)ppD3D8);
116 IWineD3DResource_Release((IWineD3DResource *)pWineD3D);
118 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
121 TRACE("(%p) returning %p\b",This , *ppD3D8);
125 static HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 iface, D3DCAPS8* pCaps) {
126 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
127 HRESULT hrc = D3D_OK;
128 WINED3DCAPS *pWineCaps;
130 TRACE("(%p) : Relay pCaps %p\n", This, pCaps);
132 return D3DERR_INVALIDCALL;
134 pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
135 if(pWineCaps == NULL){
136 return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
139 D3D8CAPSTOWINECAPS(pCaps, pWineCaps)
140 hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
141 HeapFree(GetProcessHeap(), 0, pWineCaps);
142 TRACE("Returning %p %p\n", This, pCaps);
146 static HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(LPDIRECT3DDEVICE8 iface, D3DDISPLAYMODE* pMode) {
147 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
148 TRACE("(%p) Relay\n", This);
149 return IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, 0, (WINED3DDISPLAYMODE *) pMode);
152 static HRESULT WINAPI IDirect3DDevice8Impl_GetCreationParameters(LPDIRECT3DDEVICE8 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
153 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
154 TRACE("(%p) Relay\n", This);
155 return IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
158 static HRESULT WINAPI IDirect3DDevice8Impl_SetCursorProperties(LPDIRECT3DDEVICE8 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface8* pCursorBitmap) {
159 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
160 IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl*)pCursorBitmap;
161 TRACE("(%p) Relay\n", This);
162 return IWineD3DDevice_SetCursorProperties(This->WineD3DDevice,XHotSpot,YHotSpot,(IWineD3DSurface*)pSurface->wineD3DSurface);
165 static void WINAPI IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace, DWORD Flags) {
166 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
167 TRACE("(%p) Relay\n", This);
168 return IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
171 static BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL bShow) {
172 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
173 TRACE("(%p) Relay\n", This);
175 return IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
178 static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain8** pSwapChain) {
179 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
180 IDirect3DSwapChain8Impl* object;
181 HRESULT hrc = D3D_OK;
182 WINED3DPRESENT_PARAMETERS localParameters;
184 TRACE("(%p) Relay\n", This);
186 /* Fix the back buffer count */
187 if(pPresentationParameters->BackBufferCount == 0) {
188 pPresentationParameters->BackBufferCount = 1;
191 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
192 if (NULL == object) {
193 FIXME("Allocation of memory failed\n");
195 return D3DERR_OUTOFVIDEOMEMORY;
198 object->lpVtbl = &Direct3DSwapChain8_Vtbl;
200 /* Allocate an associated WineD3DDevice object */
201 localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth;
202 localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight;
203 localParameters.BackBufferFormat = (WINED3DFORMAT *)&pPresentationParameters->BackBufferFormat;
204 localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount;
205 localParameters.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pPresentationParameters->MultiSampleType;
206 localParameters.MultiSampleQuality = NULL; /* d3d9 only */
207 localParameters.SwapEffect = (WINED3DSWAPEFFECT *) &pPresentationParameters->SwapEffect;
208 localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow;
209 localParameters.Windowed = &pPresentationParameters->Windowed;
210 localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil;
211 localParameters.AutoDepthStencilFormat = (WINED3DFORMAT *)&pPresentationParameters->AutoDepthStencilFormat;
212 localParameters.Flags = &pPresentationParameters->Flags;
213 localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
214 localParameters.PresentationInterval = &pPresentationParameters->FullScreen_PresentationInterval;
217 hrc = IWineD3DDevice_CreateAdditionalSwapChain(This->WineD3DDevice, &localParameters, &object->wineD3DSwapChain, (IUnknown*)object, D3D8CB_CreateRenderTarget, D3D8CB_CreateDepthStencilSurface);
219 FIXME("(%p) call to IWineD3DDevice_CreateAdditionalSwapChain failed\n", This);
220 HeapFree(GetProcessHeap(), 0 , object);
223 IUnknown_AddRef(iface);
224 object->parentDevice = iface;
225 *pSwapChain = (IDirect3DSwapChain8 *)object;
227 TRACE("(%p) returning %p\n", This, *pSwapChain);
231 static HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
232 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
233 WINED3DPRESENT_PARAMETERS localParameters;
234 TRACE("(%p) Relay pPresentationParameters(%p)\n", This, pPresentationParameters);
236 localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth;
237 localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight;
238 localParameters.BackBufferFormat = (WINED3DFORMAT *)&pPresentationParameters->BackBufferFormat;
239 localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount;
240 localParameters.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pPresentationParameters->MultiSampleType;
241 localParameters.MultiSampleQuality = NULL; /* D3d9 only */
242 localParameters.SwapEffect = (WINED3DSWAPEFFECT *) &pPresentationParameters->SwapEffect;
243 localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow;
244 localParameters.Windowed = &pPresentationParameters->Windowed;
245 localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil;
246 localParameters.AutoDepthStencilFormat = (WINED3DFORMAT *)&pPresentationParameters->AutoDepthStencilFormat;
247 localParameters.Flags = &pPresentationParameters->Flags;
248 localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz;
249 localParameters.PresentationInterval = &pPresentationParameters->FullScreen_PresentationInterval;
250 return IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
253 static HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
254 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
255 TRACE("(%p) Relay\n", This);
256 return IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
259 static HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) {
260 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
261 IWineD3DSurface *retSurface = NULL;
264 TRACE("(%p) Relay\n", This);
266 rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, 0, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, (IWineD3DSurface **)&retSurface);
267 if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
268 IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
269 IWineD3DSurface_Release(retSurface);
274 static HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(LPDIRECT3DDEVICE8 iface, D3DRASTER_STATUS* pRasterStatus) {
275 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
276 TRACE("(%p) Relay\n", This);
278 return IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, 0, (WINED3DRASTER_STATUS *) pRasterStatus);
281 static void WINAPI IDirect3DDevice8Impl_SetGammaRamp(LPDIRECT3DDEVICE8 iface, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
282 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
283 TRACE("(%p) Relay\n", This);
285 return IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, 0, Flags, (WINED3DGAMMARAMP *) pRamp);
288 static void WINAPI IDirect3DDevice8Impl_GetGammaRamp(LPDIRECT3DDEVICE8 iface, D3DGAMMARAMP* pRamp) {
289 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
290 TRACE("(%p) Relay\n", This);
292 return IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, 0, (WINED3DGAMMARAMP *) pRamp);
295 static HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage,
296 D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8 **ppTexture) {
297 IDirect3DTexture8Impl *object;
298 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
299 HRESULT hrc = D3D_OK;
301 TRACE("(%p) : W(%d) H(%d), Lvl(%d) d(%ld), Fmt(%u), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool);
303 /* Allocate the storage for the device */
304 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture8Impl));
306 if (NULL == object) {
307 FIXME("Allocation of memory failed\n");
308 /* *ppTexture = NULL; */
309 return D3DERR_OUTOFVIDEOMEMORY;
312 object->lpVtbl = &Direct3DTexture8_Vtbl;
314 hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage,
315 (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DTexture, NULL, (IUnknown *)object, D3D8CB_CreateSurface);
319 FIXME("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
320 HeapFree(GetProcessHeap(), 0, object);
321 /* *ppTexture = NULL; */
323 IUnknown_AddRef(iface);
324 object->parentDevice = iface;
325 *ppTexture = (LPDIRECT3DTEXTURE8) object;
328 TRACE("(%p) Created Texture %p, %p\n",This,object,object->wineD3DTexture);
332 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 iface,
333 UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage,
334 D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture8** ppVolumeTexture) {
336 IDirect3DVolumeTexture8Impl *object;
337 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
338 HRESULT hrc = D3D_OK;
340 TRACE("(%p) Relay\n", This);
342 /* Allocate the storage for the device */
343 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture8Impl));
344 if (NULL == object) {
345 FIXME("(%p) allocation of memory failed\n", This);
346 *ppVolumeTexture = NULL;
347 return D3DERR_OUTOFVIDEOMEMORY;
350 object->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
352 hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage,
353 (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DVolumeTexture, NULL,
354 (IUnknown *)object, D3D8CB_CreateVolume);
359 FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This);
360 HeapFree(GetProcessHeap(), 0, object);
361 *ppVolumeTexture = NULL;
363 IUnknown_AddRef(iface);
364 object->parentDevice = iface;
365 *ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE8) object;
367 TRACE("(%p) returning %p\n", This , *ppVolumeTexture);
371 static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface, UINT EdgeLength, UINT Levels, DWORD Usage,
372 D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8** ppCubeTexture) {
374 IDirect3DCubeTexture8Impl *object;
375 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
378 TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%ld) fmt(%u), Pool(%d)\n" , This, EdgeLength, Levels, Usage, Format, Pool);
380 /* Allocate the storage for the device */
381 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
383 if (NULL == object) {
384 FIXME("(%p) allocation of CubeTexture failed\n", This);
385 *ppCubeTexture = NULL;
386 return D3DERR_OUTOFVIDEOMEMORY;
389 object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
391 hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
392 (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DCubeTexture, NULL, (IUnknown*)object,
393 D3D8CB_CreateSurface);
398 FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
399 HeapFree(GetProcessHeap(), 0, object);
400 *ppCubeTexture = NULL;
402 IUnknown_AddRef(iface);
403 object->parentDevice = iface;
404 *ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object;
407 TRACE("(%p) returning %p\n",This, *ppCubeTexture);
411 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) {
412 IDirect3DVertexBuffer8Impl *object;
413 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
414 HRESULT hrc = D3D_OK;
416 TRACE("(%p) Relay\n", This);
417 /* Allocate the storage for the device */
418 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer8Impl));
419 if (NULL == object) {
420 FIXME("Allocation of memory failed\n");
421 *ppVertexBuffer = NULL;
422 return D3DERR_OUTOFVIDEOMEMORY;
425 object->lpVtbl = &Direct3DVertexBuffer8_Vtbl;
427 hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage, FVF, (WINED3DPOOL) Pool, &(object->wineD3DVertexBuffer), NULL, (IUnknown *)object);
432 FIXME("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This);
433 HeapFree(GetProcessHeap(), 0, object);
434 *ppVertexBuffer = NULL;
436 IUnknown_AddRef(iface);
437 object->parentDevice = iface;
438 *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER8) object;
443 static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer8** ppIndexBuffer) {
444 IDirect3DIndexBuffer8Impl *object;
445 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
446 HRESULT hrc = D3D_OK;
448 TRACE("(%p) Relay\n", This);
449 /* Allocate the storage for the device */
450 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
451 if (NULL == object) {
452 FIXME("Allocation of memory failed\n");
453 *ppIndexBuffer = NULL;
454 return D3DERR_OUTOFVIDEOMEMORY;
457 object->lpVtbl = &Direct3DIndexBuffer8_Vtbl;
459 TRACE("Calling wined3d create index buffer\n");
460 hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage, Format, (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer, NULL, (IUnknown *)object);
465 FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This);
466 HeapFree(GetProcessHeap(), 0, object);
467 *ppIndexBuffer = NULL;
469 IUnknown_AddRef(iface);
470 object->parentDevice = iface;
471 *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER8)object;
476 static HRESULT WINAPI IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface8 **ppSurface,D3DRESOURCETYPE Type, UINT Usage,D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality) {
478 IDirect3DSurface8Impl *object;
479 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
480 TRACE("(%p) Relay\n", This);
481 if(MultisampleQuality < 0) {
482 FIXME("MultisampleQuality out of range %ld, substituting 0\n", MultisampleQuality);
483 /*FIXME: Find out what windows does with a MultisampleQuality < 0 */
484 MultisampleQuality=0;
487 if(MultisampleQuality > 0){
488 FIXME("MultisampleQuality set to %ld, substituting 0\n" , MultisampleQuality);
491 [in] Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by IDirect3D8::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.
493 MultisampleQuality=0;
495 /*FIXME: Check MAX bounds of MultisampleQuality*/
497 /* Allocate the storage for the device */
498 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
499 if (NULL == object) {
500 FIXME("Allocation of memory failed\n");
502 return D3DERR_OUTOFVIDEOMEMORY;
505 object->lpVtbl = &Direct3DSurface8_Vtbl;
508 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
510 hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, Format, Lockable, Discard, Level, &object->wineD3DSurface, Type, Usage, (WINED3DPOOL) Pool,MultiSample,MultisampleQuality, NULL, SURFACE_OPENGL, (IUnknown *)object);
511 if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
513 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This);
514 HeapFree(GetProcessHeap(), 0, object);
517 IUnknown_AddRef(iface);
518 object->parentDevice = iface;
519 *ppSurface = (LPDIRECT3DSURFACE8) object;
524 static HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) {
527 return IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, Lockable, FALSE /* Discard */, 0 /* Level */ , ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, MultiSample, 0);
530 static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
532 /* TODO: Verify that Discard is false */
533 return IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE, 0 /* Level */
534 ,ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_DEPTHSTENCIL,
535 D3DPOOL_DEFAULT, MultiSample, 0);
538 static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
541 return IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Loackable */ , FALSE /*Discard*/ , 0 /* Level */ , ppSurface, D3DRTYPE_SURFACE, 0 /* Usage (undefined/none) */ , D3DPOOL_SCRATCH, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
544 static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8 *pSourceSurface, CONST RECT *pSourceRects, UINT cRects, IDirect3DSurface8 *pDestinationSurface, CONST POINT *pDestPoints) {
545 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
547 TRACE("(%p) Relay\n" , This);
549 return IWineD3DDevice_CopyRects(This->WineD3DDevice, pSourceSurface == NULL ? NULL : ((IDirect3DSurface8Impl *)pSourceSurface)->wineD3DSurface,
550 pSourceRects, cRects, pDestinationSurface == NULL ? NULL : ((IDirect3DSurface8Impl *)pDestinationSurface)->wineD3DSurface, pDestPoints);
553 static HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture, IDirect3DBaseTexture8* pDestinationTexture) {
554 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
555 TRACE("(%p) Relay\n" , This);
557 return IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture8Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture8Impl *)pDestinationTexture)->wineD3DBaseTexture);
560 static HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pDestSurface) {
561 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
562 IDirect3DSurface8Impl *destSurface = (IDirect3DSurface8Impl *)pDestSurface;
564 TRACE("(%p) Relay\n" , This);
566 if (pDestSurface == NULL) {
567 WARN("(%p) : Caller passed NULL as pDestSurface returning D3DERR_INVALIDCALL\n", This);
568 return D3DERR_INVALIDCALL;
571 return IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, 0, destSurface->wineD3DSurface);
574 static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pRenderTarget, IDirect3DSurface8* pNewZStencil) {
575 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
576 IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl *)pRenderTarget;
577 IDirect3DSurface8Impl *pZSurface = (IDirect3DSurface8Impl *)pNewZStencil;
578 TRACE("(%p) Relay\n" , This);
580 IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, NULL == pZSurface ? NULL : (IWineD3DSurface *)pZSurface->wineD3DSurface);
582 return IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, 0, (IWineD3DSurface *)pSurface->wineD3DSurface);
585 static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppRenderTarget) {
586 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
588 IWineD3DSurface *pRenderTarget;
590 TRACE("(%p) Relay\n" , This);
592 if (ppRenderTarget == NULL) {
593 return D3DERR_INVALIDCALL;
595 hr = IWineD3DDevice_GetRenderTarget(This->WineD3DDevice, 0, &pRenderTarget);
597 if (hr == D3D_OK && pRenderTarget != NULL) {
598 IWineD3DResource_GetParent((IWineD3DResource *)pRenderTarget,(IUnknown**)ppRenderTarget);
599 IWineD3DResource_Release((IWineD3DResource *)pRenderTarget);
601 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
602 *ppRenderTarget = NULL;
608 static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppZStencilSurface) {
609 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
611 IWineD3DSurface *pZStencilSurface;
613 TRACE("(%p) Relay\n" , This);
614 if(ppZStencilSurface == NULL){
615 return D3DERR_INVALIDCALL;
618 hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
619 if(hr == D3D_OK && pZStencilSurface != NULL){
620 IWineD3DResource_GetParent((IWineD3DResource *)pZStencilSurface,(IUnknown**)ppZStencilSurface);
621 IWineD3DResource_Release((IWineD3DResource *)pZStencilSurface);
623 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
624 *ppZStencilSurface = NULL;
630 static HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(LPDIRECT3DDEVICE8 iface) {
631 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
632 return IWineD3DDevice_BeginScene(This->WineD3DDevice);
635 static HRESULT WINAPI IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) {
636 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
637 TRACE("(%p) Relay\n" , This);
639 return IWineD3DDevice_EndScene(This->WineD3DDevice);
642 static HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
643 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
644 TRACE("(%p) Relay\n" , This);
646 return IWineD3DDevice_Clear(This->WineD3DDevice, Count, pRects, Flags, Color, Z, Stencil);
649 static HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
650 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
651 TRACE("(%p) Relay\n" , This);
653 return IWineD3DDevice_SetTransform(This->WineD3DDevice, State, lpMatrix);
656 static HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) {
657 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
658 TRACE("(%p) Relay\n" , This);
660 return IWineD3DDevice_GetTransform(This->WineD3DDevice, State, pMatrix);
663 static HRESULT WINAPI IDirect3DDevice8Impl_MultiplyTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
664 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
665 TRACE("(%p) Relay\n" , This);
667 return IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, pMatrix);
670 static HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(LPDIRECT3DDEVICE8 iface, CONST D3DVIEWPORT8* pViewport) {
671 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
672 TRACE("(%p) Relay\n" , This);
674 return IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
677 static HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(LPDIRECT3DDEVICE8 iface, D3DVIEWPORT8* pViewport) {
678 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
679 TRACE("(%p) Relay\n" , This);
681 return IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
684 static HRESULT WINAPI IDirect3DDevice8Impl_SetMaterial(LPDIRECT3DDEVICE8 iface, CONST D3DMATERIAL8* pMaterial) {
685 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
686 TRACE("(%p) Relay\n" , This);
687 /* FIXME: Verify that D3DMATERIAL8 ~= WINED3DMATERIAL */
688 return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
691 static HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(LPDIRECT3DDEVICE8 iface, D3DMATERIAL8* pMaterial) {
692 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
693 TRACE("(%p) Relay\n" , This);
694 /* FIXME: Verify that D3DMATERIAL8 ~= WINED3DMATERIAL */
695 return IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
698 static HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST D3DLIGHT8* pLight) {
699 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
700 TRACE("(%p) Relay\n" , This);
701 /* FIXME: Verify that D3DLIGHT8 ~= WINED3DLIGHT */
702 return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
705 static HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight) {
706 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
707 TRACE("(%p) Relay\n" , This);
708 /* FIXME: Verify that D3DLIGHT8 ~= WINED3DLIGHT */
709 return IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
712 static HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL Enable) {
713 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
714 TRACE("(%p) Relay\n" , This);
716 return IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
719 static HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL* pEnable) {
720 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
721 TRACE("(%p) Relay\n" , This);
723 return IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
726 static HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,CONST float* pPlane) {
727 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
728 TRACE("(%p) Relay\n" , This);
730 return IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
733 static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,float* pPlane) {
734 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
735 TRACE("(%p) Relay\n" , This);
737 return IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
740 static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD Value) {
741 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
742 TRACE("(%p) Relay\n" , This);
744 return IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
747 static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD* pValue) {
748 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
749 TRACE("(%p) Relay\n" , This);
751 return IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
754 static HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(LPDIRECT3DDEVICE8 iface) {
755 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
757 TRACE("(%p)\n", This);
759 return IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
762 static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface, DWORD* pToken) {
763 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
765 IWineD3DStateBlock* wineD3DStateBlock;
766 IDirect3DStateBlock8Impl* object;
768 TRACE("(%p) Relay\n", This);
770 /* Tell wineD3D to endstatablock before anything else (in case we run out
771 * of memory later and cause locking problems)
773 hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice , &wineD3DStateBlock);
775 FIXME("IWineD3DDevice_EndStateBlock returned an error\n");
779 /* allocate a new IDirectD3DStateBlock */
780 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY ,sizeof(IDirect3DStateBlock8Impl));
782 object->lpVtbl = &Direct3DStateBlock8_Vtbl;
784 object->wineD3DStateBlock = wineD3DStateBlock;
786 *pToken = (DWORD)object;
787 TRACE("(%p)Returning %p %p\n", This, object, wineD3DStateBlock);
792 static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
793 IDirect3DStateBlock8Impl *pSB = (IDirect3DStateBlock8Impl*) Token;
794 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
796 TRACE("(%p) %p Relay\n", This, pSB);
798 return IWineD3DStateBlock_Apply(pSB->wineD3DStateBlock);
801 static HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
802 IDirect3DStateBlock8Impl* pSB = (IDirect3DStateBlock8Impl *)Token;
803 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
805 TRACE("(%p) %p Relay\n", This, pSB);
807 return IWineD3DStateBlock_Capture(pSB->wineD3DStateBlock);
810 static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
811 IDirect3DStateBlock8Impl* pSB = (IDirect3DStateBlock8Impl *)Token;
812 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
814 TRACE("(%p) Relay\n", This);
816 while(IUnknown_Release((IUnknown *)pSB));
821 static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(LPDIRECT3DDEVICE8 iface, D3DSTATEBLOCKTYPE Type, DWORD* pToken) {
822 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
823 IDirect3DStateBlock8Impl *object;
824 HRESULT hrc = D3D_OK;
826 TRACE("(%p) Relay\n", This);
828 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock8Impl));
829 if (NULL == object) {
831 return E_OUTOFMEMORY;
833 object->lpVtbl = &Direct3DStateBlock8_Vtbl;
836 hrc = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &object->wineD3DStateBlock, (IUnknown *)object);
838 FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This);
839 HeapFree(GetProcessHeap(), 0, object);
842 *pToken = (DWORD)object;
844 TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object);
849 static HRESULT WINAPI IDirect3DDevice8Impl_SetClipStatus(LPDIRECT3DDEVICE8 iface, CONST D3DCLIPSTATUS8* pClipStatus) {
850 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
851 TRACE("(%p) Relay\n" , This);
852 /* FIXME: Verify that D3DCLIPSTATUS8 ~= WINED3DCLIPSTATUS */
853 return IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
856 static HRESULT WINAPI IDirect3DDevice8Impl_GetClipStatus(LPDIRECT3DDEVICE8 iface, D3DCLIPSTATUS8* pClipStatus) {
857 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
858 TRACE("(%p) Relay\n" , This);
860 return IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
863 static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage,IDirect3DBaseTexture8** ppTexture) {
864 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
865 IWineD3DBaseTexture *retTexture = NULL;
868 TRACE("(%p) Relay\n" , This);
870 if(ppTexture == NULL){
871 return D3DERR_INVALIDCALL;
874 rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, (IWineD3DBaseTexture **)&retTexture);
875 if (rc == D3D_OK && NULL != retTexture) {
876 IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
877 IWineD3DBaseTexture_Release(retTexture);
879 FIXME("Call to get texture (%ld) failed (%p)\n", Stage, retTexture);
886 static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage, IDirect3DBaseTexture8* pTexture) {
887 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
888 TRACE("(%p) Relay %ld %p\n" , This, Stage, pTexture);
890 return IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
891 pTexture==NULL ? NULL : ((IDirect3DBaseTexture8Impl *)pTexture)->wineD3DBaseTexture);
894 static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) {
895 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
896 TRACE("(%p) Relay\n" , This);
899 case D3DTSS_ADDRESSU:
900 Type = WINED3DSAMP_ADDRESSU;
902 case D3DTSS_ADDRESSV:
903 Type = WINED3DSAMP_ADDRESSV;
905 case D3DTSS_ADDRESSW:
906 Type = WINED3DSAMP_ADDRESSW;
908 case D3DTSS_BORDERCOLOR:
909 Type = WINED3DSAMP_BORDERCOLOR;
911 case D3DTSS_MAGFILTER:
912 Type = WINED3DSAMP_MAGFILTER;
914 case D3DTSS_MAXANISOTROPY:
915 Type = WINED3DSAMP_MAXANISOTROPY;
917 case D3DTSS_MAXMIPLEVEL:
918 Type = WINED3DSAMP_MAXMIPLEVEL;
920 case D3DTSS_MINFILTER:
921 Type = WINED3DSAMP_MINFILTER;
923 case D3DTSS_MIPFILTER:
924 Type = WINED3DSAMP_MIPFILTER;
926 case D3DTSS_MIPMAPLODBIAS:
927 Type = WINED3DSAMP_MIPMAPLODBIAS;
930 return IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue);
933 return IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, Type, pValue);
936 static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
937 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
938 TRACE("(%p) Relay\n" , This);
941 case D3DTSS_ADDRESSU:
942 Type = WINED3DSAMP_ADDRESSU;
944 case D3DTSS_ADDRESSV:
945 Type = WINED3DSAMP_ADDRESSV;
947 case D3DTSS_ADDRESSW:
948 Type = WINED3DSAMP_ADDRESSW;
950 case D3DTSS_BORDERCOLOR:
951 Type = WINED3DSAMP_BORDERCOLOR;
953 case D3DTSS_MAGFILTER:
954 Type = WINED3DSAMP_MAGFILTER;
956 case D3DTSS_MAXANISOTROPY:
957 Type = WINED3DSAMP_MAXANISOTROPY;
959 case D3DTSS_MAXMIPLEVEL:
960 Type = WINED3DSAMP_MAXMIPLEVEL;
962 case D3DTSS_MINFILTER:
963 Type = WINED3DSAMP_MINFILTER;
965 case D3DTSS_MIPFILTER:
966 Type = WINED3DSAMP_MIPFILTER;
968 case D3DTSS_MIPMAPLODBIAS:
969 Type = WINED3DSAMP_MIPMAPLODBIAS;
972 return IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value);
975 return IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, Type, Value);
978 static HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses) {
979 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
980 TRACE("(%p) Relay\n" , This);
982 return IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
985 static HRESULT WINAPI IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID, void* pDevInfoStruct, DWORD DevInfoStructSize) {
986 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
987 FIXME("(%p) : stub\n", This);
991 static HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
992 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
993 TRACE("(%p) Relay\n" , This);
995 return IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
998 static HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
999 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1000 TRACE("(%p) Relay\n" , This);
1002 return IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
1005 static HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber) {
1006 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1007 TRACE("(%p) Relay\n" , This);
1009 return IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
1012 static HRESULT WINAPI IDirect3DDevice8Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT *PaletteNumber) {
1013 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1014 TRACE("(%p) Relay\n" , This);
1016 return IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
1019 static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
1020 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1021 TRACE("(%p) Relay\n" , This);
1023 return IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex, PrimitiveCount);
1026 static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,
1027 UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) {
1028 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1029 TRACE("(%p) Relay\n" , This);
1031 return IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, This->baseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
1034 static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) {
1035 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1036 TRACE("(%p) Relay\n" , This);
1038 return IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
1041 static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,
1042 UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,
1043 D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,
1044 UINT VertexStreamZeroStride) {
1045 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1046 TRACE("(%p) Relay\n" , This);
1048 return IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertexIndices, PrimitiveCount,
1049 pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
1052 static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 iface, UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) {
1053 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1054 TRACE("(%p) Relay\n" , This);
1056 return IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, ((IDirect3DVertexBuffer8Impl *)pDestBuffer)->wineD3DVertexBuffer, NULL, Flags);
1059 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pDeclaration, CONST DWORD* pFunction, DWORD* ppShader, DWORD Usage) {
1060 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1061 HRESULT hrc = D3D_OK;
1062 IDirect3DVertexShader8Impl *object;
1064 /* Setup a stub object for now */
1065 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1066 TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
1067 if (NULL == object) {
1068 FIXME("Allocation of memory failed\n");
1070 return D3DERR_OUTOFVIDEOMEMORY;
1074 object->lpVtbl = &Direct3DVertexShader8_Vtbl;
1075 /* Usage is missing ..*/
1076 hrc = IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pDeclaration, pFunction, &object->wineD3DVertexShader, (IUnknown *)object);
1079 /* free up object */
1080 FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
1081 HeapFree(GetProcessHeap(), 0, object);
1084 /* TODO: Store the VS declarations locally so that they can be derefferenced with a value higher than VS_HIGHESTFIXEDFXF */
1086 while(This->vShaders[i] != NULL && i < MAX_SHADERS) ++i;
1087 if (MAX_SHADERS == i) {
1088 FIXME("(%p) : Number of shaders exceeds the maximum number of possible shaders\n", This);
1089 hrc = E_OUTOFMEMORY;
1091 This->vShaders[i] = object;
1092 *ppShader = i + VS_HIGHESTFIXEDFXF + 1;
1095 TRACE("(%p) : returning %p\n", This, object);
1100 static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1101 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1102 HRESULT hrc = D3D_OK;
1104 TRACE("(%p) : Relay\n", This);
1105 if (VS_HIGHESTFIXEDFXF >= pShader) {
1106 TRACE("Setting FVF, %d %ld\n", VS_HIGHESTFIXEDFXF, pShader);
1107 IWineD3DDevice_SetFVF(This->WineD3DDevice, pShader);
1109 /* Call SetVertexShader with a NULL shader to set the vertexshader in the stateblock to NULL. */
1110 IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL);
1112 TRACE("Setting shader\n");
1113 if (MAX_SHADERS <= pShader - (VS_HIGHESTFIXEDFXF + 1)) {
1114 FIXME("(%p) : Number of shaders exceeds the maximum number of possible shaders\n", This);
1115 hrc = D3DERR_INVALIDCALL;
1117 IDirect3DVertexShader8Impl *shader = This->vShaders[pShader - (VS_HIGHESTFIXEDFXF + 1)];
1118 hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, 0 == shader ? NULL : shader->wineD3DVertexShader);
1121 TRACE("(%p) : returning hr(%lu)\n", This, hrc);
1126 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
1127 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1128 IWineD3DVertexShader *pShader;
1129 HRESULT hrc = D3D_OK;
1131 TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
1132 hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
1133 if (D3D_OK == hrc) {
1136 hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
1137 IWineD3DVertexShader_Release(pShader);
1138 while(This->vShaders[i] != (IDirect3DVertexShader8Impl *)ppShader && i < MAX_SHADERS) ++i;
1139 if (i < MAX_SHADERS) {
1140 *ppShader = i + VS_HIGHESTFIXEDFXF + 1;
1142 WARN("(%p) : Couldn't find math for shader %p in d3d7 shadres list\n", This, (IDirect3DVertexShader8Impl *)ppShader);
1146 WARN("(%p) : The shader has been set to NULL\n", This);
1148 /* TODO: Find out what should be returned, e.g. the FVF */
1150 hrc = D3DERR_INVALIDCALL;
1153 WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %lu (device %p)\n", This, hrc, This->WineD3DDevice);
1155 TRACE("(%p) : returning %p\n", This, (IDirect3DVertexShader8 *)*ppShader);
1160 static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1161 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1162 HRESULT hrc = D3D_OK;
1163 TRACE("(%p) Relay\n", This);
1164 if (pShader <= VS_HIGHESTFIXEDFXF) {
1165 WARN("(%p) : Caller passed a shader below the value of VS_HIGHESTFIXEDFXF\n", This);
1166 hrc = D3DERR_INVALIDCALL;
1167 } else if (MAX_SHADERS <= pShader - (VS_HIGHESTFIXEDFXF + 1)) {
1168 FIXME("(%p) : Caller passed a shader greater than the maximum number of shaders\n", This);
1169 hrc = D3DERR_INVALIDCALL;
1171 IDirect3DVertexShader8Impl *shader = This->vShaders[pShader - (VS_HIGHESTFIXEDFXF + 1)];
1172 while(IUnknown_Release((IUnknown *)shader));
1173 This->vShaders[pShader - (VS_HIGHESTFIXEDFXF + 1)] = NULL;
1180 static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
1181 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1182 TRACE("(%p) : Relay\n", This);
1184 return IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, (CONST float *)pConstantData, ConstantCount);
1187 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
1188 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1189 TRACE("(%p) : Relay\n", This);
1191 return IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, (float *)pConstantData, ConstantCount);
1194 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
1195 IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)pVertexShader;
1197 TRACE("(%p) : Relay\n", This);
1198 /* return IWineD3DVertexShader_GetDeclaration(This->wineD3DVertexShader, pData, (UINT *)pSizeOfData); */
1199 return D3DERR_INVALIDCALL;
1201 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
1202 IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)pVertexShader;
1204 TRACE("(%p) : Relay\n", This);
1205 return IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, (UINT *)pSizeOfData);
1208 static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData, UINT baseVertexIndex) {
1209 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1210 TRACE("(%p) Relay\n", This);
1211 /* FIXME: store base vertex index properly */
1212 This->baseVertexIndex = baseVertexIndex;
1213 return IWineD3DDevice_SetIndices(This->WineD3DDevice,
1214 NULL == pIndexData ? NULL : ((IDirect3DIndexBuffer8Impl *)pIndexData)->wineD3DIndexBuffer,
1218 static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) {
1219 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1220 IWineD3DIndexBuffer *retIndexData = NULL;
1221 HRESULT rc = D3D_OK;
1224 TRACE("(%p) Relay\n", This);
1226 if(ppIndexData == NULL){
1227 return D3DERR_INVALIDCALL;
1230 rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData, &tmp);
1231 if (D3D_OK == rc && NULL != retIndexData) {
1232 IWineD3DVertexBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
1233 IWineD3DVertexBuffer_Release(retIndexData);
1235 if(rc != D3D_OK) FIXME("Call to GetIndices failed\n");
1236 *ppIndexData = NULL;
1238 /* FIXME: store base vertex index properly */
1239 *pBaseVertexIndex = This->baseVertexIndex;
1242 static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pFunction, DWORD* ppShader) {
1243 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1244 IDirect3DPixelShader8Impl *object;
1245 HRESULT hrc = D3D_OK;
1247 if (NULL == ppShader) {
1248 TRACE("(%p) Invalid call\n", This);
1249 return D3DERR_INVALIDCALL;
1251 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1253 if (NULL == object) {
1254 return E_OUTOFMEMORY;
1258 object->lpVtbl = &Direct3DPixelShader8_Vtbl;
1259 hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, &object->wineD3DPixelShader , (IUnknown *)object);
1260 if (D3D_OK != hrc) {
1261 FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
1262 HeapFree(GetProcessHeap(), 0 , object);
1265 *ppShader = (DWORD)object;
1270 TRACE("(%p) : returning %p\n", This, (void *)*ppShader);
1274 static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1275 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1276 IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)pShader;
1277 TRACE("(%p) Relay\n", This);
1279 return IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
1282 static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
1283 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1284 IWineD3DPixelShader *object;
1286 HRESULT hrc = D3D_OK;
1287 TRACE("(%p) Relay\n", This);
1288 if (NULL == ppShader) {
1289 TRACE("(%p) Invalid call\n", This);
1290 return D3DERR_INVALIDCALL;
1293 hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
1294 if (D3D_OK == hrc && NULL != object) {
1295 hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
1296 IWineD3DPixelShader_Release(object);
1298 *ppShader = (DWORD)NULL;
1301 TRACE("(%p) : returning %p\n", This, (void *)*ppShader);
1305 static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1306 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1307 IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)pShader;
1308 TRACE("(%p) Relay\n", This);
1310 if (NULL != shader) {
1311 while(IUnknown_Release((IUnknown *)shader));
1317 static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
1318 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1319 TRACE("(%p) Relay\n", This);
1321 return IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, (CONST float *)pConstantData, ConstantCount);
1324 static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
1325 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1326 TRACE("(%p) Relay\n", This);
1328 return IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, (float *)pConstantData, ConstantCount);
1331 static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pPixelShader, void* pData, DWORD* pSizeOfData) {
1332 IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)pPixelShader;
1334 TRACE("(%p) : Relay\n", This);
1335 return IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, (UINT *)pSizeOfData);
1338 static HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
1339 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1340 TRACE("(%p) Relay\n", This);
1342 return IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (WINED3DRECTPATCH_INFO *)pRectPatchInfo);
1345 static HRESULT WINAPI IDirect3DDevice8Impl_DrawTriPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
1346 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1347 TRACE("(%p) Relay\n", This);
1349 return IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (WINED3DTRIPATCH_INFO *)pTriPatchInfo);
1352 static HRESULT WINAPI IDirect3DDevice8Impl_DeletePatch(LPDIRECT3DDEVICE8 iface, UINT Handle) {
1353 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1354 TRACE("(%p) Relay\n", This);
1356 return IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
1359 static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) {
1360 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1361 TRACE("(%p) Relay\n" , This);
1363 return IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
1364 NULL == pStreamData ? NULL : ((IDirect3DVertexBuffer8Impl *)pStreamData)->wineD3DVertexBuffer,
1365 0/* Offset in bytes */, Stride);
1368 static HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8** pStream,UINT* pStride) {
1369 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1370 IWineD3DVertexBuffer *retStream = NULL;
1371 HRESULT rc = D3D_OK;
1373 TRACE("(%p) Relay\n" , This);
1375 if(pStream == NULL){
1376 return D3DERR_INVALIDCALL;
1379 rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, (IWineD3DVertexBuffer **)&retStream, 0 /* Offset in bytes */, pStride);
1380 if (rc == D3D_OK && NULL != retStream) {
1381 IWineD3DVertexBuffer_GetParent(retStream, (IUnknown **)pStream);
1382 IWineD3DVertexBuffer_Release(retStream);
1384 FIXME("Call to GetStreamSource failed %p\n", pStride);
1392 const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl =
1394 IDirect3DDevice8Impl_QueryInterface,
1395 IDirect3DDevice8Impl_AddRef,
1396 IDirect3DDevice8Impl_Release,
1397 IDirect3DDevice8Impl_TestCooperativeLevel,
1398 IDirect3DDevice8Impl_GetAvailableTextureMem,
1399 IDirect3DDevice8Impl_ResourceManagerDiscardBytes,
1400 IDirect3DDevice8Impl_GetDirect3D,
1401 IDirect3DDevice8Impl_GetDeviceCaps,
1402 IDirect3DDevice8Impl_GetDisplayMode,
1403 IDirect3DDevice8Impl_GetCreationParameters,
1404 IDirect3DDevice8Impl_SetCursorProperties,
1405 IDirect3DDevice8Impl_SetCursorPosition,
1406 IDirect3DDevice8Impl_ShowCursor,
1407 IDirect3DDevice8Impl_CreateAdditionalSwapChain,
1408 IDirect3DDevice8Impl_Reset,
1409 IDirect3DDevice8Impl_Present,
1410 IDirect3DDevice8Impl_GetBackBuffer,
1411 IDirect3DDevice8Impl_GetRasterStatus,
1412 IDirect3DDevice8Impl_SetGammaRamp,
1413 IDirect3DDevice8Impl_GetGammaRamp,
1414 IDirect3DDevice8Impl_CreateTexture,
1415 IDirect3DDevice8Impl_CreateVolumeTexture,
1416 IDirect3DDevice8Impl_CreateCubeTexture,
1417 IDirect3DDevice8Impl_CreateVertexBuffer,
1418 IDirect3DDevice8Impl_CreateIndexBuffer,
1419 IDirect3DDevice8Impl_CreateRenderTarget,
1420 IDirect3DDevice8Impl_CreateDepthStencilSurface,
1421 IDirect3DDevice8Impl_CreateImageSurface,
1422 IDirect3DDevice8Impl_CopyRects,
1423 IDirect3DDevice8Impl_UpdateTexture,
1424 IDirect3DDevice8Impl_GetFrontBuffer,
1425 IDirect3DDevice8Impl_SetRenderTarget,
1426 IDirect3DDevice8Impl_GetRenderTarget,
1427 IDirect3DDevice8Impl_GetDepthStencilSurface,
1428 IDirect3DDevice8Impl_BeginScene,
1429 IDirect3DDevice8Impl_EndScene,
1430 IDirect3DDevice8Impl_Clear,
1431 IDirect3DDevice8Impl_SetTransform,
1432 IDirect3DDevice8Impl_GetTransform,
1433 IDirect3DDevice8Impl_MultiplyTransform,
1434 IDirect3DDevice8Impl_SetViewport,
1435 IDirect3DDevice8Impl_GetViewport,
1436 IDirect3DDevice8Impl_SetMaterial,
1437 IDirect3DDevice8Impl_GetMaterial,
1438 IDirect3DDevice8Impl_SetLight,
1439 IDirect3DDevice8Impl_GetLight,
1440 IDirect3DDevice8Impl_LightEnable,
1441 IDirect3DDevice8Impl_GetLightEnable,
1442 IDirect3DDevice8Impl_SetClipPlane,
1443 IDirect3DDevice8Impl_GetClipPlane,
1444 IDirect3DDevice8Impl_SetRenderState,
1445 IDirect3DDevice8Impl_GetRenderState,
1446 IDirect3DDevice8Impl_BeginStateBlock,
1447 IDirect3DDevice8Impl_EndStateBlock,
1448 IDirect3DDevice8Impl_ApplyStateBlock,
1449 IDirect3DDevice8Impl_CaptureStateBlock,
1450 IDirect3DDevice8Impl_DeleteStateBlock,
1451 IDirect3DDevice8Impl_CreateStateBlock,
1452 IDirect3DDevice8Impl_SetClipStatus,
1453 IDirect3DDevice8Impl_GetClipStatus,
1454 IDirect3DDevice8Impl_GetTexture,
1455 IDirect3DDevice8Impl_SetTexture,
1456 IDirect3DDevice8Impl_GetTextureStageState,
1457 IDirect3DDevice8Impl_SetTextureStageState,
1458 IDirect3DDevice8Impl_ValidateDevice,
1459 IDirect3DDevice8Impl_GetInfo,
1460 IDirect3DDevice8Impl_SetPaletteEntries,
1461 IDirect3DDevice8Impl_GetPaletteEntries,
1462 IDirect3DDevice8Impl_SetCurrentTexturePalette,
1463 IDirect3DDevice8Impl_GetCurrentTexturePalette,
1464 IDirect3DDevice8Impl_DrawPrimitive,
1465 IDirect3DDevice8Impl_DrawIndexedPrimitive,
1466 IDirect3DDevice8Impl_DrawPrimitiveUP,
1467 IDirect3DDevice8Impl_DrawIndexedPrimitiveUP,
1468 IDirect3DDevice8Impl_ProcessVertices,
1469 IDirect3DDevice8Impl_CreateVertexShader,
1470 IDirect3DDevice8Impl_SetVertexShader,
1471 IDirect3DDevice8Impl_GetVertexShader,
1472 IDirect3DDevice8Impl_DeleteVertexShader,
1473 IDirect3DDevice8Impl_SetVertexShaderConstant,
1474 IDirect3DDevice8Impl_GetVertexShaderConstant,
1475 IDirect3DDevice8Impl_GetVertexShaderDeclaration,
1476 IDirect3DDevice8Impl_GetVertexShaderFunction,
1477 IDirect3DDevice8Impl_SetStreamSource,
1478 IDirect3DDevice8Impl_GetStreamSource,
1479 IDirect3DDevice8Impl_SetIndices,
1480 IDirect3DDevice8Impl_GetIndices,
1481 IDirect3DDevice8Impl_CreatePixelShader,
1482 IDirect3DDevice8Impl_SetPixelShader,
1483 IDirect3DDevice8Impl_GetPixelShader,
1484 IDirect3DDevice8Impl_DeletePixelShader,
1485 IDirect3DDevice8Impl_SetPixelShaderConstant,
1486 IDirect3DDevice8Impl_GetPixelShaderConstant,
1487 IDirect3DDevice8Impl_GetPixelShaderFunction,
1488 IDirect3DDevice8Impl_DrawRectPatch,
1489 IDirect3DDevice8Impl_DrawTriPatch,
1490 IDirect3DDevice8Impl_DeletePatch
1493 /* Internal function called back during the CreateDevice to create a render target */
1494 HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
1495 WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
1496 IWineD3DSurface **ppSurface, HANDLE *pSharedHandle) {
1498 HRESULT res = D3D_OK;
1499 IDirect3DSurface8Impl *d3dSurface = NULL;
1500 BOOL Lockable = TRUE;
1502 if((WINED3DPOOL_DEFAULT == Pool && WINED3DUSAGE_DYNAMIC != Usage))
1506 res = IDirect3DDevice8Impl_CreateSurface((IDirect3DDevice8 *)device, Width, Height, (D3DFORMAT)Format, Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface8 **)&d3dSurface, D3DRTYPE_SURFACE, Usage, Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
1508 if (SUCCEEDED(res)) {
1509 *ppSurface = d3dSurface->wineD3DSurface;
1510 IUnknown_Release(d3dSurface->parentDevice);
1511 d3dSurface->parentDevice = NULL;
1513 FIXME("(%p) IDirect3DDevice8_CreateSurface failed\n", device);