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 *ppSurface = (LPDIRECT3DSURFACE8) object;
522 static HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) {
525 return IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, Lockable, FALSE /* Discard */, 0 /* Level */ , ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, MultiSample, 0);
528 static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
530 /* TODO: Verify that Discard is false */
531 return IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE, 0 /* Level */
532 ,ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_DEPTHSTENCIL,
533 D3DPOOL_DEFAULT, MultiSample, 0);
536 static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
539 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 */);
542 static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8 *pSourceSurface, CONST RECT *pSourceRects, UINT cRects, IDirect3DSurface8 *pDestinationSurface, CONST POINT *pDestPoints) {
543 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
545 TRACE("(%p) Relay\n" , This);
547 return IWineD3DDevice_CopyRects(This->WineD3DDevice, pSourceSurface == NULL ? NULL : ((IDirect3DSurface8Impl *)pSourceSurface)->wineD3DSurface,
548 pSourceRects, cRects, pDestinationSurface == NULL ? NULL : ((IDirect3DSurface8Impl *)pDestinationSurface)->wineD3DSurface, pDestPoints);
551 static HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture, IDirect3DBaseTexture8* pDestinationTexture) {
552 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
553 TRACE("(%p) Relay\n" , This);
555 return IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture8Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture8Impl *)pDestinationTexture)->wineD3DBaseTexture);
558 static HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pDestSurface) {
559 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
560 IDirect3DSurface8Impl *destSurface = (IDirect3DSurface8Impl *)pDestSurface;
562 TRACE("(%p) Relay\n" , This);
564 if (pDestSurface == NULL) {
565 WARN("(%p) : Caller passed NULL as pDestSurface returning D3DERR_INVALIDCALL\n", This);
566 return D3DERR_INVALIDCALL;
569 return IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, 0, destSurface->wineD3DSurface);
572 static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pRenderTarget, IDirect3DSurface8* pNewZStencil) {
573 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
574 IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl *)pRenderTarget;
575 IDirect3DSurface8Impl *pZSurface = (IDirect3DSurface8Impl *)pNewZStencil;
576 TRACE("(%p) Relay\n" , This);
578 IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, NULL == pZSurface ? NULL : (IWineD3DSurface *)pZSurface->wineD3DSurface);
580 return IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, 0, (IWineD3DSurface *)pSurface->wineD3DSurface);
583 static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppRenderTarget) {
584 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
586 IWineD3DSurface *pRenderTarget;
588 TRACE("(%p) Relay\n" , This);
590 if (ppRenderTarget == NULL) {
591 return D3DERR_INVALIDCALL;
593 hr = IWineD3DDevice_GetRenderTarget(This->WineD3DDevice, 0, &pRenderTarget);
595 if (hr == D3D_OK && pRenderTarget != NULL) {
596 IWineD3DResource_GetParent((IWineD3DResource *)pRenderTarget,(IUnknown**)ppRenderTarget);
597 IWineD3DResource_Release((IWineD3DResource *)pRenderTarget);
599 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
600 *ppRenderTarget = NULL;
606 static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppZStencilSurface) {
607 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
609 IWineD3DSurface *pZStencilSurface;
611 TRACE("(%p) Relay\n" , This);
612 if(ppZStencilSurface == NULL){
613 return D3DERR_INVALIDCALL;
616 hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
617 if(hr == D3D_OK && pZStencilSurface != NULL){
618 IWineD3DResource_GetParent((IWineD3DResource *)pZStencilSurface,(IUnknown**)ppZStencilSurface);
619 IWineD3DResource_Release((IWineD3DResource *)pZStencilSurface);
621 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
622 *ppZStencilSurface = NULL;
628 static HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(LPDIRECT3DDEVICE8 iface) {
629 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
630 return IWineD3DDevice_BeginScene(This->WineD3DDevice);
633 static HRESULT WINAPI IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) {
634 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
635 TRACE("(%p) Relay\n" , This);
637 return IWineD3DDevice_EndScene(This->WineD3DDevice);
640 static HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
641 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
642 TRACE("(%p) Relay\n" , This);
644 return IWineD3DDevice_Clear(This->WineD3DDevice, Count, pRects, Flags, Color, Z, Stencil);
647 static HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
648 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
649 TRACE("(%p) Relay\n" , This);
651 return IWineD3DDevice_SetTransform(This->WineD3DDevice, State, lpMatrix);
654 static HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) {
655 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
656 TRACE("(%p) Relay\n" , This);
658 return IWineD3DDevice_GetTransform(This->WineD3DDevice, State, pMatrix);
661 static HRESULT WINAPI IDirect3DDevice8Impl_MultiplyTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
662 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
663 TRACE("(%p) Relay\n" , This);
665 return IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, pMatrix);
668 static HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(LPDIRECT3DDEVICE8 iface, CONST D3DVIEWPORT8* pViewport) {
669 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
670 TRACE("(%p) Relay\n" , This);
672 return IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
675 static HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(LPDIRECT3DDEVICE8 iface, D3DVIEWPORT8* pViewport) {
676 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
677 TRACE("(%p) Relay\n" , This);
679 return IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
682 static HRESULT WINAPI IDirect3DDevice8Impl_SetMaterial(LPDIRECT3DDEVICE8 iface, CONST D3DMATERIAL8* pMaterial) {
683 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
684 TRACE("(%p) Relay\n" , This);
685 /* FIXME: Verify that D3DMATERIAL8 ~= WINED3DMATERIAL */
686 return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
689 static HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(LPDIRECT3DDEVICE8 iface, D3DMATERIAL8* pMaterial) {
690 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
691 TRACE("(%p) Relay\n" , This);
692 /* FIXME: Verify that D3DMATERIAL8 ~= WINED3DMATERIAL */
693 return IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
696 static HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST D3DLIGHT8* pLight) {
697 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
698 TRACE("(%p) Relay\n" , This);
699 /* FIXME: Verify that D3DLIGHT8 ~= WINED3DLIGHT */
700 return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
703 static HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight) {
704 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
705 TRACE("(%p) Relay\n" , This);
706 /* FIXME: Verify that D3DLIGHT8 ~= WINED3DLIGHT */
707 return IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
710 static HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL Enable) {
711 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
712 TRACE("(%p) Relay\n" , This);
714 return IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
717 static HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL* pEnable) {
718 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
719 TRACE("(%p) Relay\n" , This);
721 return IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
724 static HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,CONST float* pPlane) {
725 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
726 TRACE("(%p) Relay\n" , This);
728 return IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
731 static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,float* pPlane) {
732 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
733 TRACE("(%p) Relay\n" , This);
735 return IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
738 static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD Value) {
739 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
740 TRACE("(%p) Relay\n" , This);
742 return IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
745 static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD* pValue) {
746 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
747 TRACE("(%p) Relay\n" , This);
749 return IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
752 static HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(LPDIRECT3DDEVICE8 iface) {
753 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
755 TRACE("(%p)\n", This);
757 return IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
760 static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface, DWORD* pToken) {
761 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
763 IWineD3DStateBlock* wineD3DStateBlock;
764 IDirect3DStateBlock8Impl* object;
766 TRACE("(%p) Relay\n", This);
768 /* Tell wineD3D to endstatablock before anything else (in case we run out
769 * of memory later and cause locking problems)
771 hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice , &wineD3DStateBlock);
773 FIXME("IWineD3DDevice_EndStateBlock returned an error\n");
777 /* allocate a new IDirectD3DStateBlock */
778 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY ,sizeof(IDirect3DStateBlock8Impl));
780 object->lpVtbl = &Direct3DStateBlock8_Vtbl;
782 object->wineD3DStateBlock = wineD3DStateBlock;
784 *pToken = (DWORD)object;
785 TRACE("(%p)Returning %p %p\n", This, object, wineD3DStateBlock);
790 static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
791 IDirect3DStateBlock8Impl *pSB = (IDirect3DStateBlock8Impl*) Token;
792 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
794 TRACE("(%p) %p Relay\n", This, pSB);
796 return IWineD3DStateBlock_Apply(pSB->wineD3DStateBlock);
799 static HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
800 IDirect3DStateBlock8Impl* pSB = (IDirect3DStateBlock8Impl *)Token;
801 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
803 TRACE("(%p) %p Relay\n", This, pSB);
805 return IWineD3DStateBlock_Capture(pSB->wineD3DStateBlock);
808 static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
809 IDirect3DStateBlock8Impl* pSB = (IDirect3DStateBlock8Impl *)Token;
810 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
812 TRACE("(%p) Relay\n", This);
814 while(IUnknown_Release((IUnknown *)pSB));
819 static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(LPDIRECT3DDEVICE8 iface, D3DSTATEBLOCKTYPE Type, DWORD* pToken) {
820 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
821 IDirect3DStateBlock8Impl *object;
822 HRESULT hrc = D3D_OK;
824 TRACE("(%p) Relay\n", This);
826 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock8Impl));
827 if (NULL == object) {
829 return E_OUTOFMEMORY;
831 object->lpVtbl = &Direct3DStateBlock8_Vtbl;
834 hrc = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &object->wineD3DStateBlock, (IUnknown *)object);
836 FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This);
837 HeapFree(GetProcessHeap(), 0, object);
840 *pToken = (DWORD)object;
842 TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object);
847 static HRESULT WINAPI IDirect3DDevice8Impl_SetClipStatus(LPDIRECT3DDEVICE8 iface, CONST D3DCLIPSTATUS8* pClipStatus) {
848 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
849 TRACE("(%p) Relay\n" , This);
850 /* FIXME: Verify that D3DCLIPSTATUS8 ~= WINED3DCLIPSTATUS */
851 return IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
854 static HRESULT WINAPI IDirect3DDevice8Impl_GetClipStatus(LPDIRECT3DDEVICE8 iface, D3DCLIPSTATUS8* pClipStatus) {
855 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
856 TRACE("(%p) Relay\n" , This);
858 return IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
861 static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage,IDirect3DBaseTexture8** ppTexture) {
862 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
863 IWineD3DBaseTexture *retTexture = NULL;
866 TRACE("(%p) Relay\n" , This);
868 if(ppTexture == NULL){
869 return D3DERR_INVALIDCALL;
872 rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, (IWineD3DBaseTexture **)&retTexture);
873 if (rc == D3D_OK && NULL != retTexture) {
874 IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
875 IWineD3DBaseTexture_Release(retTexture);
877 FIXME("Call to get texture (%ld) failed (%p)\n", Stage, retTexture);
884 static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage, IDirect3DBaseTexture8* pTexture) {
885 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
886 TRACE("(%p) Relay %ld %p\n" , This, Stage, pTexture);
888 return IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
889 pTexture==NULL ? NULL : ((IDirect3DBaseTexture8Impl *)pTexture)->wineD3DBaseTexture);
892 static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) {
893 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
894 TRACE("(%p) Relay\n" , This);
897 case D3DTSS_ADDRESSU:
898 Type = WINED3DSAMP_ADDRESSU;
900 case D3DTSS_ADDRESSV:
901 Type = WINED3DSAMP_ADDRESSV;
903 case D3DTSS_ADDRESSW:
904 Type = WINED3DSAMP_ADDRESSW;
906 case D3DTSS_BORDERCOLOR:
907 Type = WINED3DSAMP_BORDERCOLOR;
909 case D3DTSS_MAGFILTER:
910 Type = WINED3DSAMP_MAGFILTER;
912 case D3DTSS_MAXANISOTROPY:
913 Type = WINED3DSAMP_MAXANISOTROPY;
915 case D3DTSS_MAXMIPLEVEL:
916 Type = WINED3DSAMP_MAXMIPLEVEL;
918 case D3DTSS_MINFILTER:
919 Type = WINED3DSAMP_MINFILTER;
921 case D3DTSS_MIPFILTER:
922 Type = WINED3DSAMP_MIPFILTER;
924 case D3DTSS_MIPMAPLODBIAS:
925 Type = WINED3DSAMP_MIPMAPLODBIAS;
928 return IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue);
931 return IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, Type, pValue);
934 static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
935 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
936 TRACE("(%p) Relay\n" , This);
939 case D3DTSS_ADDRESSU:
940 Type = WINED3DSAMP_ADDRESSU;
942 case D3DTSS_ADDRESSV:
943 Type = WINED3DSAMP_ADDRESSV;
945 case D3DTSS_ADDRESSW:
946 Type = WINED3DSAMP_ADDRESSW;
948 case D3DTSS_BORDERCOLOR:
949 Type = WINED3DSAMP_BORDERCOLOR;
951 case D3DTSS_MAGFILTER:
952 Type = WINED3DSAMP_MAGFILTER;
954 case D3DTSS_MAXANISOTROPY:
955 Type = WINED3DSAMP_MAXANISOTROPY;
957 case D3DTSS_MAXMIPLEVEL:
958 Type = WINED3DSAMP_MAXMIPLEVEL;
960 case D3DTSS_MINFILTER:
961 Type = WINED3DSAMP_MINFILTER;
963 case D3DTSS_MIPFILTER:
964 Type = WINED3DSAMP_MIPFILTER;
966 case D3DTSS_MIPMAPLODBIAS:
967 Type = WINED3DSAMP_MIPMAPLODBIAS;
970 return IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value);
973 return IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, Type, Value);
976 static HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses) {
977 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
978 TRACE("(%p) Relay\n" , This);
980 return IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
983 static HRESULT WINAPI IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID, void* pDevInfoStruct, DWORD DevInfoStructSize) {
984 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
985 FIXME("(%p) : stub\n", This);
989 static HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
990 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
991 TRACE("(%p) Relay\n" , This);
993 return IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
996 static HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
997 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
998 TRACE("(%p) Relay\n" , This);
1000 return IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
1003 static HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber) {
1004 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1005 TRACE("(%p) Relay\n" , This);
1007 return IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
1010 static HRESULT WINAPI IDirect3DDevice8Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT *PaletteNumber) {
1011 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1012 TRACE("(%p) Relay\n" , This);
1014 return IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
1017 static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) {
1018 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1019 TRACE("(%p) Relay\n" , This);
1021 return IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex, PrimitiveCount);
1024 static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,
1025 UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) {
1026 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1027 TRACE("(%p) Relay\n" , This);
1029 return IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, This->baseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
1032 static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) {
1033 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1034 TRACE("(%p) Relay\n" , This);
1036 return IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
1039 static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,
1040 UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,
1041 D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,
1042 UINT VertexStreamZeroStride) {
1043 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1044 TRACE("(%p) Relay\n" , This);
1046 return IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertexIndices, PrimitiveCount,
1047 pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
1050 static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 iface, UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) {
1051 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1052 TRACE("(%p) Relay\n" , This);
1054 return IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, ((IDirect3DVertexBuffer8Impl *)pDestBuffer)->wineD3DVertexBuffer, NULL, Flags);
1057 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pDeclaration, CONST DWORD* pFunction, DWORD* ppShader, DWORD Usage) {
1058 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1059 HRESULT hrc = D3D_OK;
1060 IDirect3DVertexShader8Impl *object;
1062 /* Setup a stub object for now */
1063 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1064 TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader);
1065 if (NULL == object) {
1066 FIXME("Allocation of memory failed\n");
1068 return D3DERR_OUTOFVIDEOMEMORY;
1072 object->lpVtbl = &Direct3DVertexShader8_Vtbl;
1073 /* Usage is missing ..*/
1074 hrc = IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pDeclaration, pFunction, &object->wineD3DVertexShader, (IUnknown *)object);
1077 /* free up object */
1078 FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
1079 HeapFree(GetProcessHeap(), 0, object);
1082 /* TODO: Store the VS declarations locally so that they can be derefferenced with a value higher than VS_HIGHESTFIXEDFXF */
1084 while(This->vShaders[i] != NULL && i < MAX_SHADERS) ++i;
1085 if (MAX_SHADERS == i) {
1086 FIXME("(%p) : Number of shaders exceeds the maximum number of possible shaders\n", This);
1087 hrc = E_OUTOFMEMORY;
1089 This->vShaders[i] = object;
1090 *ppShader = i + VS_HIGHESTFIXEDFXF + 1;
1093 TRACE("(%p) : returning %p\n", This, object);
1098 static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1099 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1100 HRESULT hrc = D3D_OK;
1102 TRACE("(%p) : Relay\n", This);
1103 if (VS_HIGHESTFIXEDFXF >= pShader) {
1104 TRACE("Setting FVF, %d %ld\n", VS_HIGHESTFIXEDFXF, pShader);
1105 IWineD3DDevice_SetFVF(This->WineD3DDevice, pShader);
1107 /* Call SetVertexShader with a NULL shader to set the vertexshader in the stateblock to NULL. */
1108 IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL);
1110 TRACE("Setting shader\n");
1111 if (MAX_SHADERS <= pShader - (VS_HIGHESTFIXEDFXF + 1)) {
1112 FIXME("(%p) : Number of shaders exceeds the maximum number of possible shaders\n", This);
1113 hrc = D3DERR_INVALIDCALL;
1115 IDirect3DVertexShader8Impl *shader = This->vShaders[pShader - (VS_HIGHESTFIXEDFXF + 1)];
1116 hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, 0 == shader ? NULL : shader->wineD3DVertexShader);
1119 TRACE("(%p) : returning hr(%lu)\n", This, hrc);
1124 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
1125 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1126 IWineD3DVertexShader *pShader;
1127 HRESULT hrc = D3D_OK;
1129 TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
1130 hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
1131 if (D3D_OK == hrc) {
1134 hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
1135 IWineD3DVertexShader_Release(pShader);
1136 while(This->vShaders[i] != (IDirect3DVertexShader8Impl *)ppShader && i < MAX_SHADERS) ++i;
1137 if (i < MAX_SHADERS) {
1138 *ppShader = i + VS_HIGHESTFIXEDFXF + 1;
1140 WARN("(%p) : Couldn't find math for shader %p in d3d7 shadres list\n", This, (IDirect3DVertexShader8Impl *)ppShader);
1144 WARN("(%p) : The shader has been set to NULL\n", This);
1146 /* TODO: Find out what should be returned, e.g. the FVF */
1148 hrc = D3DERR_INVALIDCALL;
1151 WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %lu (device %p)\n", This, hrc, This->WineD3DDevice);
1153 TRACE("(%p) : returning %p\n", This, (IDirect3DVertexShader8 *)*ppShader);
1158 static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1159 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1160 HRESULT hrc = D3D_OK;
1161 TRACE("(%p) Relay\n", This);
1162 if (pShader <= VS_HIGHESTFIXEDFXF) {
1163 WARN("(%p) : Caller passed a shader below the value of VS_HIGHESTFIXEDFXF\n", This);
1164 hrc = D3DERR_INVALIDCALL;
1165 } else if (MAX_SHADERS <= pShader - (VS_HIGHESTFIXEDFXF + 1)) {
1166 FIXME("(%p) : Caller passed a shader greater than the maximum number of shaders\n", This);
1167 hrc = D3DERR_INVALIDCALL;
1169 IDirect3DVertexShader8Impl *shader = This->vShaders[pShader - (VS_HIGHESTFIXEDFXF + 1)];
1170 while(IUnknown_Release((IUnknown *)shader));
1171 This->vShaders[pShader - (VS_HIGHESTFIXEDFXF + 1)] = NULL;
1178 static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
1179 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1180 TRACE("(%p) : Relay\n", This);
1182 return IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, (CONST float *)pConstantData, ConstantCount);
1185 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
1186 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1187 TRACE("(%p) : Relay\n", This);
1189 return IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, (float *)pConstantData, ConstantCount);
1192 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
1193 IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)pVertexShader;
1195 TRACE("(%p) : Relay\n", This);
1196 /* return IWineD3DVertexShader_GetDeclaration(This->wineD3DVertexShader, pData, (UINT *)pSizeOfData); */
1197 return D3DERR_INVALIDCALL;
1199 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
1200 IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)pVertexShader;
1202 TRACE("(%p) : Relay\n", This);
1203 return IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, (UINT *)pSizeOfData);
1206 static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData, UINT baseVertexIndex) {
1207 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1208 TRACE("(%p) Relay\n", This);
1209 /* FIXME: store base vertex index properly */
1210 This->baseVertexIndex = baseVertexIndex;
1211 return IWineD3DDevice_SetIndices(This->WineD3DDevice,
1212 NULL == pIndexData ? NULL : ((IDirect3DIndexBuffer8Impl *)pIndexData)->wineD3DIndexBuffer,
1216 static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) {
1217 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1218 IWineD3DIndexBuffer *retIndexData = NULL;
1219 HRESULT rc = D3D_OK;
1222 TRACE("(%p) Relay\n", This);
1224 if(ppIndexData == NULL){
1225 return D3DERR_INVALIDCALL;
1228 rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData, &tmp);
1229 if (D3D_OK == rc && NULL != retIndexData) {
1230 IWineD3DVertexBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
1231 IWineD3DVertexBuffer_Release(retIndexData);
1233 if(rc != D3D_OK) FIXME("Call to GetIndices failed\n");
1234 *ppIndexData = NULL;
1236 /* FIXME: store base vertex index properly */
1237 *pBaseVertexIndex = This->baseVertexIndex;
1240 static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pFunction, DWORD* ppShader) {
1241 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1242 IDirect3DPixelShader8Impl *object;
1243 HRESULT hrc = D3D_OK;
1245 if (NULL == ppShader) {
1246 TRACE("(%p) Invalid call\n", This);
1247 return D3DERR_INVALIDCALL;
1249 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1251 if (NULL == object) {
1252 return E_OUTOFMEMORY;
1256 object->lpVtbl = &Direct3DPixelShader8_Vtbl;
1257 hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, &object->wineD3DPixelShader , (IUnknown *)object);
1258 if (D3D_OK != hrc) {
1259 FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
1260 HeapFree(GetProcessHeap(), 0 , object);
1263 *ppShader = (DWORD)object;
1268 TRACE("(%p) : returning %p\n", This, (void *)*ppShader);
1272 static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1273 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1274 IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)pShader;
1275 TRACE("(%p) Relay\n", This);
1277 return IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
1280 static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
1281 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1282 IWineD3DPixelShader *object;
1284 HRESULT hrc = D3D_OK;
1285 TRACE("(%p) Relay\n", This);
1286 if (NULL == ppShader) {
1287 TRACE("(%p) Invalid call\n", This);
1288 return D3DERR_INVALIDCALL;
1291 hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
1292 if (D3D_OK == hrc && NULL != object) {
1293 hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
1294 IWineD3DPixelShader_Release(object);
1296 *ppShader = (DWORD)NULL;
1299 TRACE("(%p) : returning %p\n", This, (void *)*ppShader);
1303 static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1304 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1305 IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)pShader;
1306 TRACE("(%p) Relay\n", This);
1308 if (NULL != shader) {
1309 while(IUnknown_Release((IUnknown *)shader));
1315 static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
1316 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1317 TRACE("(%p) Relay\n", This);
1319 return IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, (CONST float *)pConstantData, ConstantCount);
1322 static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
1323 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1324 TRACE("(%p) Relay\n", This);
1326 return IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, (float *)pConstantData, ConstantCount);
1329 static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pPixelShader, void* pData, DWORD* pSizeOfData) {
1330 IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)pPixelShader;
1332 TRACE("(%p) : Relay\n", This);
1333 return IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, (UINT *)pSizeOfData);
1336 static HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
1337 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1338 TRACE("(%p) Relay\n", This);
1340 return IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (WINED3DRECTPATCH_INFO *)pRectPatchInfo);
1343 static HRESULT WINAPI IDirect3DDevice8Impl_DrawTriPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
1344 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1345 TRACE("(%p) Relay\n", This);
1347 return IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (WINED3DTRIPATCH_INFO *)pTriPatchInfo);
1350 static HRESULT WINAPI IDirect3DDevice8Impl_DeletePatch(LPDIRECT3DDEVICE8 iface, UINT Handle) {
1351 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1352 TRACE("(%p) Relay\n", This);
1354 return IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
1357 static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) {
1358 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1359 TRACE("(%p) Relay\n" , This);
1361 return IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
1362 NULL == pStreamData ? NULL : ((IDirect3DVertexBuffer8Impl *)pStreamData)->wineD3DVertexBuffer,
1363 0/* Offset in bytes */, Stride);
1366 static HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8** pStream,UINT* pStride) {
1367 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1368 IWineD3DVertexBuffer *retStream = NULL;
1369 HRESULT rc = D3D_OK;
1371 TRACE("(%p) Relay\n" , This);
1373 if(pStream == NULL){
1374 return D3DERR_INVALIDCALL;
1377 rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, (IWineD3DVertexBuffer **)&retStream, 0 /* Offset in bytes */, pStride);
1378 if (rc == D3D_OK && NULL != retStream) {
1379 IWineD3DVertexBuffer_GetParent(retStream, (IUnknown **)pStream);
1380 IWineD3DVertexBuffer_Release(retStream);
1382 FIXME("Call to GetStreamSource failed %p\n", pStride);
1390 const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl =
1392 IDirect3DDevice8Impl_QueryInterface,
1393 IDirect3DDevice8Impl_AddRef,
1394 IDirect3DDevice8Impl_Release,
1395 IDirect3DDevice8Impl_TestCooperativeLevel,
1396 IDirect3DDevice8Impl_GetAvailableTextureMem,
1397 IDirect3DDevice8Impl_ResourceManagerDiscardBytes,
1398 IDirect3DDevice8Impl_GetDirect3D,
1399 IDirect3DDevice8Impl_GetDeviceCaps,
1400 IDirect3DDevice8Impl_GetDisplayMode,
1401 IDirect3DDevice8Impl_GetCreationParameters,
1402 IDirect3DDevice8Impl_SetCursorProperties,
1403 IDirect3DDevice8Impl_SetCursorPosition,
1404 IDirect3DDevice8Impl_ShowCursor,
1405 IDirect3DDevice8Impl_CreateAdditionalSwapChain,
1406 IDirect3DDevice8Impl_Reset,
1407 IDirect3DDevice8Impl_Present,
1408 IDirect3DDevice8Impl_GetBackBuffer,
1409 IDirect3DDevice8Impl_GetRasterStatus,
1410 IDirect3DDevice8Impl_SetGammaRamp,
1411 IDirect3DDevice8Impl_GetGammaRamp,
1412 IDirect3DDevice8Impl_CreateTexture,
1413 IDirect3DDevice8Impl_CreateVolumeTexture,
1414 IDirect3DDevice8Impl_CreateCubeTexture,
1415 IDirect3DDevice8Impl_CreateVertexBuffer,
1416 IDirect3DDevice8Impl_CreateIndexBuffer,
1417 IDirect3DDevice8Impl_CreateRenderTarget,
1418 IDirect3DDevice8Impl_CreateDepthStencilSurface,
1419 IDirect3DDevice8Impl_CreateImageSurface,
1420 IDirect3DDevice8Impl_CopyRects,
1421 IDirect3DDevice8Impl_UpdateTexture,
1422 IDirect3DDevice8Impl_GetFrontBuffer,
1423 IDirect3DDevice8Impl_SetRenderTarget,
1424 IDirect3DDevice8Impl_GetRenderTarget,
1425 IDirect3DDevice8Impl_GetDepthStencilSurface,
1426 IDirect3DDevice8Impl_BeginScene,
1427 IDirect3DDevice8Impl_EndScene,
1428 IDirect3DDevice8Impl_Clear,
1429 IDirect3DDevice8Impl_SetTransform,
1430 IDirect3DDevice8Impl_GetTransform,
1431 IDirect3DDevice8Impl_MultiplyTransform,
1432 IDirect3DDevice8Impl_SetViewport,
1433 IDirect3DDevice8Impl_GetViewport,
1434 IDirect3DDevice8Impl_SetMaterial,
1435 IDirect3DDevice8Impl_GetMaterial,
1436 IDirect3DDevice8Impl_SetLight,
1437 IDirect3DDevice8Impl_GetLight,
1438 IDirect3DDevice8Impl_LightEnable,
1439 IDirect3DDevice8Impl_GetLightEnable,
1440 IDirect3DDevice8Impl_SetClipPlane,
1441 IDirect3DDevice8Impl_GetClipPlane,
1442 IDirect3DDevice8Impl_SetRenderState,
1443 IDirect3DDevice8Impl_GetRenderState,
1444 IDirect3DDevice8Impl_BeginStateBlock,
1445 IDirect3DDevice8Impl_EndStateBlock,
1446 IDirect3DDevice8Impl_ApplyStateBlock,
1447 IDirect3DDevice8Impl_CaptureStateBlock,
1448 IDirect3DDevice8Impl_DeleteStateBlock,
1449 IDirect3DDevice8Impl_CreateStateBlock,
1450 IDirect3DDevice8Impl_SetClipStatus,
1451 IDirect3DDevice8Impl_GetClipStatus,
1452 IDirect3DDevice8Impl_GetTexture,
1453 IDirect3DDevice8Impl_SetTexture,
1454 IDirect3DDevice8Impl_GetTextureStageState,
1455 IDirect3DDevice8Impl_SetTextureStageState,
1456 IDirect3DDevice8Impl_ValidateDevice,
1457 IDirect3DDevice8Impl_GetInfo,
1458 IDirect3DDevice8Impl_SetPaletteEntries,
1459 IDirect3DDevice8Impl_GetPaletteEntries,
1460 IDirect3DDevice8Impl_SetCurrentTexturePalette,
1461 IDirect3DDevice8Impl_GetCurrentTexturePalette,
1462 IDirect3DDevice8Impl_DrawPrimitive,
1463 IDirect3DDevice8Impl_DrawIndexedPrimitive,
1464 IDirect3DDevice8Impl_DrawPrimitiveUP,
1465 IDirect3DDevice8Impl_DrawIndexedPrimitiveUP,
1466 IDirect3DDevice8Impl_ProcessVertices,
1467 IDirect3DDevice8Impl_CreateVertexShader,
1468 IDirect3DDevice8Impl_SetVertexShader,
1469 IDirect3DDevice8Impl_GetVertexShader,
1470 IDirect3DDevice8Impl_DeleteVertexShader,
1471 IDirect3DDevice8Impl_SetVertexShaderConstant,
1472 IDirect3DDevice8Impl_GetVertexShaderConstant,
1473 IDirect3DDevice8Impl_GetVertexShaderDeclaration,
1474 IDirect3DDevice8Impl_GetVertexShaderFunction,
1475 IDirect3DDevice8Impl_SetStreamSource,
1476 IDirect3DDevice8Impl_GetStreamSource,
1477 IDirect3DDevice8Impl_SetIndices,
1478 IDirect3DDevice8Impl_GetIndices,
1479 IDirect3DDevice8Impl_CreatePixelShader,
1480 IDirect3DDevice8Impl_SetPixelShader,
1481 IDirect3DDevice8Impl_GetPixelShader,
1482 IDirect3DDevice8Impl_DeletePixelShader,
1483 IDirect3DDevice8Impl_SetPixelShaderConstant,
1484 IDirect3DDevice8Impl_GetPixelShaderConstant,
1485 IDirect3DDevice8Impl_GetPixelShaderFunction,
1486 IDirect3DDevice8Impl_DrawRectPatch,
1487 IDirect3DDevice8Impl_DrawTriPatch,
1488 IDirect3DDevice8Impl_DeletePatch
1491 /* Internal function called back during the CreateDevice to create a render target */
1492 HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
1493 WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
1494 IWineD3DSurface **ppSurface, HANDLE *pSharedHandle) {
1496 HRESULT res = D3D_OK;
1497 IDirect3DSurface8Impl *d3dSurface = NULL;
1498 BOOL Lockable = TRUE;
1500 if((WINED3DPOOL_DEFAULT == Pool && WINED3DUSAGE_DYNAMIC != Usage))
1504 res = IDirect3DDevice8Impl_CreateSurface((IDirect3DDevice8 *)device, Width, Height, (D3DFORMAT)Format, Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface8 **)&d3dSurface, D3DRTYPE_SURFACE, Usage, Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
1506 if (res == D3D_OK) {
1507 *ppSurface = d3dSurface->wineD3DSurface;
1509 FIXME("(%p) IDirect3DDevice8_CreateSurface failed\n", device);