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 D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format)
41 BYTE *c = (BYTE *)&format;
43 /* Don't translate FOURCC formats */
44 if (isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) return format;
48 case WINED3DFMT_UNKNOWN: return D3DFMT_UNKNOWN;
49 case WINED3DFMT_B8G8R8_UNORM: return D3DFMT_R8G8B8;
50 case WINED3DFMT_B8G8R8A8_UNORM: return D3DFMT_A8R8G8B8;
51 case WINED3DFMT_B8G8R8X8_UNORM: return D3DFMT_X8R8G8B8;
52 case WINED3DFMT_B5G6R5_UNORM: return D3DFMT_R5G6B5;
53 case WINED3DFMT_B5G5R5X1_UNORM: return D3DFMT_X1R5G5B5;
54 case WINED3DFMT_B5G5R5A1_UNORM: return D3DFMT_A1R5G5B5;
55 case WINED3DFMT_B4G4R4A4_UNORM: return D3DFMT_A4R4G4B4;
56 case WINED3DFMT_B2G3R3_UNORM: return D3DFMT_R3G3B2;
57 case WINED3DFMT_A8_UNORM: return D3DFMT_A8;
58 case WINED3DFMT_B2G3R3A8_UNORM: return D3DFMT_A8R3G3B2;
59 case WINED3DFMT_B4G4R4X4_UNORM: return D3DFMT_X4R4G4B4;
60 case WINED3DFMT_R10G10B10A2_UNORM: return D3DFMT_A2B10G10R10;
61 case WINED3DFMT_R16G16_UNORM: return D3DFMT_G16R16;
62 case WINED3DFMT_P8_UINT_A8_UNORM: return D3DFMT_A8P8;
63 case WINED3DFMT_P8_UINT: return D3DFMT_P8;
64 case WINED3DFMT_L8_UNORM: return D3DFMT_L8;
65 case WINED3DFMT_L8A8_UNORM: return D3DFMT_A8L8;
66 case WINED3DFMT_L4A4_UNORM: return D3DFMT_A4L4;
67 case WINED3DFMT_R8G8_SNORM: return D3DFMT_V8U8;
68 case WINED3DFMT_R5G5_SNORM_L6_UNORM: return D3DFMT_L6V5U5;
69 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM: return D3DFMT_X8L8V8U8;
70 case WINED3DFMT_R8G8B8A8_SNORM: return D3DFMT_Q8W8V8U8;
71 case WINED3DFMT_R16G16_SNORM: return D3DFMT_V16U16;
72 case WINED3DFMT_R10G11B11_SNORM: return D3DFMT_W11V11U10;
73 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM: return D3DFMT_A2W10V10U10;
74 case WINED3DFMT_D16_LOCKABLE: return D3DFMT_D16_LOCKABLE;
75 case WINED3DFMT_D32_UNORM: return D3DFMT_D32;
76 case WINED3DFMT_S1_UINT_D15_UNORM: return D3DFMT_D15S1;
77 case WINED3DFMT_S8_UINT_D24_UNORM: return D3DFMT_D24S8;
78 case WINED3DFMT_X8D24_UNORM: return D3DFMT_D24X8;
79 case WINED3DFMT_S4X4_UINT_D24_UNORM: return D3DFMT_D24X4S4;
80 case WINED3DFMT_D16_UNORM: return D3DFMT_D16;
81 case WINED3DFMT_VERTEXDATA: return D3DFMT_VERTEXDATA;
82 case WINED3DFMT_R16_UINT: return D3DFMT_INDEX16;
83 case WINED3DFMT_R32_UINT: return D3DFMT_INDEX32;
85 FIXME("Unhandled WINED3DFORMAT %#x\n", format);
86 return D3DFMT_UNKNOWN;
90 WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format)
92 BYTE *c = (BYTE *)&format;
94 /* Don't translate FOURCC formats */
95 if (isprint(c[0]) && isprint(c[1]) && isprint(c[2]) && isprint(c[3])) return format;
99 case D3DFMT_UNKNOWN: return WINED3DFMT_UNKNOWN;
100 case D3DFMT_R8G8B8: return WINED3DFMT_B8G8R8_UNORM;
101 case D3DFMT_A8R8G8B8: return WINED3DFMT_B8G8R8A8_UNORM;
102 case D3DFMT_X8R8G8B8: return WINED3DFMT_B8G8R8X8_UNORM;
103 case D3DFMT_R5G6B5: return WINED3DFMT_B5G6R5_UNORM;
104 case D3DFMT_X1R5G5B5: return WINED3DFMT_B5G5R5X1_UNORM;
105 case D3DFMT_A1R5G5B5: return WINED3DFMT_B5G5R5A1_UNORM;
106 case D3DFMT_A4R4G4B4: return WINED3DFMT_B4G4R4A4_UNORM;
107 case D3DFMT_R3G3B2: return WINED3DFMT_B2G3R3_UNORM;
108 case D3DFMT_A8: return WINED3DFMT_A8_UNORM;
109 case D3DFMT_A8R3G3B2: return WINED3DFMT_B2G3R3A8_UNORM;
110 case D3DFMT_X4R4G4B4: return WINED3DFMT_B4G4R4X4_UNORM;
111 case D3DFMT_A2B10G10R10: return WINED3DFMT_R10G10B10A2_UNORM;
112 case D3DFMT_G16R16: return WINED3DFMT_R16G16_UNORM;
113 case D3DFMT_A8P8: return WINED3DFMT_P8_UINT_A8_UNORM;
114 case D3DFMT_P8: return WINED3DFMT_P8_UINT;
115 case D3DFMT_L8: return WINED3DFMT_L8_UNORM;
116 case D3DFMT_A8L8: return WINED3DFMT_L8A8_UNORM;
117 case D3DFMT_A4L4: return WINED3DFMT_L4A4_UNORM;
118 case D3DFMT_V8U8: return WINED3DFMT_R8G8_SNORM;
119 case D3DFMT_L6V5U5: return WINED3DFMT_R5G5_SNORM_L6_UNORM;
120 case D3DFMT_X8L8V8U8: return WINED3DFMT_R8G8_SNORM_L8X8_UNORM;
121 case D3DFMT_Q8W8V8U8: return WINED3DFMT_R8G8B8A8_SNORM;
122 case D3DFMT_V16U16: return WINED3DFMT_R16G16_SNORM;
123 case D3DFMT_W11V11U10: return WINED3DFMT_R10G11B11_SNORM;
124 case D3DFMT_A2W10V10U10: return WINED3DFMT_R10G10B10_SNORM_A2_UNORM;
125 case D3DFMT_D16_LOCKABLE: return WINED3DFMT_D16_LOCKABLE;
126 case D3DFMT_D32: return WINED3DFMT_D32_UNORM;
127 case D3DFMT_D15S1: return WINED3DFMT_S1_UINT_D15_UNORM;
128 case D3DFMT_D24S8: return WINED3DFMT_S8_UINT_D24_UNORM;
129 case D3DFMT_D24X8: return WINED3DFMT_X8D24_UNORM;
130 case D3DFMT_D24X4S4: return WINED3DFMT_S4X4_UINT_D24_UNORM;
131 case D3DFMT_D16: return WINED3DFMT_D16_UNORM;
132 case D3DFMT_VERTEXDATA: return WINED3DFMT_VERTEXDATA;
133 case D3DFMT_INDEX16: return WINED3DFMT_R16_UINT;
134 case D3DFMT_INDEX32: return WINED3DFMT_R32_UINT;
136 FIXME("Unhandled D3DFORMAT %#x\n", format);
137 return WINED3DFMT_UNKNOWN;
141 static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT primitive_count)
143 switch(primitive_type)
145 case D3DPT_POINTLIST:
146 return primitive_count;
149 return primitive_count * 2;
151 case D3DPT_LINESTRIP:
152 return primitive_count + 1;
154 case D3DPT_TRIANGLELIST:
155 return primitive_count * 3;
157 case D3DPT_TRIANGLESTRIP:
158 case D3DPT_TRIANGLEFAN:
159 return primitive_count + 2;
162 FIXME("Unhandled primitive type %#x\n", primitive_type);
167 /* Handle table functions */
168 static DWORD d3d8_allocate_handle(struct d3d8_handle_table *t, void *object, enum d3d8_handle_type type)
170 struct d3d8_handle_entry *entry;
174 /* Use a free handle */
175 entry = t->free_entries;
176 if (entry->type != D3D8_HANDLE_FREE)
178 ERR("Handle %u(%p) is in the free list, but has type %#x.\n", (entry - t->entries), entry, entry->type);
179 return D3D8_INVALID_HANDLE;
181 t->free_entries = entry->object;
182 entry->object = object;
185 return entry - t->entries;
188 if (!(t->entry_count < t->table_size))
191 UINT new_size = t->table_size + (t->table_size >> 1);
192 struct d3d8_handle_entry *new_entries = HeapReAlloc(GetProcessHeap(),
193 0, t->entries, new_size * sizeof(*t->entries));
196 ERR("Failed to grow the handle table.\n");
197 return D3D8_INVALID_HANDLE;
199 t->entries = new_entries;
200 t->table_size = new_size;
203 entry = &t->entries[t->entry_count];
204 entry->object = object;
207 return t->entry_count++;
210 static void *d3d8_free_handle(struct d3d8_handle_table *t, DWORD handle, enum d3d8_handle_type type)
212 struct d3d8_handle_entry *entry;
215 if (handle == D3D8_INVALID_HANDLE || handle >= t->entry_count)
217 WARN("Invalid handle %u passed.\n", handle);
221 entry = &t->entries[handle];
222 if (entry->type != type)
224 WARN("Handle %u(%p) is not of type %#x.\n", handle, entry, type);
228 object = entry->object;
229 entry->object = t->free_entries;
230 entry->type = D3D8_HANDLE_FREE;
231 t->free_entries = entry;
236 static void *d3d8_get_object(struct d3d8_handle_table *t, DWORD handle, enum d3d8_handle_type type)
238 struct d3d8_handle_entry *entry;
240 if (handle == D3D8_INVALID_HANDLE || handle >= t->entry_count)
242 WARN("Invalid handle %u passed.\n", handle);
246 entry = &t->entries[handle];
247 if (entry->type != type)
249 WARN("Handle %u(%p) is not of type %#x.\n", handle, entry, type);
253 return entry->object;
256 /* IDirect3D IUnknown parts follow: */
257 static HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID riid,LPVOID *ppobj)
259 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
261 if (IsEqualGUID(riid, &IID_IUnknown)
262 || IsEqualGUID(riid, &IID_IDirect3DDevice8)) {
263 IUnknown_AddRef(iface);
268 if (IsEqualGUID(riid, &IID_IWineD3DDeviceParent))
270 IUnknown_AddRef((IUnknown *)&This->device_parent_vtbl);
271 *ppobj = &This->device_parent_vtbl;
275 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
277 return E_NOINTERFACE;
280 static ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface) {
281 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
282 ULONG ref = InterlockedIncrement(&This->ref);
284 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
289 static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
290 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
293 if (This->inDestruction) return 0;
294 ref = InterlockedDecrement(&This->ref);
296 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
301 TRACE("Releasing wined3d device %p\n", This->WineD3DDevice);
303 wined3d_mutex_lock();
305 This->inDestruction = TRUE;
307 for(i = 0; i < This->numConvertedDecls; i++) {
308 IDirect3DVertexDeclaration8_Release(This->decls[i].decl);
310 HeapFree(GetProcessHeap(), 0, This->decls);
312 IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_DestroySwapChain);
313 IWineD3DDevice_Release(This->WineD3DDevice);
314 HeapFree(GetProcessHeap(), 0, This->handle_table.entries);
315 HeapFree(GetProcessHeap(), 0, This);
317 wined3d_mutex_unlock();
322 /* IDirect3DDevice Interface follow: */
323 static HRESULT WINAPI IDirect3DDevice8Impl_TestCooperativeLevel(LPDIRECT3DDEVICE8 iface) {
324 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
327 TRACE("(%p) : Relay\n", This);
329 wined3d_mutex_lock();
330 hr = IWineD3DDevice_TestCooperativeLevel(This->WineD3DDevice);
331 wined3d_mutex_unlock();
336 static UINT WINAPI IDirect3DDevice8Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE8 iface) {
337 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
340 TRACE("(%p) Relay\n", This);
342 wined3d_mutex_lock();
343 hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
344 wined3d_mutex_unlock();
349 static HRESULT WINAPI IDirect3DDevice8Impl_ResourceManagerDiscardBytes(LPDIRECT3DDEVICE8 iface, DWORD Bytes) {
350 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
353 TRACE("(%p) : Relay bytes(%d)\n", This, Bytes);
355 wined3d_mutex_lock();
356 hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
357 wined3d_mutex_unlock();
362 static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(LPDIRECT3DDEVICE8 iface, IDirect3D8** ppD3D8) {
363 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
367 TRACE("(%p) Relay\n", This);
369 if (NULL == ppD3D8) {
370 return D3DERR_INVALIDCALL;
373 wined3d_mutex_lock();
374 hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
375 if (hr == D3D_OK && pWineD3D != NULL)
377 IWineD3D_GetParent(pWineD3D,(IUnknown **)ppD3D8);
378 IWineD3D_Release(pWineD3D);
380 FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
383 wined3d_mutex_unlock();
385 TRACE("(%p) returning %p\n",This , *ppD3D8);
390 static HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 iface, D3DCAPS8* pCaps) {
391 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
392 HRESULT hrc = D3D_OK;
393 WINED3DCAPS *pWineCaps;
395 TRACE("(%p) : Relay pCaps %p\n", This, pCaps);
397 return D3DERR_INVALIDCALL;
399 pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
400 if(pWineCaps == NULL){
401 return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
404 wined3d_mutex_lock();
405 hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
406 wined3d_mutex_unlock();
408 fixup_caps(pWineCaps);
409 WINECAPSTOD3D8CAPS(pCaps, pWineCaps)
410 HeapFree(GetProcessHeap(), 0, pWineCaps);
412 TRACE("Returning %p %p\n", This, pCaps);
416 static HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(LPDIRECT3DDEVICE8 iface, D3DDISPLAYMODE* pMode) {
417 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
419 TRACE("(%p) Relay\n", This);
421 wined3d_mutex_lock();
422 hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, 0, (WINED3DDISPLAYMODE *) pMode);
423 wined3d_mutex_unlock();
425 if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
430 static HRESULT WINAPI IDirect3DDevice8Impl_GetCreationParameters(LPDIRECT3DDEVICE8 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
431 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
433 TRACE("(%p) Relay\n", This);
435 wined3d_mutex_lock();
436 hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
437 wined3d_mutex_unlock();
442 static HRESULT WINAPI IDirect3DDevice8Impl_SetCursorProperties(LPDIRECT3DDEVICE8 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface8* pCursorBitmap) {
443 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
444 IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl*)pCursorBitmap;
446 TRACE("(%p) Relay\n", This);
448 WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
449 return WINED3DERR_INVALIDCALL;
452 wined3d_mutex_lock();
453 hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice,XHotSpot,YHotSpot,pSurface->wineD3DSurface);
454 wined3d_mutex_unlock();
459 static void WINAPI IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace, DWORD Flags) {
460 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
461 TRACE("(%p) Relay\n", This);
463 wined3d_mutex_lock();
464 IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
465 wined3d_mutex_unlock();
468 static BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL bShow) {
469 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
471 TRACE("(%p) Relay\n", This);
473 wined3d_mutex_lock();
474 ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
475 wined3d_mutex_unlock();
480 static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain8** pSwapChain) {
481 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
482 IDirect3DSwapChain8Impl* object;
483 HRESULT hrc = D3D_OK;
484 WINED3DPRESENT_PARAMETERS localParameters;
486 TRACE("(%p) Relay\n", This);
488 /* Fix the back buffer count */
489 if(pPresentationParameters->BackBufferCount == 0) {
490 pPresentationParameters->BackBufferCount = 1;
493 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
494 if (NULL == object) {
495 FIXME("Allocation of memory failed\n");
497 return D3DERR_OUTOFVIDEOMEMORY;
500 object->lpVtbl = &Direct3DSwapChain8_Vtbl;
502 /* Allocate an associated WineD3DDevice object */
503 localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
504 localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
505 localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
506 localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
507 localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
508 localParameters.MultiSampleQuality = 0; /* d3d9 only */
509 localParameters.SwapEffect = pPresentationParameters->SwapEffect;
510 localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
511 localParameters.Windowed = pPresentationParameters->Windowed;
512 localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
513 localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
514 localParameters.Flags = pPresentationParameters->Flags;
515 localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
516 localParameters.PresentationInterval = pPresentationParameters->FullScreen_PresentationInterval;
517 localParameters.AutoRestoreDisplayMode = TRUE;
519 wined3d_mutex_lock();
520 hrc = IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, &localParameters,
521 &object->wineD3DSwapChain, (IUnknown *)object, SURFACE_OPENGL);
522 wined3d_mutex_unlock();
524 pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
525 pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
526 pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
527 pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
528 pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
529 pPresentationParameters->SwapEffect = localParameters.SwapEffect;
530 pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
531 pPresentationParameters->Windowed = localParameters.Windowed;
532 pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
533 pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
534 pPresentationParameters->Flags = localParameters.Flags;
535 pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
536 pPresentationParameters->FullScreen_PresentationInterval = localParameters.PresentationInterval;
539 FIXME("(%p) call to IWineD3DDevice_CreateSwapChain failed\n", This);
540 HeapFree(GetProcessHeap(), 0 , object);
543 IUnknown_AddRef(iface);
544 object->parentDevice = iface;
545 *pSwapChain = (IDirect3DSwapChain8 *)object;
547 TRACE("(%p) returning %p\n", This, *pSwapChain);
551 static HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
552 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
553 WINED3DPRESENT_PARAMETERS localParameters;
556 TRACE("(%p) Relay pPresentationParameters(%p)\n", This, pPresentationParameters);
558 localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
559 localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
560 localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
561 localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
562 localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
563 localParameters.MultiSampleQuality = 0; /* d3d9 only */
564 localParameters.SwapEffect = pPresentationParameters->SwapEffect;
565 localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
566 localParameters.Windowed = pPresentationParameters->Windowed;
567 localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
568 localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
569 localParameters.Flags = pPresentationParameters->Flags;
570 localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
571 localParameters.PresentationInterval = pPresentationParameters->FullScreen_PresentationInterval;
572 localParameters.AutoRestoreDisplayMode = TRUE;
574 wined3d_mutex_lock();
575 hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
576 wined3d_mutex_unlock();
578 pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
579 pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
580 pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
581 pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
582 pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
583 pPresentationParameters->SwapEffect = localParameters.SwapEffect;
584 pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
585 pPresentationParameters->Windowed = localParameters.Windowed;
586 pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
587 pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
588 pPresentationParameters->Flags = localParameters.Flags;
589 pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
590 pPresentationParameters->FullScreen_PresentationInterval = localParameters.PresentationInterval;
595 static HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
596 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
598 TRACE("(%p) Relay\n", This);
600 wined3d_mutex_lock();
601 hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
602 wined3d_mutex_unlock();
607 static HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) {
608 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
609 IWineD3DSurface *retSurface = NULL;
612 TRACE("(%p) Relay\n", This);
614 wined3d_mutex_lock();
615 rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, 0, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
616 if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
617 IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
618 IWineD3DSurface_Release(retSurface);
620 wined3d_mutex_unlock();
625 static HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(LPDIRECT3DDEVICE8 iface, D3DRASTER_STATUS* pRasterStatus) {
626 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
628 TRACE("(%p) Relay\n", This);
630 wined3d_mutex_lock();
631 hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, 0, (WINED3DRASTER_STATUS *) pRasterStatus);
632 wined3d_mutex_unlock();
637 static void WINAPI IDirect3DDevice8Impl_SetGammaRamp(LPDIRECT3DDEVICE8 iface, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
638 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
639 TRACE("(%p) Relay\n", This);
641 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
642 wined3d_mutex_lock();
643 IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, 0, Flags, (CONST WINED3DGAMMARAMP *) pRamp);
644 wined3d_mutex_unlock();
647 static void WINAPI IDirect3DDevice8Impl_GetGammaRamp(LPDIRECT3DDEVICE8 iface, D3DGAMMARAMP* pRamp) {
648 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
649 TRACE("(%p) Relay\n", This);
651 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
652 wined3d_mutex_lock();
653 IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, 0, (WINED3DGAMMARAMP *) pRamp);
654 wined3d_mutex_unlock();
657 static HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(IDirect3DDevice8 *iface,
658 UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format,
659 D3DPOOL pool, IDirect3DTexture8 **texture)
661 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
662 IDirect3DTexture8Impl *object;
665 TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
666 iface, width, height, levels, usage, format, pool, texture);
668 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
671 ERR("Failed to allocate texture memory.\n");
672 return D3DERR_OUTOFVIDEOMEMORY;
675 hr = texture_init(object, This, width, height, levels, usage, format, pool);
678 WARN("Failed to initialize texture, hr %#x.\n", hr);
679 HeapFree(GetProcessHeap(), 0, object);
683 TRACE("Created texture %p.\n", object);
684 *texture = (IDirect3DTexture8 *)object;
689 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(IDirect3DDevice8 *iface,
690 UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format,
691 D3DPOOL pool, IDirect3DVolumeTexture8 **texture)
693 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
694 IDirect3DVolumeTexture8Impl *object;
697 TRACE("iface %p, width %u, height %u, depth %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
698 iface, width, height, depth, levels, usage, format, pool, texture);
700 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
703 ERR("Failed to allocate volume texture memory.\n");
704 return D3DERR_OUTOFVIDEOMEMORY;
707 hr = volumetexture_init(object, This, width, height, depth, levels, usage, format, pool);
710 WARN("Failed to initialize volume texture, hr %#x.\n", hr);
711 HeapFree(GetProcessHeap(), 0, object);
715 TRACE("Created volume texture %p.\n", object);
716 *texture = (IDirect3DVolumeTexture8 *)object;
721 static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT edge_length,
722 UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, IDirect3DCubeTexture8 **texture)
724 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
725 IDirect3DCubeTexture8Impl *object;
728 TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
729 iface, edge_length, levels, usage, format, pool, texture);
731 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
734 ERR("Failed to allocate cube texture memory.\n");
735 return D3DERR_OUTOFVIDEOMEMORY;
738 hr = cubetexture_init(object, This, edge_length, levels, usage, format, pool);
741 WARN("Failed to initialize cube texture, hr %#x.\n", hr);
742 HeapFree(GetProcessHeap(), 0, object);
746 TRACE("Created cube texture %p.\n", object);
747 *texture = (IDirect3DCubeTexture8 *)object;
752 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(IDirect3DDevice8 *iface, UINT size, DWORD usage,
753 DWORD fvf, D3DPOOL pool, IDirect3DVertexBuffer8 **buffer)
755 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
756 IDirect3DVertexBuffer8Impl *object;
759 TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p.\n",
760 iface, size, usage, fvf, pool, buffer);
762 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
765 ERR("Failed to allocate buffer memory.\n");
766 return D3DERR_OUTOFVIDEOMEMORY;
769 hr = vertexbuffer_init(object, This, size, usage, fvf, pool);
772 WARN("Failed to initialize vertex buffer, hr %#x.\n", hr);
773 HeapFree(GetProcessHeap(), 0, object);
777 TRACE("Created vertex buffer %p.\n", object);
778 *buffer = (IDirect3DVertexBuffer8 *)object;
783 static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(IDirect3DDevice8 *iface, UINT size, DWORD usage,
784 D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer8 **buffer)
786 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
787 IDirect3DIndexBuffer8Impl *object;
790 TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p.\n",
791 iface, size, usage, format, pool, buffer);
793 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
796 ERR("Failed to allocate buffer memory.\n");
797 return D3DERR_OUTOFVIDEOMEMORY;
800 hr = indexbuffer_init(object, This, size, usage, format, pool);
803 WARN("Failed to initialize index buffer, hr %#x.\n", hr);
804 HeapFree(GetProcessHeap(), 0, object);
808 TRACE("Created index buffer %p.\n", object);
809 *buffer = (IDirect3DIndexBuffer8 *)object;
814 static HRESULT IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height,
815 D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface8 **ppSurface,
816 UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)
818 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
819 IDirect3DSurface8Impl *object;
822 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
824 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
827 FIXME("Failed to allocate surface memory.\n");
828 return D3DERR_OUTOFVIDEOMEMORY;
831 hr = surface_init(object, This, Width, Height, Format, Lockable, Discard,
832 Level, Usage, Pool, MultiSample, MultisampleQuality);
835 WARN("Failed to initialize surface, hr %#x.\n", hr);
836 HeapFree(GetProcessHeap(), 0, object);
840 TRACE("Created surface %p.\n", object);
841 *ppSurface = (IDirect3DSurface8 *)object;
846 static HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) {
850 hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, Lockable, FALSE /* Discard */,
851 0 /* Level */, ppSurface, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, MultiSample, 0);
856 static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
860 /* TODO: Verify that Discard is false */
861 hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE,
862 0 /* Level */, ppSurface, D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, MultiSample, 0);
867 /* IDirect3DDevice8Impl::CreateImageSurface returns surface with pool type SYSTEMMEM */
868 static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
872 hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE /* Discard */,
873 0 /* Level */, ppSurface, 0 /* Usage (undefined/none) */, D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE,
874 0 /* MultisampleQuality */);
879 static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8 *pSourceSurface, CONST RECT *pSourceRects, UINT cRects, IDirect3DSurface8 *pDestinationSurface, CONST POINT *pDestPoints) {
880 IDirect3DSurface8Impl *Source = (IDirect3DSurface8Impl *) pSourceSurface;
881 IDirect3DSurface8Impl *Dest = (IDirect3DSurface8Impl *) pDestinationSurface;
883 HRESULT hr = WINED3D_OK;
884 WINED3DFORMAT srcFormat, destFormat;
885 WINED3DSURFACE_DESC winedesc;
887 TRACE("(%p) pSrcSur=%p, pSourceRects=%p, cRects=%d, pDstSur=%p, pDestPtsArr=%p\n", iface,
888 pSourceSurface, pSourceRects, cRects, pDestinationSurface, pDestPoints);
891 /* Check that the source texture is in WINED3DPOOL_SYSTEMMEM and the destination texture is in WINED3DPOOL_DEFAULT */
893 wined3d_mutex_lock();
894 IWineD3DSurface_GetDesc(Source->wineD3DSurface, &winedesc);
895 srcFormat = winedesc.format;
897 IWineD3DSurface_GetDesc(Dest->wineD3DSurface, &winedesc);
898 destFormat = winedesc.format;
900 /* Check that the source and destination formats match */
901 if (srcFormat != destFormat && WINED3DFMT_UNKNOWN != destFormat) {
902 WARN("(%p) source %p format must match the dest %p format, returning WINED3DERR_INVALIDCALL\n", iface, pSourceSurface, pDestinationSurface);
903 wined3d_mutex_unlock();
904 return WINED3DERR_INVALIDCALL;
905 } else if (WINED3DFMT_UNKNOWN == destFormat) {
906 TRACE("(%p) : Converting destination surface from WINED3DFMT_UNKNOWN to the source format\n", iface);
907 IWineD3DSurface_SetFormat(Dest->wineD3DSurface, srcFormat);
910 /* Quick if complete copy ... */
911 if (cRects == 0 && pSourceRects == NULL && pDestPoints == NULL) {
912 IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, NULL, WINEDDBLTFAST_NOCOLORKEY);
915 /* Copy rect by rect */
916 if (NULL != pSourceRects && NULL != pDestPoints) {
917 for (i = 0; i < cRects; ++i) {
918 IWineD3DSurface_BltFast(Dest->wineD3DSurface, pDestPoints[i].x, pDestPoints[i].y, Source->wineD3DSurface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
921 for (i = 0; i < cRects; ++i) {
922 IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
926 wined3d_mutex_unlock();
931 static HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture, IDirect3DBaseTexture8* pDestinationTexture) {
932 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
934 TRACE("(%p) Relay\n" , This);
936 wined3d_mutex_lock();
937 hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture8Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture8Impl *)pDestinationTexture)->wineD3DBaseTexture);
938 wined3d_mutex_unlock();
943 static HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pDestSurface) {
944 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
945 IDirect3DSurface8Impl *destSurface = (IDirect3DSurface8Impl *)pDestSurface;
948 TRACE("(%p) Relay\n" , This);
950 if (pDestSurface == NULL) {
951 WARN("(%p) : Caller passed NULL as pDestSurface returning D3DERR_INVALIDCALL\n", This);
952 return D3DERR_INVALIDCALL;
955 wined3d_mutex_lock();
956 hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, 0, destSurface->wineD3DSurface);
957 wined3d_mutex_unlock();
962 static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pRenderTarget, IDirect3DSurface8* pNewZStencil) {
963 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
964 IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl *)pRenderTarget;
965 IDirect3DSurface8Impl *pZSurface = (IDirect3DSurface8Impl *)pNewZStencil;
966 IWineD3DSurface *original_ds = NULL;
968 TRACE("(%p) Relay\n" , This);
970 wined3d_mutex_lock();
972 hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice, &original_ds);
973 if (hr == WINED3D_OK || hr == WINED3DERR_NOTFOUND)
975 hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, pZSurface ? pZSurface->wineD3DSurface : NULL);
976 if (SUCCEEDED(hr) && pSurface)
977 hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, 0, pSurface->wineD3DSurface);
978 if (FAILED(hr)) IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, original_ds);
980 if (original_ds) IWineD3DSurface_Release(original_ds);
982 wined3d_mutex_unlock();
987 static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppRenderTarget) {
988 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
990 IWineD3DSurface *pRenderTarget;
992 TRACE("(%p) Relay\n" , This);
994 if (ppRenderTarget == NULL) {
995 return D3DERR_INVALIDCALL;
998 wined3d_mutex_lock();
999 hr = IWineD3DDevice_GetRenderTarget(This->WineD3DDevice, 0, &pRenderTarget);
1001 if (hr == D3D_OK && pRenderTarget != NULL) {
1002 IWineD3DSurface_GetParent(pRenderTarget,(IUnknown**)ppRenderTarget);
1003 IWineD3DSurface_Release(pRenderTarget);
1005 FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
1006 *ppRenderTarget = NULL;
1008 wined3d_mutex_unlock();
1013 static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppZStencilSurface) {
1014 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1015 HRESULT hr = D3D_OK;
1016 IWineD3DSurface *pZStencilSurface;
1018 TRACE("(%p) Relay\n" , This);
1019 if(ppZStencilSurface == NULL){
1020 return D3DERR_INVALIDCALL;
1023 wined3d_mutex_lock();
1024 hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
1025 if (hr == WINED3D_OK) {
1026 IWineD3DSurface_GetParent(pZStencilSurface,(IUnknown**)ppZStencilSurface);
1027 IWineD3DSurface_Release(pZStencilSurface);
1029 if (hr != WINED3DERR_NOTFOUND)
1030 FIXME("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr);
1031 *ppZStencilSurface = NULL;
1033 wined3d_mutex_unlock();
1038 static HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(LPDIRECT3DDEVICE8 iface) {
1039 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1041 TRACE("(%p) Relay\n" , This);
1043 wined3d_mutex_lock();
1044 hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
1045 wined3d_mutex_unlock();
1050 static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) {
1051 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1053 TRACE("(%p) Relay\n" , This);
1055 wined3d_mutex_lock();
1056 hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
1057 wined3d_mutex_unlock();
1062 static HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
1063 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1065 TRACE("(%p) Relay\n" , This);
1067 /* Note: D3DRECT is compatible with WINED3DRECT */
1068 wined3d_mutex_lock();
1069 hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
1070 wined3d_mutex_unlock();
1075 static HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
1076 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1078 TRACE("(%p) Relay\n" , This);
1080 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
1081 wined3d_mutex_lock();
1082 hr = IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
1083 wined3d_mutex_unlock();
1088 static HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) {
1089 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1091 TRACE("(%p) Relay\n" , This);
1093 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
1094 wined3d_mutex_lock();
1095 hr = IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
1096 wined3d_mutex_unlock();
1101 static HRESULT WINAPI IDirect3DDevice8Impl_MultiplyTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
1102 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1104 TRACE("(%p) Relay\n" , This);
1106 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
1107 wined3d_mutex_lock();
1108 hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
1109 wined3d_mutex_unlock();
1114 static HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(LPDIRECT3DDEVICE8 iface, CONST D3DVIEWPORT8* pViewport) {
1115 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1117 TRACE("(%p) Relay\n" , This);
1119 /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
1120 wined3d_mutex_lock();
1121 hr = IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
1122 wined3d_mutex_unlock();
1127 static HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(LPDIRECT3DDEVICE8 iface, D3DVIEWPORT8* pViewport) {
1128 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1130 TRACE("(%p) Relay\n" , This);
1132 /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
1133 wined3d_mutex_lock();
1134 hr = IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
1135 wined3d_mutex_unlock();
1140 static HRESULT WINAPI IDirect3DDevice8Impl_SetMaterial(LPDIRECT3DDEVICE8 iface, CONST D3DMATERIAL8* pMaterial) {
1141 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1143 TRACE("(%p) Relay\n" , This);
1145 /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */
1146 wined3d_mutex_lock();
1147 hr = IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
1148 wined3d_mutex_unlock();
1153 static HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(LPDIRECT3DDEVICE8 iface, D3DMATERIAL8* pMaterial) {
1154 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1156 TRACE("(%p) Relay\n" , This);
1158 /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */
1159 wined3d_mutex_lock();
1160 hr = IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
1161 wined3d_mutex_unlock();
1166 static HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST D3DLIGHT8* pLight) {
1167 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1169 TRACE("(%p) Relay\n" , This);
1171 /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
1172 wined3d_mutex_lock();
1173 hr = IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
1174 wined3d_mutex_unlock();
1179 static HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight) {
1180 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1182 TRACE("(%p) Relay\n" , This);
1184 /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
1185 wined3d_mutex_lock();
1186 hr = IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
1187 wined3d_mutex_unlock();
1192 static HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL Enable) {
1193 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1195 TRACE("(%p) Relay\n" , This);
1197 wined3d_mutex_lock();
1198 hr = IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
1199 wined3d_mutex_unlock();
1204 static HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL* pEnable) {
1205 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1207 TRACE("(%p) Relay\n" , This);
1209 wined3d_mutex_lock();
1210 hr = IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
1211 wined3d_mutex_unlock();
1216 static HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,CONST float* pPlane) {
1217 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1219 TRACE("(%p) Relay\n" , This);
1221 wined3d_mutex_lock();
1222 hr = IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
1223 wined3d_mutex_unlock();
1228 static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,float* pPlane) {
1229 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1231 TRACE("(%p) Relay\n" , This);
1233 wined3d_mutex_lock();
1234 hr = IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
1235 wined3d_mutex_unlock();
1240 static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD Value) {
1241 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1243 TRACE("(%p) Relay\n" , This);
1245 wined3d_mutex_lock();
1246 hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
1247 wined3d_mutex_unlock();
1252 static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD* pValue) {
1253 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1255 TRACE("(%p) Relay\n" , This);
1257 wined3d_mutex_lock();
1258 hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
1259 wined3d_mutex_unlock();
1264 static HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(LPDIRECT3DDEVICE8 iface) {
1265 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1267 TRACE("(%p)\n", This);
1269 wined3d_mutex_lock();
1270 hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
1271 wined3d_mutex_unlock();
1276 static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface, DWORD* pToken) {
1277 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1279 IWineD3DStateBlock* wineD3DStateBlock;
1280 IDirect3DStateBlock8Impl* object;
1282 TRACE("(%p) Relay\n", This);
1284 /* Tell wineD3D to endstateblock before anything else (in case we run out
1285 * of memory later and cause locking problems)
1287 wined3d_mutex_lock();
1288 hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice , &wineD3DStateBlock);
1290 WARN("IWineD3DDevice_EndStateBlock returned an error\n");
1291 wined3d_mutex_unlock();
1295 /* allocate a new IDirectD3DStateBlock */
1296 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY ,sizeof(IDirect3DStateBlock8Impl));
1298 object->lpVtbl = &Direct3DStateBlock8_Vtbl;
1300 object->wineD3DStateBlock = wineD3DStateBlock;
1302 *pToken = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_SB);
1303 wined3d_mutex_unlock();
1305 if (*pToken == D3D8_INVALID_HANDLE)
1307 ERR("Failed to create a handle\n");
1308 IDirect3DStateBlock8_Release((IDirect3DStateBlock8 *)object);
1313 TRACE("Returning %#x (%p).\n", *pToken, object);
1318 static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
1319 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1320 IDirect3DStateBlock8Impl *pSB;
1323 TRACE("(%p) %#x Relay\n", This, Token);
1325 wined3d_mutex_lock();
1326 pSB = d3d8_get_object(&This->handle_table, Token - 1, D3D8_HANDLE_SB);
1329 WARN("Invalid handle (%#x) passed.\n", Token);
1330 wined3d_mutex_unlock();
1331 return D3DERR_INVALIDCALL;
1333 hr = IWineD3DStateBlock_Apply(pSB->wineD3DStateBlock);
1334 wined3d_mutex_unlock();
1339 static HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
1340 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1341 IDirect3DStateBlock8Impl *pSB;
1344 TRACE("(%p) %#x Relay\n", This, Token);
1346 wined3d_mutex_lock();
1347 pSB = d3d8_get_object(&This->handle_table, Token - 1, D3D8_HANDLE_SB);
1350 WARN("Invalid handle (%#x) passed.\n", Token);
1351 wined3d_mutex_unlock();
1352 return D3DERR_INVALIDCALL;
1354 hr = IWineD3DStateBlock_Capture(pSB->wineD3DStateBlock);
1355 wined3d_mutex_unlock();
1360 static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
1361 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1362 IDirect3DStateBlock8Impl *pSB;
1364 TRACE("(%p) Relay\n", This);
1366 wined3d_mutex_lock();
1367 pSB = d3d8_free_handle(&This->handle_table, Token - 1, D3D8_HANDLE_SB);
1368 wined3d_mutex_unlock();
1372 WARN("Invalid handle (%#x) passed.\n", Token);
1373 return D3DERR_INVALIDCALL;
1376 if (IUnknown_Release((IUnknown *)pSB))
1378 ERR("Stateblock %p has references left, this shouldn't happen.\n", pSB);
1384 static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(IDirect3DDevice8 *iface,
1385 D3DSTATEBLOCKTYPE Type, DWORD *handle)
1387 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1388 IDirect3DStateBlock8Impl *object;
1391 TRACE("(%p) Relay\n", This);
1393 if (Type != D3DSBT_ALL
1394 && Type != D3DSBT_PIXELSTATE
1395 && Type != D3DSBT_VERTEXSTATE)
1397 WARN("Unexpected stateblock type, returning D3DERR_INVALIDCALL\n");
1398 return D3DERR_INVALIDCALL;
1401 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock8Impl));
1404 ERR("Failed to allocate memory.\n");
1405 return E_OUTOFMEMORY;
1408 object->lpVtbl = &Direct3DStateBlock8_Vtbl;
1411 wined3d_mutex_lock();
1412 hr = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type,
1413 &object->wineD3DStateBlock, (IUnknown *)object);
1416 wined3d_mutex_unlock();
1417 ERR("IWineD3DDevice_CreateStateBlock failed, hr %#x\n", hr);
1418 HeapFree(GetProcessHeap(), 0, object);
1422 *handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_SB);
1423 wined3d_mutex_unlock();
1425 if (*handle == D3D8_INVALID_HANDLE)
1427 ERR("Failed to allocate a handle.\n");
1428 IDirect3DStateBlock8_Release((IDirect3DStateBlock8 *)object);
1433 TRACE("Returning %#x (%p).\n", *handle, object);
1438 static HRESULT WINAPI IDirect3DDevice8Impl_SetClipStatus(LPDIRECT3DDEVICE8 iface, CONST D3DCLIPSTATUS8* pClipStatus) {
1439 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1441 TRACE("(%p) Relay\n" , This);
1442 /* FIXME: Verify that D3DCLIPSTATUS8 ~= WINED3DCLIPSTATUS */
1444 wined3d_mutex_lock();
1445 hr = IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
1446 wined3d_mutex_unlock();
1451 static HRESULT WINAPI IDirect3DDevice8Impl_GetClipStatus(LPDIRECT3DDEVICE8 iface, D3DCLIPSTATUS8* pClipStatus) {
1452 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1454 TRACE("(%p) Relay\n" , This);
1456 wined3d_mutex_lock();
1457 hr = IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
1458 wined3d_mutex_unlock();
1463 static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage,IDirect3DBaseTexture8** ppTexture) {
1464 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1465 IWineD3DBaseTexture *retTexture;
1468 TRACE("(%p) Relay\n" , This);
1470 if(ppTexture == NULL){
1471 return D3DERR_INVALIDCALL;
1474 wined3d_mutex_lock();
1475 hr = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture);
1478 WARN("Failed to get texture for stage %u, hr %#x.\n", Stage, hr);
1479 wined3d_mutex_unlock();
1486 IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
1487 IWineD3DBaseTexture_Release(retTexture);
1493 wined3d_mutex_unlock();
1498 static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage, IDirect3DBaseTexture8* pTexture) {
1499 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1501 TRACE("(%p) Relay %d %p\n" , This, Stage, pTexture);
1503 wined3d_mutex_lock();
1504 hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
1505 pTexture==NULL ? NULL : ((IDirect3DBaseTexture8Impl *)pTexture)->wineD3DBaseTexture);
1506 wined3d_mutex_unlock();
1511 static const struct tss_lookup
1518 {FALSE, WINED3DTSS_FORCE_DWORD}, /* 0, unused */
1519 {FALSE, WINED3DTSS_COLOROP}, /* 1, D3DTSS_COLOROP */
1520 {FALSE, WINED3DTSS_COLORARG1}, /* 2, D3DTSS_COLORARG1 */
1521 {FALSE, WINED3DTSS_COLORARG2}, /* 3, D3DTSS_COLORARG2 */
1522 {FALSE, WINED3DTSS_ALPHAOP}, /* 4, D3DTSS_ALPHAOP */
1523 {FALSE, WINED3DTSS_ALPHAARG1}, /* 5, D3DTSS_ALPHAARG1 */
1524 {FALSE, WINED3DTSS_ALPHAARG2}, /* 6, D3DTSS_ALPHAARG2 */
1525 {FALSE, WINED3DTSS_BUMPENVMAT00}, /* 7, D3DTSS_BUMPENVMAT00 */
1526 {FALSE, WINED3DTSS_BUMPENVMAT01}, /* 8, D3DTSS_BUMPENVMAT01 */
1527 {FALSE, WINED3DTSS_BUMPENVMAT10}, /* 9, D3DTSS_BUMPENVMAT10 */
1528 {FALSE, WINED3DTSS_BUMPENVMAT11}, /* 10, D3DTSS_BUMPENVMAT11 */
1529 {FALSE, WINED3DTSS_TEXCOORDINDEX}, /* 11, D3DTSS_TEXCOORDINDEX */
1530 {FALSE, WINED3DTSS_FORCE_DWORD}, /* 12, unused */
1531 {TRUE, WINED3DSAMP_ADDRESSU}, /* 13, D3DTSS_ADDRESSU */
1532 {TRUE, WINED3DSAMP_ADDRESSV}, /* 14, D3DTSS_ADDRESSV */
1533 {TRUE, WINED3DSAMP_BORDERCOLOR}, /* 15, D3DTSS_BORDERCOLOR */
1534 {TRUE, WINED3DSAMP_MAGFILTER}, /* 16, D3DTSS_MAGFILTER */
1535 {TRUE, WINED3DSAMP_MINFILTER}, /* 17, D3DTSS_MINFILTER */
1536 {TRUE, WINED3DSAMP_MIPFILTER}, /* 18, D3DTSS_MIPFILTER */
1537 {TRUE, WINED3DSAMP_MIPMAPLODBIAS}, /* 19, D3DTSS_MIPMAPLODBIAS */
1538 {TRUE, WINED3DSAMP_MAXMIPLEVEL}, /* 20, D3DTSS_MAXMIPLEVEL */
1539 {TRUE, WINED3DSAMP_MAXANISOTROPY}, /* 21, D3DTSS_MAXANISOTROPY */
1540 {FALSE, WINED3DTSS_BUMPENVLSCALE}, /* 22, D3DTSS_BUMPENVLSCALE */
1541 {FALSE, WINED3DTSS_BUMPENVLOFFSET}, /* 23, D3DTSS_BUMPENVLOFFSET */
1542 {FALSE, WINED3DTSS_TEXTURETRANSFORMFLAGS}, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
1543 {TRUE, WINED3DSAMP_ADDRESSW}, /* 25, D3DTSS_ADDRESSW */
1544 {FALSE, WINED3DTSS_COLORARG0}, /* 26, D3DTSS_COLORARG0 */
1545 {FALSE, WINED3DTSS_ALPHAARG0}, /* 27, D3DTSS_ALPHAARG0 */
1546 {FALSE, WINED3DTSS_RESULTARG}, /* 28, D3DTSS_RESULTARG */
1549 static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) {
1550 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1551 const struct tss_lookup *l = &tss_lookup[Type];
1553 TRACE("(%p) Relay\n" , This);
1555 wined3d_mutex_lock();
1556 if (l->sampler_state) hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, l->state, pValue);
1557 else hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, l->state, pValue);
1558 wined3d_mutex_unlock();
1563 static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
1564 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1565 const struct tss_lookup *l = &tss_lookup[Type];
1567 TRACE("(%p) Relay\n" , This);
1569 wined3d_mutex_lock();
1570 if (l->sampler_state) hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, l->state, Value);
1571 else hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, l->state, Value);
1572 wined3d_mutex_unlock();
1577 static HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses) {
1578 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1580 TRACE("(%p) Relay\n" , This);
1582 wined3d_mutex_lock();
1583 hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
1584 wined3d_mutex_unlock();
1589 static HRESULT WINAPI IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID, void* pDevInfoStruct, DWORD DevInfoStructSize) {
1590 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1591 FIXME("(%p) : stub\n", This);
1595 static HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
1596 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1598 TRACE("(%p) Relay\n" , This);
1600 wined3d_mutex_lock();
1601 hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
1602 wined3d_mutex_unlock();
1607 static HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
1608 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1610 TRACE("(%p) Relay\n" , This);
1612 wined3d_mutex_lock();
1613 hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
1614 wined3d_mutex_unlock();
1619 static HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber) {
1620 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1622 TRACE("(%p) Relay\n" , This);
1624 wined3d_mutex_lock();
1625 hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
1626 wined3d_mutex_unlock();
1631 static HRESULT WINAPI IDirect3DDevice8Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT *PaletteNumber) {
1632 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1634 TRACE("(%p) Relay\n" , This);
1636 wined3d_mutex_lock();
1637 hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
1638 wined3d_mutex_unlock();
1643 static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(IDirect3DDevice8 *iface, D3DPRIMITIVETYPE PrimitiveType,
1644 UINT StartVertex, UINT PrimitiveCount)
1646 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1648 TRACE("(%p) Relay\n" , This);
1650 wined3d_mutex_lock();
1651 IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
1652 hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, StartVertex,
1653 vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
1654 wined3d_mutex_unlock();
1659 static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,
1660 UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) {
1661 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1663 TRACE("(%p) Relay\n" , This);
1665 wined3d_mutex_lock();
1666 IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
1667 hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, startIndex,
1668 vertex_count_from_primitive_count(PrimitiveType, primCount));
1669 wined3d_mutex_unlock();
1674 static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) {
1675 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1677 TRACE("(%p) Relay\n" , This);
1679 wined3d_mutex_lock();
1680 IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
1681 hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice,
1682 vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
1683 pVertexStreamZeroData, VertexStreamZeroStride);
1684 wined3d_mutex_unlock();
1689 static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,
1690 UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,
1691 D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,
1692 UINT VertexStreamZeroStride) {
1693 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1695 TRACE("(%p) Relay\n" , This);
1697 wined3d_mutex_lock();
1698 IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
1699 hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice,
1700 vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
1701 wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
1702 wined3d_mutex_unlock();
1707 static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 iface, UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) {
1708 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1710 IDirect3DVertexBuffer8Impl *dest = (IDirect3DVertexBuffer8Impl *) pDestBuffer;
1711 TRACE("(%p) Relay\n" , This);
1713 wined3d_mutex_lock();
1714 hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, dest->wineD3DVertexBuffer, NULL, Flags, dest->fvf);
1715 wined3d_mutex_unlock();
1720 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(IDirect3DDevice8 *iface,
1721 const DWORD *declaration, const DWORD *byte_code, DWORD *shader, DWORD usage)
1723 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1724 IDirect3DVertexShader8Impl *object;
1725 DWORD shader_handle;
1729 TRACE("iface %p, declaration %p, byte_code %p, shader %p, usage %#x.\n",
1730 iface, declaration, byte_code, shader, usage);
1732 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
1735 ERR("Failed to allocate vertex shader memory.\n");
1737 return E_OUTOFMEMORY;
1740 wined3d_mutex_lock();
1741 handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_VS);
1742 wined3d_mutex_unlock();
1743 if (handle == D3D8_INVALID_HANDLE)
1745 ERR("Failed to allocate vertex shader handle.\n");
1746 HeapFree(GetProcessHeap(), 0, object);
1748 return E_OUTOFMEMORY;
1751 shader_handle = handle + VS_HIGHESTFIXEDFXF + 1;
1753 hr = vertexshader_init(object, This, declaration, byte_code, shader_handle, usage);
1756 WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
1757 wined3d_mutex_lock();
1758 d3d8_free_handle(&This->handle_table, handle, D3D8_HANDLE_VS);
1759 wined3d_mutex_unlock();
1760 HeapFree(GetProcessHeap(), 0, object);
1765 TRACE("Created vertex shader %p (handle %#x).\n", object, shader_handle);
1766 *shader = shader_handle;
1771 static IDirect3DVertexDeclaration8Impl *IDirect3DDevice8Impl_FindDecl(IDirect3DDevice8Impl *This, DWORD fvf)
1773 IDirect3DVertexDeclaration8Impl *d3d8_declaration;
1775 int p, low, high; /* deliberately signed */
1776 struct FvfToDecl *convertedDecls = This->decls;
1778 TRACE("Searching for declaration for fvf %08x... ", fvf);
1781 high = This->numConvertedDecls - 1;
1782 while(low <= high) {
1783 p = (low + high) >> 1;
1785 if(convertedDecls[p].fvf == fvf) {
1786 TRACE("found %p\n", convertedDecls[p].decl);
1787 return (IDirect3DVertexDeclaration8Impl *)convertedDecls[p].decl;
1788 } else if(convertedDecls[p].fvf < fvf) {
1794 TRACE("not found. Creating and inserting at position %d.\n", low);
1796 d3d8_declaration = HeapAlloc(GetProcessHeap(), 0, sizeof(*d3d8_declaration));
1797 if (!d3d8_declaration)
1799 ERR("Memory allocation failed.\n");
1803 hr = vertexdeclaration_init_fvf(d3d8_declaration, This, fvf);
1806 WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
1807 HeapFree(GetProcessHeap(), 0, d3d8_declaration);
1811 if(This->declArraySize == This->numConvertedDecls) {
1812 int grow = This->declArraySize / 2;
1813 convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
1814 sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow));
1815 if(!convertedDecls) {
1816 /* This will destroy it */
1817 IDirect3DVertexDeclaration8_Release((IDirect3DVertexDeclaration8 *)d3d8_declaration);
1820 This->decls = convertedDecls;
1821 This->declArraySize += grow;
1824 memmove(convertedDecls + low + 1, convertedDecls + low, sizeof(convertedDecls[0]) * (This->numConvertedDecls - low));
1825 convertedDecls[low].decl = (IDirect3DVertexDeclaration8 *)d3d8_declaration;
1826 convertedDecls[low].fvf = fvf;
1827 This->numConvertedDecls++;
1829 TRACE("Returning %p. %u decls in array\n", d3d8_declaration, This->numConvertedDecls);
1830 return d3d8_declaration;
1833 static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1834 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1835 IDirect3DVertexShader8Impl *shader;
1838 TRACE("(%p) : Relay\n", This);
1840 if (VS_HIGHESTFIXEDFXF >= pShader) {
1841 TRACE("Setting FVF, %#x\n", pShader);
1843 wined3d_mutex_lock();
1844 IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
1845 IDirect3DDevice8Impl_FindDecl(This, pShader)->wined3d_vertex_declaration);
1846 IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL);
1847 wined3d_mutex_unlock();
1852 TRACE("Setting shader\n");
1854 wined3d_mutex_lock();
1855 shader = d3d8_get_object(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS);
1858 WARN("Invalid handle (%#x) passed.\n", pShader);
1859 wined3d_mutex_unlock();
1861 return D3DERR_INVALIDCALL;
1864 hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
1865 ((IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration)->wined3d_vertex_declaration);
1866 if (SUCCEEDED(hr)) hr = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, shader->wineD3DVertexShader);
1867 wined3d_mutex_unlock();
1869 TRACE("Returning hr %#x\n", hr);
1874 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
1875 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1876 IWineD3DVertexDeclaration *wined3d_declaration;
1877 IDirect3DVertexDeclaration8 *d3d8_declaration;
1880 TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
1882 wined3d_mutex_lock();
1883 hrc = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &wined3d_declaration);
1886 wined3d_mutex_unlock();
1887 WARN("(%p) : Call to IWineD3DDevice_GetVertexDeclaration failed %#x (device %p)\n",
1888 This, hrc, This->WineD3DDevice);
1892 if (!wined3d_declaration)
1894 wined3d_mutex_unlock();
1899 hrc = IWineD3DVertexDeclaration_GetParent(wined3d_declaration, (IUnknown **)&d3d8_declaration);
1900 IWineD3DVertexDeclaration_Release(wined3d_declaration);
1901 wined3d_mutex_unlock();
1904 *ppShader = ((IDirect3DVertexDeclaration8Impl *)d3d8_declaration)->shader_handle;
1905 IDirect3DVertexDeclaration8_Release(d3d8_declaration);
1908 TRACE("(%p) : returning %#x\n", This, *ppShader);
1913 static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
1914 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1915 IDirect3DVertexShader8Impl *shader;
1916 IWineD3DVertexShader *cur = NULL;
1918 TRACE("(%p) : pShader %#x\n", This, pShader);
1920 wined3d_mutex_lock();
1921 shader = d3d8_free_handle(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS);
1924 WARN("Invalid handle (%#x) passed.\n", pShader);
1925 wined3d_mutex_unlock();
1927 return D3DERR_INVALIDCALL;
1930 IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &cur);
1934 if (cur == shader->wineD3DVertexShader) IDirect3DDevice8_SetVertexShader(iface, 0);
1935 IWineD3DVertexShader_Release(cur);
1938 wined3d_mutex_unlock();
1940 if (IUnknown_Release((IUnknown *)shader))
1942 ERR("Shader %p has references left, this shouldn't happen.\n", shader);
1948 static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
1949 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1951 TRACE("(%p) : Relay\n", This);
1953 if(Register + ConstantCount > D3D8_MAX_VERTEX_SHADER_CONSTANTF) {
1954 WARN("Trying to access %u constants, but d3d8 only supports %u\n",
1955 Register + ConstantCount, D3D8_MAX_VERTEX_SHADER_CONSTANTF);
1956 return D3DERR_INVALIDCALL;
1959 wined3d_mutex_lock();
1960 hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
1961 wined3d_mutex_unlock();
1966 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
1967 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1969 TRACE("(%p) : Relay\n", This);
1971 if(Register + ConstantCount > D3D8_MAX_VERTEX_SHADER_CONSTANTF) {
1972 WARN("Trying to access %u constants, but d3d8 only supports %u\n",
1973 Register + ConstantCount, D3D8_MAX_VERTEX_SHADER_CONSTANTF);
1974 return D3DERR_INVALIDCALL;
1977 wined3d_mutex_lock();
1978 hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
1979 wined3d_mutex_unlock();
1984 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
1985 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
1986 IDirect3DVertexDeclaration8Impl *declaration;
1987 IDirect3DVertexShader8Impl *shader;
1989 TRACE("(%p) : pVertexShader 0x%08x, pData %p, *pSizeOfData %u\n", This, pVertexShader, pData, *pSizeOfData);
1991 wined3d_mutex_lock();
1992 shader = d3d8_get_object(&This->handle_table, pVertexShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS);
1993 wined3d_mutex_unlock();
1997 WARN("Invalid handle (%#x) passed.\n", pVertexShader);
1998 return D3DERR_INVALIDCALL;
2000 declaration = (IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration;
2002 /* If pData is NULL, we just return the required size of the buffer. */
2004 *pSizeOfData = declaration->elements_size;
2008 /* MSDN claims that if *pSizeOfData is smaller than the required size
2009 * we should write the required size and return D3DERR_MOREDATA.
2010 * That's not actually true. */
2011 if (*pSizeOfData < declaration->elements_size) {
2012 return D3DERR_INVALIDCALL;
2015 CopyMemory(pData, declaration->elements, declaration->elements_size);
2020 static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
2021 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2022 IDirect3DVertexShader8Impl *shader = NULL;
2025 TRACE("(%p) : pVertexShader %#x, pData %p, pSizeOfData %p\n", This, pVertexShader, pData, pSizeOfData);
2027 wined3d_mutex_lock();
2028 shader = d3d8_get_object(&This->handle_table, pVertexShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS);
2031 WARN("Invalid handle (%#x) passed.\n", pVertexShader);
2032 wined3d_mutex_unlock();
2034 return D3DERR_INVALIDCALL;
2037 if (!shader->wineD3DVertexShader)
2039 wined3d_mutex_unlock();
2044 hr = IWineD3DVertexShader_GetFunction(shader->wineD3DVertexShader, pData, pSizeOfData);
2045 wined3d_mutex_unlock();
2050 static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData, UINT baseVertexIndex) {
2051 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2053 IDirect3DIndexBuffer8Impl *ib = (IDirect3DIndexBuffer8Impl *)pIndexData;
2054 TRACE("(%p) Relay\n", This);
2056 /* WineD3D takes an INT(due to d3d9), but d3d8 uses UINTs. Do I have to add a check here that
2057 * the UINT doesn't cause an overflow in the INT? It seems rather unlikely because such large
2058 * vertex buffers can't be created to address them with an index that requires the 32nd bit
2059 * (4 Byte minimum vertex size * 2^31-1 -> 8 gb buffer. The index sign would be the least
2062 wined3d_mutex_lock();
2063 IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, baseVertexIndex);
2064 hr = IWineD3DDevice_SetIndexBuffer(This->WineD3DDevice,
2065 ib ? ib->wineD3DIndexBuffer : NULL,
2066 ib ? ib->format : WINED3DFMT_UNKNOWN);
2067 wined3d_mutex_unlock();
2072 static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) {
2073 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2074 IWineD3DBuffer *retIndexData = NULL;
2075 HRESULT rc = D3D_OK;
2077 TRACE("(%p) Relay\n", This);
2079 if(ppIndexData == NULL){
2080 return D3DERR_INVALIDCALL;
2083 /* The case from UINT to INT is safe because d3d8 will never set negative values */
2084 wined3d_mutex_lock();
2085 IWineD3DDevice_GetBaseVertexIndex(This->WineD3DDevice, (INT *) pBaseVertexIndex);
2086 rc = IWineD3DDevice_GetIndexBuffer(This->WineD3DDevice, &retIndexData);
2087 if (SUCCEEDED(rc) && retIndexData) {
2088 IWineD3DBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
2089 IWineD3DBuffer_Release(retIndexData);
2091 if (FAILED(rc)) FIXME("Call to GetIndices failed\n");
2092 *ppIndexData = NULL;
2094 wined3d_mutex_unlock();
2099 static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *iface,
2100 const DWORD *byte_code, DWORD *shader)
2102 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2103 IDirect3DPixelShader8Impl *object;
2104 DWORD shader_handle;
2108 TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader);
2112 TRACE("(%p) Invalid call\n", This);
2113 return D3DERR_INVALIDCALL;
2116 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
2119 ERR("Failed to allocate pixel shader memmory.\n");
2120 return E_OUTOFMEMORY;
2123 wined3d_mutex_lock();
2124 handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_PS);
2125 wined3d_mutex_unlock();
2126 if (handle == D3D8_INVALID_HANDLE)
2128 ERR("Failed to allocate pixel shader handle.\n");
2129 HeapFree(GetProcessHeap(), 0, object);
2130 return E_OUTOFMEMORY;
2133 shader_handle = handle + VS_HIGHESTFIXEDFXF + 1;
2135 hr = pixelshader_init(object, This, byte_code, shader_handle);
2138 WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
2139 wined3d_mutex_lock();
2140 d3d8_free_handle(&This->handle_table, handle, D3D8_HANDLE_PS);
2141 wined3d_mutex_unlock();
2142 HeapFree(GetProcessHeap(), 0, object);
2147 TRACE("Created pixel shader %p (handle %#x).\n", object, shader_handle);
2148 *shader = shader_handle;
2153 static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
2154 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2155 IDirect3DPixelShader8Impl *shader;
2158 TRACE("(%p) : pShader %#x\n", This, pShader);
2160 wined3d_mutex_lock();
2164 hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, NULL);
2165 wined3d_mutex_unlock();
2169 shader = d3d8_get_object(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS);
2172 WARN("Invalid handle (%#x) passed.\n", pShader);
2173 wined3d_mutex_unlock();
2174 return D3DERR_INVALIDCALL;
2177 TRACE("(%p) : Setting shader %p\n", This, shader);
2178 hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader->wineD3DPixelShader);
2179 wined3d_mutex_unlock();
2184 static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
2185 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2186 IWineD3DPixelShader *object;
2188 HRESULT hrc = D3D_OK;
2189 TRACE("(%p) Relay\n", This);
2190 if (NULL == ppShader) {
2191 TRACE("(%p) Invalid call\n", This);
2192 return D3DERR_INVALIDCALL;
2195 wined3d_mutex_lock();
2196 hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
2197 if (D3D_OK == hrc && NULL != object) {
2198 IDirect3DPixelShader8Impl *d3d8_shader;
2199 hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)&d3d8_shader);
2200 IWineD3DPixelShader_Release(object);
2201 *ppShader = d3d8_shader->handle;
2202 IDirect3DPixelShader8_Release((IDirect3DPixelShader8 *)d3d8_shader);
2206 wined3d_mutex_unlock();
2208 TRACE("(%p) : returning %#x\n", This, *ppShader);
2213 static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
2214 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2215 IDirect3DPixelShader8Impl *shader;
2216 IWineD3DPixelShader *cur = NULL;
2218 TRACE("(%p) : pShader %#x\n", This, pShader);
2220 wined3d_mutex_lock();
2222 shader = d3d8_free_handle(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS);
2225 WARN("Invalid handle (%#x) passed.\n", pShader);
2226 wined3d_mutex_unlock();
2230 IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &cur);
2234 if (cur == shader->wineD3DPixelShader) IDirect3DDevice8_SetPixelShader(iface, 0);
2235 IWineD3DPixelShader_Release(cur);
2238 wined3d_mutex_unlock();
2240 if (IUnknown_Release((IUnknown *)shader))
2242 ERR("Shader %p has references left, this shouldn't happen.\n", shader);
2248 static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
2249 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2251 TRACE("(%p) Relay\n", This);
2253 wined3d_mutex_lock();
2254 hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
2255 wined3d_mutex_unlock();
2260 static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
2261 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2263 TRACE("(%p) Relay\n", This);
2265 wined3d_mutex_lock();
2266 hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
2267 wined3d_mutex_unlock();
2272 static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pPixelShader, void* pData, DWORD* pSizeOfData) {
2273 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2274 IDirect3DPixelShader8Impl *shader = NULL;
2277 TRACE("(%p) : pPixelShader %#x, pData %p, pSizeOfData %p\n", This, pPixelShader, pData, pSizeOfData);
2279 wined3d_mutex_lock();
2280 shader = d3d8_get_object(&This->handle_table, pPixelShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS);
2283 WARN("Invalid handle (%#x) passed.\n", pPixelShader);
2284 wined3d_mutex_unlock();
2286 return D3DERR_INVALIDCALL;
2289 hr = IWineD3DPixelShader_GetFunction(shader->wineD3DPixelShader, pData, pSizeOfData);
2290 wined3d_mutex_unlock();
2295 static HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
2296 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2298 TRACE("(%p) Relay\n", This);
2300 wined3d_mutex_lock();
2301 hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
2302 wined3d_mutex_unlock();
2307 static HRESULT WINAPI IDirect3DDevice8Impl_DrawTriPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
2308 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2310 TRACE("(%p) Relay\n", This);
2312 wined3d_mutex_lock();
2313 hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
2314 wined3d_mutex_unlock();
2319 static HRESULT WINAPI IDirect3DDevice8Impl_DeletePatch(LPDIRECT3DDEVICE8 iface, UINT Handle) {
2320 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2322 TRACE("(%p) Relay\n", This);
2324 wined3d_mutex_lock();
2325 hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
2326 wined3d_mutex_unlock();
2331 static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) {
2332 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2334 TRACE("(%p) Relay\n" , This);
2336 wined3d_mutex_lock();
2337 hr = IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
2338 NULL == pStreamData ? NULL : ((IDirect3DVertexBuffer8Impl *)pStreamData)->wineD3DVertexBuffer,
2339 0/* Offset in bytes */, Stride);
2340 wined3d_mutex_unlock();
2345 static HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8** pStream,UINT* pStride) {
2346 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
2347 IWineD3DBuffer *retStream = NULL;
2348 HRESULT rc = D3D_OK;
2350 TRACE("(%p) Relay\n" , This);
2352 if(pStream == NULL){
2353 return D3DERR_INVALIDCALL;
2356 wined3d_mutex_lock();
2357 rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, 0 /* Offset in bytes */, pStride);
2358 if (rc == D3D_OK && NULL != retStream) {
2359 IWineD3DBuffer_GetParent(retStream, (IUnknown **)pStream);
2360 IWineD3DBuffer_Release(retStream);
2363 FIXME("Call to GetStreamSource failed %p\n", pStride);
2367 wined3d_mutex_unlock();
2373 const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl =
2375 IDirect3DDevice8Impl_QueryInterface,
2376 IDirect3DDevice8Impl_AddRef,
2377 IDirect3DDevice8Impl_Release,
2378 IDirect3DDevice8Impl_TestCooperativeLevel,
2379 IDirect3DDevice8Impl_GetAvailableTextureMem,
2380 IDirect3DDevice8Impl_ResourceManagerDiscardBytes,
2381 IDirect3DDevice8Impl_GetDirect3D,
2382 IDirect3DDevice8Impl_GetDeviceCaps,
2383 IDirect3DDevice8Impl_GetDisplayMode,
2384 IDirect3DDevice8Impl_GetCreationParameters,
2385 IDirect3DDevice8Impl_SetCursorProperties,
2386 IDirect3DDevice8Impl_SetCursorPosition,
2387 IDirect3DDevice8Impl_ShowCursor,
2388 IDirect3DDevice8Impl_CreateAdditionalSwapChain,
2389 IDirect3DDevice8Impl_Reset,
2390 IDirect3DDevice8Impl_Present,
2391 IDirect3DDevice8Impl_GetBackBuffer,
2392 IDirect3DDevice8Impl_GetRasterStatus,
2393 IDirect3DDevice8Impl_SetGammaRamp,
2394 IDirect3DDevice8Impl_GetGammaRamp,
2395 IDirect3DDevice8Impl_CreateTexture,
2396 IDirect3DDevice8Impl_CreateVolumeTexture,
2397 IDirect3DDevice8Impl_CreateCubeTexture,
2398 IDirect3DDevice8Impl_CreateVertexBuffer,
2399 IDirect3DDevice8Impl_CreateIndexBuffer,
2400 IDirect3DDevice8Impl_CreateRenderTarget,
2401 IDirect3DDevice8Impl_CreateDepthStencilSurface,
2402 IDirect3DDevice8Impl_CreateImageSurface,
2403 IDirect3DDevice8Impl_CopyRects,
2404 IDirect3DDevice8Impl_UpdateTexture,
2405 IDirect3DDevice8Impl_GetFrontBuffer,
2406 IDirect3DDevice8Impl_SetRenderTarget,
2407 IDirect3DDevice8Impl_GetRenderTarget,
2408 IDirect3DDevice8Impl_GetDepthStencilSurface,
2409 IDirect3DDevice8Impl_BeginScene,
2410 IDirect3DDevice8Impl_EndScene,
2411 IDirect3DDevice8Impl_Clear,
2412 IDirect3DDevice8Impl_SetTransform,
2413 IDirect3DDevice8Impl_GetTransform,
2414 IDirect3DDevice8Impl_MultiplyTransform,
2415 IDirect3DDevice8Impl_SetViewport,
2416 IDirect3DDevice8Impl_GetViewport,
2417 IDirect3DDevice8Impl_SetMaterial,
2418 IDirect3DDevice8Impl_GetMaterial,
2419 IDirect3DDevice8Impl_SetLight,
2420 IDirect3DDevice8Impl_GetLight,
2421 IDirect3DDevice8Impl_LightEnable,
2422 IDirect3DDevice8Impl_GetLightEnable,
2423 IDirect3DDevice8Impl_SetClipPlane,
2424 IDirect3DDevice8Impl_GetClipPlane,
2425 IDirect3DDevice8Impl_SetRenderState,
2426 IDirect3DDevice8Impl_GetRenderState,
2427 IDirect3DDevice8Impl_BeginStateBlock,
2428 IDirect3DDevice8Impl_EndStateBlock,
2429 IDirect3DDevice8Impl_ApplyStateBlock,
2430 IDirect3DDevice8Impl_CaptureStateBlock,
2431 IDirect3DDevice8Impl_DeleteStateBlock,
2432 IDirect3DDevice8Impl_CreateStateBlock,
2433 IDirect3DDevice8Impl_SetClipStatus,
2434 IDirect3DDevice8Impl_GetClipStatus,
2435 IDirect3DDevice8Impl_GetTexture,
2436 IDirect3DDevice8Impl_SetTexture,
2437 IDirect3DDevice8Impl_GetTextureStageState,
2438 IDirect3DDevice8Impl_SetTextureStageState,
2439 IDirect3DDevice8Impl_ValidateDevice,
2440 IDirect3DDevice8Impl_GetInfo,
2441 IDirect3DDevice8Impl_SetPaletteEntries,
2442 IDirect3DDevice8Impl_GetPaletteEntries,
2443 IDirect3DDevice8Impl_SetCurrentTexturePalette,
2444 IDirect3DDevice8Impl_GetCurrentTexturePalette,
2445 IDirect3DDevice8Impl_DrawPrimitive,
2446 IDirect3DDevice8Impl_DrawIndexedPrimitive,
2447 IDirect3DDevice8Impl_DrawPrimitiveUP,
2448 IDirect3DDevice8Impl_DrawIndexedPrimitiveUP,
2449 IDirect3DDevice8Impl_ProcessVertices,
2450 IDirect3DDevice8Impl_CreateVertexShader,
2451 IDirect3DDevice8Impl_SetVertexShader,
2452 IDirect3DDevice8Impl_GetVertexShader,
2453 IDirect3DDevice8Impl_DeleteVertexShader,
2454 IDirect3DDevice8Impl_SetVertexShaderConstant,
2455 IDirect3DDevice8Impl_GetVertexShaderConstant,
2456 IDirect3DDevice8Impl_GetVertexShaderDeclaration,
2457 IDirect3DDevice8Impl_GetVertexShaderFunction,
2458 IDirect3DDevice8Impl_SetStreamSource,
2459 IDirect3DDevice8Impl_GetStreamSource,
2460 IDirect3DDevice8Impl_SetIndices,
2461 IDirect3DDevice8Impl_GetIndices,
2462 IDirect3DDevice8Impl_CreatePixelShader,
2463 IDirect3DDevice8Impl_SetPixelShader,
2464 IDirect3DDevice8Impl_GetPixelShader,
2465 IDirect3DDevice8Impl_DeletePixelShader,
2466 IDirect3DDevice8Impl_SetPixelShaderConstant,
2467 IDirect3DDevice8Impl_GetPixelShaderConstant,
2468 IDirect3DDevice8Impl_GetPixelShaderFunction,
2469 IDirect3DDevice8Impl_DrawRectPatch,
2470 IDirect3DDevice8Impl_DrawTriPatch,
2471 IDirect3DDevice8Impl_DeletePatch
2474 /* IWineD3DDeviceParent IUnknown methods */
2476 static inline struct IDirect3DDevice8Impl *device_from_device_parent(IWineD3DDeviceParent *iface)
2478 return (struct IDirect3DDevice8Impl *)((char*)iface
2479 - FIELD_OFFSET(struct IDirect3DDevice8Impl, device_parent_vtbl));
2482 static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
2484 struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
2485 return IDirect3DDevice8Impl_QueryInterface((IDirect3DDevice8 *)This, riid, object);
2488 static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
2490 struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
2491 return IDirect3DDevice8Impl_AddRef((IDirect3DDevice8 *)This);
2494 static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
2496 struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
2497 return IDirect3DDevice8Impl_Release((IDirect3DDevice8 *)This);
2500 /* IWineD3DDeviceParent methods */
2502 static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
2504 TRACE("iface %p, device %p\n", iface, device);
2507 static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
2508 IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
2509 WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
2511 struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
2512 IDirect3DSurface8Impl *d3d_surface;
2513 BOOL lockable = TRUE;
2516 TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
2517 "\tpool %#x, level %u, face %u, surface %p\n",
2518 iface, superior, width, height, format, usage, pool, level, face, surface);
2521 if (pool == WINED3DPOOL_DEFAULT && !(usage & WINED3DUSAGE_DYNAMIC)) lockable = FALSE;
2523 hr = IDirect3DDevice8Impl_CreateSurface((IDirect3DDevice8 *)This, width, height,
2524 d3dformat_from_wined3dformat(format), lockable, FALSE /* Discard */, level,
2525 (IDirect3DSurface8 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
2528 ERR("(%p) CreateSurface failed, returning %#x\n", iface, hr);
2532 *surface = d3d_surface->wineD3DSurface;
2533 IWineD3DSurface_AddRef(*surface);
2535 d3d_surface->container = superior;
2536 IUnknown_Release(d3d_surface->parentDevice);
2537 d3d_surface->parentDevice = NULL;
2539 IDirect3DSurface8_Release((IDirect3DSurface8 *)d3d_surface);
2540 d3d_surface->forwardReference = superior;
2545 static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
2546 IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
2547 DWORD multisample_quality, BOOL lockable, IWineD3DSurface **surface)
2549 struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
2550 IDirect3DSurface8Impl *d3d_surface;
2553 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2554 "\tmultisample_quality %u, lockable %u, surface %p\n",
2555 iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
2557 hr = IDirect3DDevice8_CreateRenderTarget((IDirect3DDevice8 *)This, width, height,
2558 d3dformat_from_wined3dformat(format), multisample_type, lockable, (IDirect3DSurface8 **)&d3d_surface);
2561 ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface, hr);
2565 *surface = d3d_surface->wineD3DSurface;
2566 IWineD3DSurface_AddRef(*surface);
2568 d3d_surface->container = (IUnknown *)This;
2569 /* Implicit surfaces are created with an refcount of 0 */
2570 IUnknown_Release((IUnknown *)d3d_surface);
2575 static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
2576 IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
2577 DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
2579 struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
2580 IDirect3DSurface8Impl *d3d_surface;
2583 TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
2584 "\tmultisample_quality %u, discard %u, surface %p\n",
2585 iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
2587 hr = IDirect3DDevice8_CreateDepthStencilSurface((IDirect3DDevice8 *)This, width, height,
2588 d3dformat_from_wined3dformat(format), multisample_type, (IDirect3DSurface8 **)&d3d_surface);
2591 ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface, hr);
2595 *surface = d3d_surface->wineD3DSurface;
2596 IWineD3DSurface_AddRef(*surface);
2598 d3d_surface->container = (IUnknown *)This;
2599 /* Implicit surfaces are created with an refcount of 0 */
2600 IUnknown_Release((IUnknown *)d3d_surface);
2605 static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
2606 IUnknown *superior, UINT width, UINT height, UINT depth, WINED3DFORMAT format,
2607 WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
2609 struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
2610 IDirect3DVolume8Impl *object;
2613 TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
2614 iface, superior, width, height, depth, format, pool, usage, volume);
2616 /* Allocate the storage for the device */
2617 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
2620 FIXME("Allocation of memory failed\n");
2622 return D3DERR_OUTOFVIDEOMEMORY;
2625 hr = volume_init(object, This, width, height, depth, usage, format, pool);
2628 WARN("Failed to initialize volume, hr %#x.\n", hr);
2629 HeapFree(GetProcessHeap(), 0, object);
2633 *volume = object->wineD3DVolume;
2634 IWineD3DVolume_AddRef(*volume);
2635 IDirect3DVolume8_Release((IDirect3DVolume8 *)object);
2637 object->container = superior;
2638 object->forwardReference = superior;
2640 TRACE("(%p) Created volume %p\n", iface, object);
2645 static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
2646 WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
2648 struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
2649 IDirect3DSwapChain8Impl *d3d_swapchain;
2650 D3DPRESENT_PARAMETERS local_parameters;
2653 TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
2655 /* Copy the presentation parameters */
2656 local_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
2657 local_parameters.BackBufferHeight = present_parameters->BackBufferHeight;
2658 local_parameters.BackBufferFormat = d3dformat_from_wined3dformat(present_parameters->BackBufferFormat);
2659 local_parameters.BackBufferCount = present_parameters->BackBufferCount;
2660 local_parameters.MultiSampleType = present_parameters->MultiSampleType;
2661 local_parameters.SwapEffect = present_parameters->SwapEffect;
2662 local_parameters.hDeviceWindow = present_parameters->hDeviceWindow;
2663 local_parameters.Windowed = present_parameters->Windowed;
2664 local_parameters.EnableAutoDepthStencil = present_parameters->EnableAutoDepthStencil;
2665 local_parameters.AutoDepthStencilFormat = d3dformat_from_wined3dformat(present_parameters->AutoDepthStencilFormat);
2666 local_parameters.Flags = present_parameters->Flags;
2667 local_parameters.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
2668 local_parameters.FullScreen_PresentationInterval = present_parameters->PresentationInterval;
2670 hr = IDirect3DDevice8_CreateAdditionalSwapChain((IDirect3DDevice8 *)This,
2671 &local_parameters, (IDirect3DSwapChain8 **)&d3d_swapchain);
2674 ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
2679 *swapchain = d3d_swapchain->wineD3DSwapChain;
2680 IUnknown_Release(d3d_swapchain->parentDevice);
2681 d3d_swapchain->parentDevice = NULL;
2683 /* Copy back the presentation parameters */
2684 present_parameters->BackBufferWidth = local_parameters.BackBufferWidth;
2685 present_parameters->BackBufferHeight = local_parameters.BackBufferHeight;
2686 present_parameters->BackBufferFormat = wined3dformat_from_d3dformat(local_parameters.BackBufferFormat);
2687 present_parameters->BackBufferCount = local_parameters.BackBufferCount;
2688 present_parameters->MultiSampleType = local_parameters.MultiSampleType;
2689 present_parameters->SwapEffect = local_parameters.SwapEffect;
2690 present_parameters->hDeviceWindow = local_parameters.hDeviceWindow;
2691 present_parameters->Windowed = local_parameters.Windowed;
2692 present_parameters->EnableAutoDepthStencil = local_parameters.EnableAutoDepthStencil;
2693 present_parameters->AutoDepthStencilFormat = wined3dformat_from_d3dformat(local_parameters.AutoDepthStencilFormat);
2694 present_parameters->Flags = local_parameters.Flags;
2695 present_parameters->FullScreen_RefreshRateInHz = local_parameters.FullScreen_RefreshRateInHz;
2696 present_parameters->PresentationInterval = local_parameters.FullScreen_PresentationInterval;
2701 const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl =
2703 /* IUnknown methods */
2704 device_parent_QueryInterface,
2705 device_parent_AddRef,
2706 device_parent_Release,
2707 /* IWineD3DDeviceParent methods */
2708 device_parent_WineD3DDeviceCreated,
2709 device_parent_CreateSurface,
2710 device_parent_CreateRenderTarget,
2711 device_parent_CreateDepthStencilSurface,
2712 device_parent_CreateVolume,
2713 device_parent_CreateSwapChain,