2 * Copyright (c) 2006 Stefan Dösinger
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/port.h"
21 #include "wine/debug.h"
34 #include "wine/exception.h"
39 #include "ddraw_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
43 /*****************************************************************************
44 * IDirect3D7::QueryInterface
46 * QueryInterface implementation with thunks to IDirectDraw7
48 *****************************************************************************/
50 Thunk_IDirect3DImpl_7_QueryInterface(IDirect3D7 *iface,
54 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
55 TRACE("(%p)->(%s,%p): Thunking to IDirectDraw7\n", This, debugstr_guid(refiid), obj);
57 return IDirectDraw7_QueryInterface(ICOM_INTERFACE(This, IDirectDraw7),
63 Thunk_IDirect3DImpl_3_QueryInterface(IDirect3D3 *iface,
67 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
68 TRACE("(%p)->(%s,%p): Thunking to IDirectDraw7\n", This, debugstr_guid(refiid), obj);
70 return IDirectDraw7_QueryInterface(ICOM_INTERFACE(This, IDirectDraw7),
76 Thunk_IDirect3DImpl_2_QueryInterface(IDirect3D2 *iface,
80 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
81 TRACE("(%p)->(%s,%p): Thunking to IDirectDraw7\n", This, debugstr_guid(refiid), obj);
83 return IDirectDraw7_QueryInterface(ICOM_INTERFACE(This, IDirectDraw7),
89 Thunk_IDirect3DImpl_1_QueryInterface(IDirect3D *iface,
93 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
94 TRACE("(%p)->(%s,%p): Thunking to IDirectDraw7\n", This, debugstr_guid(refiid), obj);
96 return IDirectDraw7_QueryInterface(ICOM_INTERFACE(This, IDirectDraw7),
101 /*****************************************************************************
104 * DirectDraw refcounting is a bit odd. Every version of the ddraw interface
105 * has its own refcount, but IDirect3D 1/2/3 refcounts are linked to
106 * IDirectDraw, and IDirect3D7 is linked to IDirectDraw7
108 * IDirect3D7 -> IDirectDraw7
109 * IDirect3D3 -> IDirectDraw
110 * IDirect3D2 -> IDirectDraw
111 * IDirect3D -> IDirectDraw
113 * So every AddRef implementation thunks to a different interface, and the
114 * IDirectDrawX::AddRef implementations have different counters...
119 *****************************************************************************/
121 Thunk_IDirect3DImpl_7_AddRef(IDirect3D7 *iface)
123 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
124 TRACE("(%p) : Thunking to IDirectDraw7.\n", This);
126 return IDirectDraw7_AddRef(ICOM_INTERFACE(This, IDirectDraw7));
130 Thunk_IDirect3DImpl_3_AddRef(IDirect3D3 *iface)
132 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
133 TRACE("(%p) : Thunking to IDirectDraw.\n", This);
135 return IDirectDraw_AddRef(ICOM_INTERFACE(This, IDirectDraw));
139 Thunk_IDirect3DImpl_2_AddRef(IDirect3D2 *iface)
141 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
142 TRACE("(%p) : Thunking to IDirectDraw.\n", This);
144 return IDirectDraw_AddRef(ICOM_INTERFACE(This, IDirectDraw));
148 Thunk_IDirect3DImpl_1_AddRef(IDirect3D *iface)
150 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
151 TRACE("(%p) : Thunking to IDirectDraw.\n", This);
153 return IDirectDraw_AddRef(ICOM_INTERFACE(This, IDirectDraw));
156 /*****************************************************************************
157 * IDirect3D7::Release
159 * Same story as IDirect3D7::AddRef
161 * Returns: The new refcount
163 *****************************************************************************/
165 Thunk_IDirect3DImpl_7_Release(IDirect3D7 *iface)
167 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
168 TRACE("(%p) : Thunking to IDirectDraw7.\n", This);
170 return IDirectDraw7_Release(ICOM_INTERFACE(This, IDirectDraw7));
174 Thunk_IDirect3DImpl_3_Release(IDirect3D3 *iface)
176 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
177 TRACE("(%p) : Thunking to IDirectDraw.\n", This);
179 return IDirectDraw_Release(ICOM_INTERFACE(This, IDirectDraw));
183 Thunk_IDirect3DImpl_2_Release(IDirect3D2 *iface)
185 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
186 TRACE("(%p) : Thunking to IDirectDraw.\n", This);
188 return IDirectDraw_Release(ICOM_INTERFACE(This, IDirectDraw));
192 Thunk_IDirect3DImpl_1_Release(IDirect3D *iface)
194 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
195 TRACE("(%p) : Thunking to IDirectDraw.\n", This);
197 return IDirectDraw_Release(ICOM_INTERFACE(This, IDirectDraw));
200 /*****************************************************************************
202 *****************************************************************************/
204 /*****************************************************************************
205 * IDirect3D::Initialize
207 * Initializes the IDirect3D interface. This is a no-op implementation,
208 * as all initialization is done at create time.
216 * D3D_OK, because it's a no-op
218 *****************************************************************************/
219 static HRESULT WINAPI
220 IDirect3DImpl_1_Initialize(IDirect3D *iface,
223 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
225 TRACE("(%p)->(%s) no-op...\n", This, debugstr_guid(refiid));
229 /*****************************************************************************
230 * IDirect3D7::EnumDevices
232 * The EnumDevices method for IDirect3D7. It enumerates all supported
233 * D3D7 devices. Currently the T&L, HAL and RGB devices are enumerated.
236 * Callback: Function to call for each enumerated device
237 * Context: Pointer to pass back to the app
240 * D3D_OK, or the return value of the GetCaps call
242 *****************************************************************************/
243 static HRESULT WINAPI
244 IDirect3DImpl_7_EnumDevices(IDirect3D7 *iface,
245 LPD3DENUMDEVICESCALLBACK7 Callback,
248 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
249 char interface_name_tnl[] = "WINE Direct3D7 Hardware Transform and Lighting acceleration using WineD3D";
250 char device_name_tnl[] = "Wine D3D7 T&L HAL";
251 char interface_name_hal[] = "WINE Direct3D7 Hardware acceleration using WineD3D";
252 char device_name_hal[] = "Wine D3D7 HAL";
253 char interface_name_rgb[] = "WINE Direct3D7 RGB Software Emulation using WineD3D";
254 char device_name_rgb[] = "Wine D3D7 RGB";
255 D3DDEVICEDESC7 ddesc;
256 D3DDEVICEDESC oldDesc;
259 TRACE("(%p)->(%p,%p)\n", This, Callback, Context);
260 EnterCriticalSection(&ddraw_cs);
262 TRACE("(%p) Enumerating WineD3D D3Device7 interface\n", This);
263 hr = IDirect3DImpl_GetCaps(This->wineD3D, &oldDesc, &ddesc);
266 LeaveCriticalSection(&ddraw_cs);
269 Callback(interface_name_tnl, device_name_tnl, &ddesc, Context);
271 ddesc.deviceGUID = IID_IDirect3DHALDevice;
272 Callback(interface_name_hal, device_name_hal, &ddesc, Context);
274 ddesc.deviceGUID = IID_IDirect3DRGBDevice;
275 Callback(interface_name_rgb, device_name_rgb, &ddesc, Context);
277 TRACE("(%p) End of enumeration\n", This);
278 LeaveCriticalSection(&ddraw_cs);
282 /*****************************************************************************
283 * IDirect3D3::EnumDevices
285 * Enumerates all supported Direct3DDevice interfaces. This is the
286 * implementation for Direct3D 1 to Direc3D 3, Version 7 has its own.
291 * Callback: Application-provided routine to call for each enumerated device
292 * Context: Pointer to pass to the callback
296 * The result of IDirect3DImpl_GetCaps if it failed
298 *****************************************************************************/
299 static HRESULT WINAPI
300 IDirect3DImpl_3_EnumDevices(IDirect3D3 *iface,
301 LPD3DENUMDEVICESCALLBACK Callback,
304 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
305 D3DDEVICEDESC dref, d1, d2;
306 D3DDEVICEDESC7 newDesc;
307 static CHAR wined3d_description[] = "Wine D3DDevice using WineD3D and OpenGL";
310 /* Some games (Motoracer 2 demo) have the bad idea to modify the device name string.
311 Let's put the string in a sufficiently sized array in writable memory. */
312 char device_name[50];
313 strcpy(device_name,"direct3d");
315 TRACE("(%p)->(%p,%p)\n", This, Callback, Context);
316 EnterCriticalSection(&ddraw_cs);
318 hr = IDirect3DImpl_GetCaps(This->wineD3D, &dref, &newDesc);
321 LeaveCriticalSection(&ddraw_cs);
325 /* Do I have to enumerate the reference id? Note from old d3d7:
326 * "It seems that enumerating the reference IID on Direct3D 1 games
327 * (AvP / Motoracer2) breaks them". So do not enumerate this iid in V1
329 * There's a registry key HKLM\Software\Microsoft\Direct3D\Drivers, EnumReference
330 * which enables / disables enumerating the reference rasterizer. It's a DWORD,
331 * 0 means disabled, 2 means enabled. The enablerefrast.reg and disablerefrast.reg
332 * files in the DirectX 7.0 sdk demo directory suggest this.
334 * Some games(GTA 2) seem to use the second enumerated device, so I have to enumerate
335 * at least 2 devices. So enumerate the reference device to have 2 devices.
337 * Other games(Rollcage) tell emulation and hal device appart by certain flags.
338 * Rollcage expects D3DPTEXTURECAPS_POW2 to be set(yeah, it is a limitation flag),
339 * and it refuses all devices that have the perspective flag set. This way it refuses
340 * the emulation device, and HAL devices never have POW2 unset in d3d7 on windows.
343 if(This->d3dversion != 1)
345 static CHAR reference_description[] = "RGB Direct3D emulation";
347 TRACE("(%p) Enumerating WineD3D D3DDevice interface\n", This);
350 /* The rgb device has the pow2 flag set in the hel caps, but not in the hal caps */
351 d1.dpcLineCaps.dwTextureCaps &= ~(D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE);
352 d1.dpcTriCaps.dwTextureCaps &= ~(D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE);
353 hr = Callback( (LPIID) &IID_IDirect3DRGBDevice, reference_description, device_name, &d1, &d2, Context);
354 if(hr != D3DENUMRET_OK)
356 TRACE("Application cancelled the enumeration\n");
357 LeaveCriticalSection(&ddraw_cs);
362 TRACE("(%p) Enumerating HAL Direct3D device\n", This);
365 /* The hal device does not have the pow2 flag set in hel, but in hal */
366 d2.dpcLineCaps.dwTextureCaps &= ~(D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE);
367 d2.dpcTriCaps.dwTextureCaps &= ~(D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PERSPECTIVE);
368 hr = Callback( (LPIID) &IID_IDirect3DHALDevice, wined3d_description, device_name, &d1, &d2, Context);
369 if(hr != D3DENUMRET_OK)
371 TRACE("Application cancelled the enumeration\n");
372 LeaveCriticalSection(&ddraw_cs);
375 TRACE("(%p) End of enumeration\n", This);
377 LeaveCriticalSection(&ddraw_cs);
381 static HRESULT WINAPI
382 Thunk_IDirect3DImpl_2_EnumDevices(IDirect3D2 *iface,
383 LPD3DENUMDEVICESCALLBACK Callback,
386 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
387 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, Callback, Context);
388 return IDirect3D3_EnumDevices(ICOM_INTERFACE(This, IDirect3D3),
393 static HRESULT WINAPI
394 Thunk_IDirect3DImpl_1_EnumDevices(IDirect3D *iface,
395 LPD3DENUMDEVICESCALLBACK Callback,
398 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
399 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, Callback, Context);
400 return IDirect3D3_EnumDevices(ICOM_INTERFACE(This, IDirect3D3),
405 /*****************************************************************************
406 * IDirect3D3::CreateLight
408 * Creates an IDirect3DLight interface. This interface is used in
409 * Direct3D3 or earlier for lighting. In Direct3D7 it has been replaced
410 * by the DIRECT3DLIGHT7 structure. Wine's Direct3DLight implementation
411 * uses the IDirect3DDevice7 interface with D3D7 lights.
416 * Light: Address to store the new interface pointer
417 * UnkOuter: Basically for aggregation, but ddraw doesn't support it.
422 * DDERR_OUTOFMEMORY if memory allocation failed
423 * CLASS_E_NOAGGREGATION if UnkOuter != NULL
425 *****************************************************************************/
426 static HRESULT WINAPI
427 IDirect3DImpl_3_CreateLight(IDirect3D3 *iface,
428 IDirect3DLight **Light,
431 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
432 IDirect3DLightImpl *object;
434 TRACE("(%p)->(%p,%p)\n", This, Light, UnkOuter);
437 return CLASS_E_NOAGGREGATION;
439 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DLightImpl));
441 return DDERR_OUTOFMEMORY;
443 ICOM_INIT_INTERFACE(object, IDirect3DLight, IDirect3DLight_Vtbl);
445 object->ddraw = This;
447 object->active_viewport = NULL;
449 /* Update functions */
450 object->activate = light_update;
451 object->desactivate = light_activate;
452 object->update = light_desactivate;
453 object->active_viewport = NULL;
455 *Light = ICOM_INTERFACE(object, IDirect3DLight);
457 TRACE("(%p) creating implementation at %p.\n", This, object);
462 static HRESULT WINAPI
463 Thunk_IDirect3DImpl_2_CreateLight(IDirect3D2 *iface,
464 IDirect3DLight **Direct3DLight,
467 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
468 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, Direct3DLight, UnkOuter);
469 return IDirect3D3_CreateLight(ICOM_INTERFACE(This, IDirect3D3),
474 static HRESULT WINAPI
475 Thunk_IDirect3DImpl_1_CreateLight(IDirect3D *iface,
476 IDirect3DLight **Direct3DLight,
479 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
480 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, Direct3DLight, UnkOuter);
481 return IDirect3D3_CreateLight(ICOM_INTERFACE(This, IDirect3D3),
486 /*****************************************************************************
487 * IDirect3D3::CreateMaterial
489 * Creates an IDirect3DMaterial interface. This interface is used by Direct3D3
490 * and older versions. The IDirect3DMaterial implementation wraps its
491 * functionality to IDirect3DDevice7::SetMaterial and friends.
496 * Material: Address to store the new interface's pointer to
497 * UnkOuter: Basically for aggregation, but ddraw doesn't support it.
502 * DDERR_OUTOFMEMORY if memory allocation failed
503 * CLASS_E_NOAGGREGATION if UnkOuter != NULL
505 *****************************************************************************/
506 static HRESULT WINAPI
507 IDirect3DImpl_3_CreateMaterial(IDirect3D3 *iface,
508 IDirect3DMaterial3 **Material,
511 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
512 IDirect3DMaterialImpl *object;
514 TRACE("(%p)->(%p,%p)\n", This, Material, UnkOuter);
517 return CLASS_E_NOAGGREGATION;
519 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DMaterialImpl));
521 return DDERR_OUTOFMEMORY;
523 ICOM_INIT_INTERFACE(object, IDirect3DMaterial3, IDirect3DMaterial3_Vtbl);
524 ICOM_INIT_INTERFACE(object, IDirect3DMaterial2, IDirect3DMaterial2_Vtbl);
525 ICOM_INIT_INTERFACE(object, IDirect3DMaterial, IDirect3DMaterial_Vtbl);
527 object->ddraw = This;
528 object->activate = material_activate;
530 *Material = ICOM_INTERFACE(object, IDirect3DMaterial3);
532 TRACE("(%p) creating implementation at %p.\n", This, object);
537 static HRESULT WINAPI
538 Thunk_IDirect3DImpl_2_CreateMaterial(IDirect3D2 *iface,
539 IDirect3DMaterial2 **Direct3DMaterial,
542 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
544 IDirect3DMaterial3 *ret_val;
546 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, Direct3DMaterial, UnkOuter);
547 ret = IDirect3D3_CreateMaterial(ICOM_INTERFACE(This, IDirect3D3),
551 *Direct3DMaterial = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial2, ret_val);
553 TRACE(" returning interface %p.\n", *Direct3DMaterial);
558 static HRESULT WINAPI
559 Thunk_IDirect3DImpl_1_CreateMaterial(IDirect3D *iface,
560 IDirect3DMaterial **Direct3DMaterial,
563 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
565 LPDIRECT3DMATERIAL3 ret_val;
567 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, Direct3DMaterial, UnkOuter);
568 ret = IDirect3D3_CreateMaterial(ICOM_INTERFACE(This, IDirect3D3),
572 *Direct3DMaterial = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial, ret_val);
574 TRACE(" returning interface %p.\n", *Direct3DMaterial);
579 /*****************************************************************************
580 * IDirect3D3::CreateViewport
582 * Creates an IDirect3DViewport interface. This interface is used
583 * by Direct3D and earlier versions for Viewport management. In Direct3D7
584 * it has been replaced by a viewport structure and
585 * IDirect3DDevice7::*Viewport. Wine's IDirect3DViewport implementation
586 * uses the IDirect3DDevice7 methods for its functionality
589 * Viewport: Address to store the new interface pointer
590 * UnkOuter: Basically for aggregation, but ddraw doesn't support it.
595 * DDERR_OUTOFMEMORY if memory allocation failed
596 * CLASS_E_NOAGGREGATION if UnkOuter != NULL
598 *****************************************************************************/
599 static HRESULT WINAPI
600 IDirect3DImpl_3_CreateViewport(IDirect3D3 *iface,
601 IDirect3DViewport3 **Viewport,
604 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
605 IDirect3DViewportImpl *object;
608 return CLASS_E_NOAGGREGATION;
610 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DViewportImpl));
612 return DDERR_OUTOFMEMORY;
614 ICOM_INIT_INTERFACE(object, IDirect3DViewport3, IDirect3DViewport3_Vtbl);
616 object->ddraw = This;
617 object->activate = viewport_activate;
618 object->use_vp2 = 0xFF;
620 object->lights = NULL;
621 object->num_lights = 0;
622 object->map_lights = 0;
624 *Viewport = ICOM_INTERFACE(object, IDirect3DViewport3);
626 TRACE("(%p) creating implementation at %p.\n",This, object);
631 static HRESULT WINAPI
632 Thunk_IDirect3DImpl_2_CreateViewport(IDirect3D2 *iface,
633 IDirect3DViewport2 **D3DViewport2,
636 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
637 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, D3DViewport2, UnkOuter);
639 return IDirect3D3_CreateViewport(ICOM_INTERFACE(This, IDirect3D3),
640 (IDirect3DViewport3 **) D3DViewport2 /* No need to cast here */,
644 static HRESULT WINAPI
645 Thunk_IDirect3DImpl_1_CreateViewport(IDirect3D *iface,
646 IDirect3DViewport **D3DViewport,
649 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
650 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, D3DViewport, UnkOuter);
652 return IDirect3D3_CreateViewport(ICOM_INTERFACE(This, IDirect3D3),
653 (IDirect3DViewport3 **) D3DViewport /* No need to cast here */,
657 /*****************************************************************************
658 * IDirect3D3::FindDevice
660 * This method finds a device with the requested properties and returns a
665 * D3DDFS: Describes the requested device characteristics
666 * D3DFDR: Returns the device description
670 * DDERR_INVALIDPARAMS if no device was found
672 *****************************************************************************/
673 static HRESULT WINAPI
674 IDirect3DImpl_3_FindDevice(IDirect3D3 *iface,
675 D3DFINDDEVICESEARCH *D3DDFS,
676 D3DFINDDEVICERESULT *D3DFDR)
678 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
680 D3DDEVICEDESC7 newDesc;
683 TRACE("(%p)->(%p,%p)\n", This, D3DDFS, D3DFDR);
685 if ((D3DDFS->dwFlags & D3DFDS_COLORMODEL) &&
686 (D3DDFS->dcmColorModel != D3DCOLOR_RGB))
688 TRACE(" trying to request a non-RGB D3D color model. Not supported.\n");
689 return DDERR_INVALIDPARAMS; /* No real idea what to return here :-) */
691 if (D3DDFS->dwFlags & D3DFDS_GUID)
693 TRACE(" trying to match guid %s.\n", debugstr_guid(&(D3DDFS->guid)));
694 if ((IsEqualGUID(&IID_D3DDEVICE_WineD3D, &(D3DDFS->guid)) == 0) &&
695 (IsEqualGUID(&IID_IDirect3DHALDevice, &(D3DDFS->guid)) == 0) &&
696 (IsEqualGUID(&IID_IDirect3DRefDevice, &(D3DDFS->guid)) == 0))
698 TRACE(" no match for this GUID.\n");
699 return DDERR_INVALIDPARAMS;
704 hr = IDirect3DImpl_GetCaps(This->wineD3D, &desc, &newDesc);
705 if(hr != D3D_OK) return hr;
707 /* Now return our own GUID */
708 D3DFDR->guid = IID_D3DDEVICE_WineD3D;
709 D3DFDR->ddHwDesc = desc;
710 D3DFDR->ddSwDesc = desc;
712 TRACE(" returning Wine's WineD3D device with (undumped) capabilities\n");
717 static HRESULT WINAPI
718 Thunk_IDirect3DImpl_2_FindDevice(IDirect3D2 *iface,
719 D3DFINDDEVICESEARCH *D3DDFS,
720 D3DFINDDEVICERESULT *D3DFDR)
722 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
723 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, D3DDFS, D3DFDR);
724 return IDirect3D3_FindDevice(ICOM_INTERFACE(This, IDirect3D3),
729 static HRESULT WINAPI
730 Thunk_IDirect3DImpl_1_FindDevice(IDirect3D *iface,
731 D3DFINDDEVICESEARCH *D3DDFS,
732 D3DFINDDEVICERESULT *D3DDevice)
734 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
735 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", This, D3DDFS, D3DDevice);
736 return IDirect3D3_FindDevice(ICOM_INTERFACE(This, IDirect3D3),
741 /*****************************************************************************
742 * IDirect3D7::CreateDevice
744 * Creates an IDirect3DDevice7 interface.
746 * Version 2, 3 and 7. IDirect3DDevice 1 interfaces are interfaces to
747 * DirectDraw surfaces and are created with
748 * IDirectDrawSurface::QueryInterface. This method uses CreateDevice to
749 * create the device object and QueryInterfaces for IDirect3DDevice
752 * refiid: IID of the device to create
753 * Surface: Inititial rendertarget
754 * Device: Address to return the interface pointer
758 * DDERR_OUTOFMEMORY if memory allocation failed
759 * DDERR_INVALIDPARAMS if a device exists already
761 *****************************************************************************/
762 static HRESULT WINAPI
763 IDirect3DImpl_7_CreateDevice(IDirect3D7 *iface,
765 IDirectDrawSurface7 *Surface,
766 IDirect3DDevice7 **Device)
768 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
769 IDirect3DDeviceImpl *object;
770 IParentImpl *IndexBufferParent;
772 IDirectDrawSurfaceImpl *target = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, Surface);
773 TRACE("(%p)->(%s,%p,%p)\n", iface, debugstr_guid(refiid), Surface, Device);
775 EnterCriticalSection(&ddraw_cs);
778 /* Fail device creation if non-opengl surfaces are used */
779 if(This->ImplType != SURFACE_OPENGL)
781 ERR("The application wants to create a Direct3D device, but non-opengl surfaces are set in the registry. Please set the surface implementation to opengl or autodetection to allow 3D rendering\n");
783 /* We only hit this path if a default surface is set in the registry. Incorrect autodetection
784 * is caught in CreateSurface or QueryInterface
786 LeaveCriticalSection(&ddraw_cs);
790 /* So far we can only create one device per ddraw object */
793 FIXME("(%p): Only one Direct3D device per DirectDraw object supported\n", This);
794 LeaveCriticalSection(&ddraw_cs);
795 return DDERR_INVALIDPARAMS;
798 object = HeapAlloc(GetProcessHeap(), 0, sizeof(IDirect3DDeviceImpl));
801 ERR("Out of memory when allocating a IDirect3DDevice implementation\n");
802 LeaveCriticalSection(&ddraw_cs);
803 return DDERR_OUTOFMEMORY;
806 ICOM_INIT_INTERFACE(object, IDirect3DDevice7, IDirect3DDevice7_Vtbl);
807 ICOM_INIT_INTERFACE(object, IDirect3DDevice3, IDirect3DDevice3_Vtbl);
808 ICOM_INIT_INTERFACE(object, IDirect3DDevice2, IDirect3DDevice2_Vtbl);
809 ICOM_INIT_INTERFACE(object, IDirect3DDevice, IDirect3DDevice1_Vtbl);
812 object->ddraw = This;
813 object->viewport_list = NULL;
814 object->current_viewport = NULL;
815 object->material = 0;
816 object->target = target;
818 object->Handles = NULL;
819 object->numHandles = 0;
821 /* This is for convenience */
822 object->wineD3DDevice = This->wineD3DDevice;
824 /* Create an index buffer, it's needed for indexed drawing */
825 IndexBufferParent = HeapAlloc(GetProcessHeap(), 0, sizeof(IParentImpl *));
826 if(!IndexBufferParent)
828 ERR("Allocating memory for an index buffer parent failed\n");
829 HeapFree(GetProcessHeap(), 0, object);
830 LeaveCriticalSection(&ddraw_cs);
831 return DDERR_OUTOFMEMORY;
833 ICOM_INIT_INTERFACE(IndexBufferParent, IParent, IParent_Vtbl);
834 IndexBufferParent->ref = 1;
836 /* Create an Index Buffer. WineD3D needs one for Drawing indexed primitives
837 * Create a (hopefully) long enough buffer, and copy the indices into it
838 * Ideally, a IWineD3DIndexBuffer::SetData method could be created, which
839 * takes the pointer and avoids the memcpy
841 hr = IWineD3DDevice_CreateIndexBuffer(This->wineD3DDevice,
842 0x40000, /* Length. Don't know how long it should be */
843 WINED3DUSAGE_DYNAMIC, /* Usage */
844 WINED3DFMT_INDEX16, /* Format. D3D7 uses WORDS */
846 &object->indexbuffer,
848 (IUnknown *) ICOM_INTERFACE(IndexBufferParent, IParent));
852 ERR("Failed to create an index buffer\n");
853 HeapFree(GetProcessHeap(), 0, object);
854 LeaveCriticalSection(&ddraw_cs);
857 IndexBufferParent->child = (IUnknown *) object->indexbuffer;
859 /* No need to set the indices, it's done when necessary */
861 /* AddRef the WineD3D Device */
862 IWineD3DDevice_AddRef(This->wineD3DDevice);
864 /* Don't forget to return the interface ;) */
865 *Device = ICOM_INTERFACE(object, IDirect3DDevice7);
867 TRACE(" (%p) Created an IDirect3DDeviceImpl object at %p\n", This, object);
869 /* This is for apps which create a non-flip, non-d3d primary surface
870 * and an offscreen D3DDEVICE surface, then render to the offscreen surface
871 * and do a Blt from the offscreen to the primary surface.
873 * Set the offscreen D3DDDEVICE surface(=target) as the back buffer,
874 * and the primary surface(=This->d3d_target) as the front buffer.
876 * This way the app will render to the D3DDEVICE surface and WineD3D
877 * will catch the Blt was Back Buffer -> Front buffer blt and perform
878 * a flip instead. This way we don't have to deal with a mixed GL / GDI
881 * This should be checked against windowed apps. The only app tested with
882 * this is moto racer 2 during the loading screen.
884 TRACE("Isrendertarget: %s, d3d_target=%p\n", target->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE ? "true" : "false", This->d3d_target);
885 if(!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
886 (This->d3d_target != target))
889 TRACE("(%p) Using %p as front buffer, %p as back buffer\n", This, This->d3d_target, target);
890 hr = IWineD3DDevice_SetFrontBackBuffers(This->wineD3DDevice,
891 This->d3d_target->WineD3DSurface,
892 target->WineD3DSurface);
894 ERR("(%p) Error %08x setting the front and back buffer\n", This, hr);
896 /* Render to the back buffer */
897 IWineD3DDevice_SetRenderTarget(This->wineD3DDevice, 0,
898 target->WineD3DSurface);
902 vp.Width = target->surface_desc.dwWidth;
903 vp.Height = target->surface_desc.dwHeight;
906 IWineD3DDevice_SetViewport(This->wineD3DDevice,
909 object->OffScreenTarget = TRUE;
913 object->OffScreenTarget = FALSE;
916 /* AddRef the render target. Also AddRef the render target from ddraw,
917 * because if it is released before the app releases the D3D device, the D3D capabilities
918 * of WineD3D will be uninitialized, which has bad effects.
920 * In most cases, those surfaces are the surfaces are the same anyway, but this will simply
921 * add another ref which is released when the device is destroyed.
923 IDirectDrawSurface7_AddRef(Surface);
924 IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This->d3d_target, IDirectDrawSurface7));
926 This->d3ddevice = object;
928 IWineD3DDevice_SetRenderState(This->wineD3DDevice,
930 IDirect3DDeviceImpl_UpdateDepthStencil(object));
931 LeaveCriticalSection(&ddraw_cs);
935 static HRESULT WINAPI
936 Thunk_IDirect3DImpl_3_CreateDevice(IDirect3D3 *iface,
938 IDirectDrawSurface4 *Surface,
939 IDirect3DDevice3 **Device,
942 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
944 TRACE("(%p)->(%s,%p,%p,%p): Thunking to IDirect3D7\n", This, debugstr_guid(refiid), Surface, Device, UnkOuter);
947 return CLASS_E_NOAGGREGATION;
949 hr = IDirect3D7_CreateDevice(ICOM_INTERFACE(This, IDirect3D7),
951 (IDirectDrawSurface7 *) Surface /* Same VTables */,
952 (IDirect3DDevice7 **) Device);
954 *Device = COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice7, IDirect3DDevice3, *Device);
958 static HRESULT WINAPI
959 Thunk_IDirect3DImpl_2_CreateDevice(IDirect3D2 *iface,
961 IDirectDrawSurface *Surface,
962 IDirect3DDevice2 **Device)
964 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
966 TRACE("(%p)->(%s,%p,%p): Thunking to IDirect3D7\n", This, debugstr_guid(refiid), Surface, Device);
968 hr = IDirect3D7_CreateDevice(ICOM_INTERFACE(This, IDirect3D7),
970 COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface3, IDirectDrawSurface7, Surface),
971 (IDirect3DDevice7 **) Device);
973 *Device = COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice7, IDirect3DDevice2, *Device);
977 /*****************************************************************************
978 * IDirect3D7::CreateVertexBuffer
980 * Creates a new vertex buffer object and returns a IDirect3DVertexBuffer7
986 * Desc: Requested Vertex buffer properties
987 * VertexBuffer: Address to return the interface pointer at
988 * Flags: Some flags, must be 0
992 * DDERR_OUTOFMEMORY if memory allocation failed
993 * The return value of IWineD3DDevice::CreateVertexBuffer if this call fails
994 * DDERR_INVALIDPARAMS if Desc or VertexBuffer are NULL, or Flags != 0
996 *****************************************************************************/
997 static HRESULT WINAPI
998 IDirect3DImpl_7_CreateVertexBuffer(IDirect3D7 *iface,
999 D3DVERTEXBUFFERDESC *Desc,
1000 IDirect3DVertexBuffer7 **VertexBuffer,
1003 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
1004 IDirect3DVertexBufferImpl *object;
1006 TRACE("(%p)->(%p,%p,%08x)\n", This, Desc, VertexBuffer, Flags);
1008 TRACE("(%p) Vertex buffer description:\n", This);
1009 TRACE("(%p) dwSize=%d\n", This, Desc->dwSize);
1010 TRACE("(%p) dwCaps=%08x\n", This, Desc->dwCaps);
1011 TRACE("(%p) FVF=%08x\n", This, Desc->dwFVF);
1012 TRACE("(%p) dwNumVertices=%d\n", This, Desc->dwNumVertices);
1014 /* D3D7 SDK: "No Flags are currently defined for this method. This
1015 * parameter must be 0"
1017 * Never trust the documentation - this is wrong
1020 ERR("(%p) Flags is %08lx, returning DDERR_INVALIDPARAMS\n", This, Flags);
1021 return DDERR_INVALIDPARAMS;
1025 /* Well, this sounds sane */
1026 if( (!VertexBuffer) || (!Desc) )
1027 return DDERR_INVALIDPARAMS;
1029 /* Now create the vertex buffer */
1030 object = HeapAlloc(GetProcessHeap(), 0, sizeof(IDirect3DVertexBufferImpl));
1033 ERR("(%p) Out of memory when allocating a IDirect3DVertexBufferImpl structure\n", This);
1034 return DDERR_OUTOFMEMORY;
1038 ICOM_INIT_INTERFACE(object, IDirect3DVertexBuffer7, IDirect3DVertexBuffer7_Vtbl);
1039 ICOM_INIT_INTERFACE(object, IDirect3DVertexBuffer, IDirect3DVertexBuffer1_Vtbl);
1041 object->Caps = Desc->dwCaps;
1042 object->ddraw = This;
1044 EnterCriticalSection(&ddraw_cs);
1045 hr = IWineD3DDevice_CreateVertexBuffer(This->wineD3DDevice,
1046 get_flexible_vertex_size(Desc->dwFVF) * Desc->dwNumVertices,
1047 Desc->dwCaps & D3DVBCAPS_WRITEONLY ? WINED3DUSAGE_WRITEONLY : 0,
1049 Desc->dwCaps & D3DVBCAPS_SYSTEMMEMORY ? WINED3DPOOL_SYSTEMMEM : WINED3DPOOL_DEFAULT,
1050 &object->wineD3DVertexBuffer,
1051 0 /* SharedHandle */,
1052 (IUnknown *) ICOM_INTERFACE(object, IDirect3DVertexBuffer7));
1055 ERR("(%p) IWineD3DDevice::CreateVertexBuffer failed with hr=%08x\n", This, hr);
1056 HeapFree(GetProcessHeap(), 0, object);
1057 LeaveCriticalSection(&ddraw_cs);
1058 if (hr == WINED3DERR_INVALIDCALL)
1059 return DDERR_INVALIDPARAMS;
1064 object->wineD3DVertexDeclaration = IDirectDrawImpl_FindDecl(This,
1066 if(!object->wineD3DVertexDeclaration)
1068 ERR("Cannot find the vertex declaration for fvf %08x\n", Desc->dwFVF);
1069 IWineD3DVertexBuffer_Release(object->wineD3DVertexBuffer);
1070 HeapFree(GetProcessHeap(), 0, object);
1071 LeaveCriticalSection(&ddraw_cs);
1072 return DDERR_INVALIDPARAMS;
1074 IWineD3DVertexDeclaration_AddRef(object->wineD3DVertexDeclaration);
1076 /* Return the interface */
1077 *VertexBuffer = ICOM_INTERFACE(object, IDirect3DVertexBuffer7);
1079 TRACE("(%p) Created new vertex buffer implementation at %p, returning interface at %p\n", This, object, *VertexBuffer);
1080 LeaveCriticalSection(&ddraw_cs);
1084 static HRESULT WINAPI
1085 Thunk_IDirect3DImpl_3_CreateVertexBuffer(IDirect3D3 *iface,
1086 D3DVERTEXBUFFERDESC *Desc,
1087 IDirect3DVertexBuffer **VertexBuffer,
1091 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
1093 TRACE("(%p)->(%p,%p,%08x,%p): Relaying to IDirect3D7\n", This, Desc, VertexBuffer, Flags, UnkOuter);
1095 if(UnkOuter != NULL) return CLASS_E_NOAGGREGATION;
1097 hr = IDirect3D7_CreateVertexBuffer(ICOM_INTERFACE(This, IDirect3D7),
1099 (IDirect3DVertexBuffer7 **) VertexBuffer,
1102 *VertexBuffer = COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, IDirect3DVertexBuffer, *VertexBuffer);
1107 /*****************************************************************************
1108 * IDirect3D7::EnumZBufferFormats
1110 * Enumerates all supported Z buffer pixel formats
1116 * Callback: Callback to call for each pixel format
1117 * Context: Pointer to pass back to the callback
1121 * DDERR_INVALIDPARAMS if Callback is NULL
1122 * For details, see IWineD3DDevice::EnumZBufferFormats
1124 *****************************************************************************/
1125 static HRESULT WINAPI
1126 IDirect3DImpl_7_EnumZBufferFormats(IDirect3D7 *iface,
1127 REFCLSID refiidDevice,
1128 LPD3DENUMPIXELFORMATSCALLBACK Callback,
1131 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
1135 /* Order matters. Specifically, BattleZone II (full version) expects the
1136 * 16-bit depth formats to be listed before the 24 and 32 ones. */
1137 WINED3DFORMAT FormatList[] = {
1146 TRACE("(%p)->(%s,%p,%p): Relay\n", iface, debugstr_guid(refiidDevice), Callback, Context);
1149 return DDERR_INVALIDPARAMS;
1151 EnterCriticalSection(&ddraw_cs);
1152 for(i = 0; i < sizeof(FormatList) / sizeof(WINED3DFORMAT); i++)
1154 hr = IWineD3D_CheckDeviceFormat(This->wineD3D,
1157 0 /* AdapterFormat */,
1158 WINED3DUSAGE_DEPTHSTENCIL /* Usage */,
1159 0 /* ResourceType */,
1163 DDPIXELFORMAT pformat;
1165 memset(&pformat, 0, sizeof(pformat));
1166 pformat.dwSize = sizeof(pformat);
1167 PixelFormat_WineD3DtoDD(&pformat, FormatList[i]);
1169 TRACE("Enumerating WineD3DFormat %d\n", FormatList[i]);
1170 hr = Callback(&pformat, Context);
1171 if(hr != DDENUMRET_OK)
1173 TRACE("Format enumeration cancelled by application\n");
1174 LeaveCriticalSection(&ddraw_cs);
1179 TRACE("End of enumeration\n");
1180 LeaveCriticalSection(&ddraw_cs);
1184 static HRESULT WINAPI
1185 Thunk_IDirect3DImpl_3_EnumZBufferFormats(IDirect3D3 *iface,
1186 REFCLSID riidDevice,
1187 LPD3DENUMPIXELFORMATSCALLBACK Callback,
1190 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
1191 TRACE("(%p)->(%s,%p,%p) thunking to IDirect3D7 interface.\n", This, debugstr_guid(riidDevice), Callback, Context);
1192 return IDirect3D7_EnumZBufferFormats(ICOM_INTERFACE(This, IDirect3D7),
1198 /*****************************************************************************
1199 * IDirect3D7::EvictManagedTextures
1201 * Removes all managed textures (=surfaces with DDSCAPS2_TEXTUREMANAGE or
1202 * DDSCAPS2_D3DTEXTUREMANAGE caps) to be removed from video memory.
1207 * D3D_OK, because it's a stub
1209 *****************************************************************************/
1210 static HRESULT WINAPI
1211 IDirect3DImpl_7_EvictManagedTextures(IDirect3D7 *iface)
1213 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
1214 FIXME("(%p): Stub!\n", This);
1216 /* Implementation idea:
1217 * Add an IWineD3DSurface method which sets the opengl texture
1218 * priority low or even removes the opengl texture.
1224 static HRESULT WINAPI
1225 Thunk_IDirect3DImpl_3_EvictManagedTextures(IDirect3D3 *iface)
1227 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
1228 TRACE("(%p)->() thunking to IDirect3D7 interface.\n", This);
1229 return IDirect3D7_EvictManagedTextures(ICOM_INTERFACE(This, IDirect3D7));
1232 /*****************************************************************************
1233 * IDirect3DImpl_GetCaps
1235 * This function retrieves the device caps from wined3d
1236 * and converts it into a D3D7 and D3D - D3D3 structure
1237 * This is a helper function called from various places in ddraw
1240 * WineD3D: The interface to get the caps from
1241 * Desc123: Old D3D <3 structure to fill (needed)
1242 * Desc7: D3D7 device desc structure to fill (needed)
1245 * D3D_OK on success, or the return value of IWineD3D::GetCaps
1247 *****************************************************************************/
1249 IDirect3DImpl_GetCaps(IWineD3D *WineD3D,
1250 D3DDEVICEDESC *Desc123,
1251 D3DDEVICEDESC7 *Desc7)
1256 /* Some Variables to asign to the pointers in WCaps */
1257 WINED3DDEVTYPE DevType;
1260 DWORD dummy_dword, MaxTextureBlendStages, MaxSimultaneousTextures;
1261 DWORD MaxUserClipPlanes, MaxVertexBlendMatrices;
1263 TRACE("()->(%p,%p,%p\n", WineD3D, Desc123, Desc7);
1265 /* Asign the pointers in WCaps */
1266 WCaps.DeviceType = &DevType;
1267 WCaps.AdapterOrdinal = &dummy_uint;
1269 WCaps.Caps = &dummy_dword;
1270 WCaps.Caps2 = &dummy_dword;
1271 WCaps.Caps3 = &dummy_dword;
1272 WCaps.PresentationIntervals = &dummy_dword;
1274 WCaps.CursorCaps = &dummy_dword;
1276 WCaps.DevCaps = &Desc7->dwDevCaps;
1277 WCaps.PrimitiveMiscCaps = &dummy_dword;
1278 WCaps.RasterCaps = &Desc7->dpcLineCaps.dwRasterCaps;
1279 WCaps.ZCmpCaps = &Desc7->dpcLineCaps.dwZCmpCaps;
1280 WCaps.SrcBlendCaps = &Desc7->dpcLineCaps.dwSrcBlendCaps;
1281 WCaps.DestBlendCaps = &Desc7->dpcLineCaps.dwDestBlendCaps;
1282 WCaps.AlphaCmpCaps = &Desc7->dpcLineCaps.dwAlphaCmpCaps;
1283 WCaps.ShadeCaps = &Desc7->dpcLineCaps.dwShadeCaps;
1284 WCaps.TextureCaps = &Desc7->dpcLineCaps.dwTextureCaps;
1285 WCaps.TextureFilterCaps = &Desc7->dpcLineCaps.dwTextureFilterCaps;
1286 WCaps.CubeTextureFilterCaps = &dummy_dword;
1287 WCaps.VolumeTextureFilterCaps = &dummy_dword;
1288 WCaps.TextureAddressCaps = &Desc7->dpcLineCaps.dwTextureAddressCaps;
1289 WCaps.VolumeTextureAddressCaps = &dummy_dword;
1291 WCaps.LineCaps = &dummy_dword;
1292 WCaps.MaxTextureWidth = &Desc7->dwMaxTextureWidth;
1293 WCaps.MaxTextureHeight = &Desc7->dwMaxTextureHeight;
1294 WCaps.MaxVolumeExtent = &dummy_dword;
1296 WCaps.MaxTextureRepeat = &Desc7->dwMaxTextureRepeat;
1297 WCaps.MaxTextureAspectRatio = &Desc7->dwMaxTextureAspectRatio;
1298 WCaps.MaxAnisotropy = &Desc7->dwMaxAnisotropy;
1299 WCaps.MaxVertexW = &Desc7->dvMaxVertexW;
1301 WCaps.GuardBandLeft = &Desc7->dvGuardBandLeft;
1302 WCaps.GuardBandTop = &Desc7->dvGuardBandTop;
1303 WCaps.GuardBandRight = &Desc7->dvGuardBandRight;
1304 WCaps.GuardBandBottom = &Desc7->dvGuardBandBottom;
1306 WCaps.ExtentsAdjust = &Desc7->dvExtentsAdjust;
1307 WCaps.StencilCaps = &Desc7->dwStencilCaps;
1309 WCaps.FVFCaps = &Desc7->dwFVFCaps;
1310 WCaps.TextureOpCaps = &Desc7->dwTextureOpCaps;
1311 WCaps.MaxTextureBlendStages = &MaxTextureBlendStages;
1312 WCaps.MaxSimultaneousTextures = &MaxSimultaneousTextures;
1314 WCaps.VertexProcessingCaps = &Desc7->dwVertexProcessingCaps;
1315 WCaps.MaxActiveLights = &Desc7->dwMaxActiveLights;
1316 WCaps.MaxUserClipPlanes = &MaxUserClipPlanes;
1317 WCaps.MaxVertexBlendMatrices = &MaxVertexBlendMatrices;
1318 WCaps.MaxVertexBlendMatrixIndex = &dummy_dword;
1320 WCaps.MaxPointSize = &dummy_float;
1321 WCaps.MaxPrimitiveCount = &dummy_dword;
1322 WCaps.MaxVertexIndex = &dummy_dword;
1323 WCaps.MaxStreams = &dummy_dword;
1324 WCaps.MaxStreamStride = &dummy_dword;
1326 WCaps.VertexShaderVersion = &dummy_dword;
1327 WCaps.MaxVertexShaderConst = &dummy_dword;
1329 WCaps.PixelShaderVersion = &dummy_dword;
1330 WCaps.PixelShader1xMaxValue = &dummy_float;
1332 /* These are dx9 only, set them to NULL */
1333 WCaps.DevCaps2 = NULL;
1334 WCaps.MaxNpatchTessellationLevel = NULL;
1335 WCaps.Reserved5 = NULL;
1336 WCaps.MasterAdapterOrdinal = NULL;
1337 WCaps.AdapterOrdinalInGroup = NULL;
1338 WCaps.NumberOfAdaptersInGroup = NULL;
1339 WCaps.DeclTypes = NULL;
1340 WCaps.NumSimultaneousRTs = NULL;
1341 WCaps.StretchRectFilterCaps = NULL;
1342 /* WCaps.VS20Caps = NULL; */
1343 /* WCaps.PS20Caps = NULL; */
1344 WCaps.VertexTextureFilterCaps = NULL;
1345 WCaps.MaxVShaderInstructionsExecuted = NULL;
1346 WCaps.MaxPShaderInstructionsExecuted = NULL;
1347 WCaps.MaxVertexShader30InstructionSlots = NULL;
1348 WCaps.MaxPixelShader30InstructionSlots = NULL;
1349 WCaps.Reserved2 = NULL;
1350 WCaps.Reserved3 = NULL;
1352 /* Now get the caps */
1353 EnterCriticalSection(&ddraw_cs);
1354 hr = IWineD3D_GetDeviceCaps(WineD3D, 0, WINED3DDEVTYPE_HAL, &WCaps);
1355 LeaveCriticalSection(&ddraw_cs);
1361 /* Remove all non-d3d7 caps */
1362 Desc7->dwDevCaps &= (
1363 D3DDEVCAPS_FLOATTLVERTEX | D3DDEVCAPS_SORTINCREASINGZ | D3DDEVCAPS_SORTDECREASINGZ |
1364 D3DDEVCAPS_SORTEXACT | D3DDEVCAPS_EXECUTESYSTEMMEMORY | D3DDEVCAPS_EXECUTEVIDEOMEMORY |
1365 D3DDEVCAPS_TLVERTEXSYSTEMMEMORY | D3DDEVCAPS_TLVERTEXVIDEOMEMORY | D3DDEVCAPS_TEXTURESYSTEMMEMORY |
1366 D3DDEVCAPS_TEXTUREVIDEOMEMORY | D3DDEVCAPS_DRAWPRIMTLVERTEX | D3DDEVCAPS_CANRENDERAFTERFLIP |
1367 D3DDEVCAPS_TEXTURENONLOCALVIDMEM | D3DDEVCAPS_DRAWPRIMITIVES2 | D3DDEVCAPS_SEPARATETEXTUREMEMORIES |
1368 D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWTRANSFORMANDLIGHT | D3DDEVCAPS_CANBLTSYSTONONLOCAL |
1369 D3DDEVCAPS_HWRASTERIZATION);
1371 Desc7->dwStencilCaps &= (
1372 D3DSTENCILCAPS_KEEP | D3DSTENCILCAPS_ZERO | D3DSTENCILCAPS_REPLACE |
1373 D3DSTENCILCAPS_INCRSAT | D3DSTENCILCAPS_DECRSAT | D3DSTENCILCAPS_INVERT |
1374 D3DSTENCILCAPS_INCR | D3DSTENCILCAPS_DECR | D3DSTENCILCAPS_TWOSIDED);
1378 Desc7->dwTextureOpCaps &= (
1379 D3DTEXOPCAPS_DISABLE | D3DTEXOPCAPS_SELECTARG1 | D3DTEXOPCAPS_SELECTARG2 |
1380 D3DTEXOPCAPS_MODULATE | D3DTEXOPCAPS_MODULATE2X | D3DTEXOPCAPS_MODULATE4X |
1381 D3DTEXOPCAPS_ADD | D3DTEXOPCAPS_ADDSIGNED | D3DTEXOPCAPS_ADDSIGNED2X |
1382 D3DTEXOPCAPS_SUBTRACT | D3DTEXOPCAPS_ADDSMOOTH | D3DTEXOPCAPS_BLENDTEXTUREALPHA |
1383 D3DTEXOPCAPS_BLENDFACTORALPHA | D3DTEXOPCAPS_BLENDTEXTUREALPHAPM | D3DTEXOPCAPS_BLENDCURRENTALPHA |
1384 D3DTEXOPCAPS_PREMODULATE | D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR | D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
1385 D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR | D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA | D3DTEXOPCAPS_BUMPENVMAP |
1386 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE | D3DTEXOPCAPS_DOTPRODUCT3);
1388 Desc7->dwVertexProcessingCaps &= (
1389 D3DVTXPCAPS_TEXGEN | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_VERTEXFOG |
1390 D3DVTXPCAPS_DIRECTIONALLIGHTS | D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_LOCALVIEWER);
1392 Desc7->dpcLineCaps.dwMiscCaps &= (
1393 D3DPMISCCAPS_MASKPLANES | D3DPMISCCAPS_MASKZ | D3DPMISCCAPS_LINEPATTERNREP |
1394 D3DPMISCCAPS_CONFORMANT | D3DPMISCCAPS_CULLNONE | D3DPMISCCAPS_CULLCW |
1395 D3DPMISCCAPS_CULLCCW);
1397 Desc7->dpcLineCaps.dwRasterCaps &= (
1398 D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_ROP2 | D3DPRASTERCAPS_XOR |
1399 D3DPRASTERCAPS_PAT | D3DPRASTERCAPS_ZTEST | D3DPRASTERCAPS_SUBPIXEL |
1400 D3DPRASTERCAPS_SUBPIXELX | D3DPRASTERCAPS_FOGVERTEX | D3DPRASTERCAPS_FOGTABLE |
1401 D3DPRASTERCAPS_STIPPLE | D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT | D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT |
1402 D3DPRASTERCAPS_ANTIALIASEDGES | D3DPRASTERCAPS_MIPMAPLODBIAS | D3DPRASTERCAPS_ZBIAS |
1403 D3DPRASTERCAPS_ZBUFFERLESSHSR | D3DPRASTERCAPS_FOGRANGE | D3DPRASTERCAPS_ANISOTROPY |
1404 D3DPRASTERCAPS_WBUFFER | D3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT | D3DPRASTERCAPS_WFOG |
1405 D3DPRASTERCAPS_ZFOG);
1407 Desc7->dpcLineCaps.dwZCmpCaps &= (
1408 D3DPCMPCAPS_NEVER | D3DPCMPCAPS_LESS | D3DPCMPCAPS_EQUAL |
1409 D3DPCMPCAPS_LESSEQUAL | D3DPCMPCAPS_GREATER | D3DPCMPCAPS_NOTEQUAL |
1410 D3DPCMPCAPS_GREATEREQUAL | D3DPCMPCAPS_ALWAYS);
1412 Desc7->dpcLineCaps.dwSrcBlendCaps &= (
1413 D3DPBLENDCAPS_ZERO | D3DPBLENDCAPS_ONE | D3DPBLENDCAPS_SRCCOLOR |
1414 D3DPBLENDCAPS_INVSRCCOLOR | D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA |
1415 D3DPBLENDCAPS_DESTALPHA | D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR |
1416 D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA |
1417 D3DPBLENDCAPS_BOTHINVSRCALPHA);
1419 Desc7->dpcLineCaps.dwDestBlendCaps &= (
1420 D3DPBLENDCAPS_ZERO | D3DPBLENDCAPS_ONE | D3DPBLENDCAPS_SRCCOLOR |
1421 D3DPBLENDCAPS_INVSRCCOLOR | D3DPBLENDCAPS_SRCALPHA | D3DPBLENDCAPS_INVSRCALPHA |
1422 D3DPBLENDCAPS_DESTALPHA | D3DPBLENDCAPS_INVDESTALPHA | D3DPBLENDCAPS_DESTCOLOR |
1423 D3DPBLENDCAPS_INVDESTCOLOR | D3DPBLENDCAPS_SRCALPHASAT | D3DPBLENDCAPS_BOTHSRCALPHA |
1424 D3DPBLENDCAPS_BOTHINVSRCALPHA);
1426 Desc7->dpcLineCaps.dwAlphaCmpCaps &= (
1427 D3DPCMPCAPS_NEVER | D3DPCMPCAPS_LESS | D3DPCMPCAPS_EQUAL |
1428 D3DPCMPCAPS_LESSEQUAL | D3DPCMPCAPS_GREATER | D3DPCMPCAPS_NOTEQUAL |
1429 D3DPCMPCAPS_GREATEREQUAL | D3DPCMPCAPS_ALWAYS);
1431 Desc7->dpcLineCaps.dwShadeCaps &= (
1432 D3DPSHADECAPS_COLORFLATMONO | D3DPSHADECAPS_COLORFLATRGB | D3DPSHADECAPS_COLORGOURAUDMONO |
1433 D3DPSHADECAPS_COLORGOURAUDRGB | D3DPSHADECAPS_COLORPHONGMONO | D3DPSHADECAPS_COLORPHONGRGB |
1434 D3DPSHADECAPS_SPECULARFLATMONO | D3DPSHADECAPS_SPECULARFLATRGB | D3DPSHADECAPS_SPECULARGOURAUDMONO |
1435 D3DPSHADECAPS_SPECULARGOURAUDRGB | D3DPSHADECAPS_SPECULARPHONGMONO | D3DPSHADECAPS_SPECULARPHONGRGB |
1436 D3DPSHADECAPS_ALPHAFLATBLEND | D3DPSHADECAPS_ALPHAFLATSTIPPLED | D3DPSHADECAPS_ALPHAGOURAUDBLEND |
1437 D3DPSHADECAPS_ALPHAGOURAUDSTIPPLED | D3DPSHADECAPS_ALPHAPHONGBLEND | D3DPSHADECAPS_ALPHAPHONGSTIPPLED |
1438 D3DPSHADECAPS_FOGFLAT | D3DPSHADECAPS_FOGGOURAUD | D3DPSHADECAPS_FOGPHONG);
1440 Desc7->dpcLineCaps.dwTextureCaps &= (
1441 D3DPTEXTURECAPS_PERSPECTIVE | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_ALPHA |
1442 D3DPTEXTURECAPS_TRANSPARENCY | D3DPTEXTURECAPS_BORDER | D3DPTEXTURECAPS_SQUAREONLY |
1443 D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE | D3DPTEXTURECAPS_ALPHAPALETTE| D3DPTEXTURECAPS_NONPOW2CONDITIONAL |
1444 D3DPTEXTURECAPS_PROJECTED | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_COLORKEYBLEND);
1446 Desc7->dpcLineCaps.dwTextureFilterCaps &= (
1447 D3DPTFILTERCAPS_NEAREST | D3DPTFILTERCAPS_LINEAR | D3DPTFILTERCAPS_MIPNEAREST |
1448 D3DPTFILTERCAPS_MIPLINEAR | D3DPTFILTERCAPS_LINEARMIPNEAREST | D3DPTFILTERCAPS_LINEARMIPLINEAR |
1449 D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR | D3DPTFILTERCAPS_MINFANISOTROPIC |
1450 D3DPTFILTERCAPS_MIPFPOINT | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT |
1451 D3DPTFILTERCAPS_MAGFLINEAR | D3DPTFILTERCAPS_MAGFANISOTROPIC | D3DPTFILTERCAPS_MAGFAFLATCUBIC |
1452 D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC);
1454 Desc7->dpcLineCaps.dwTextureBlendCaps &= (
1455 D3DPTBLENDCAPS_DECAL | D3DPTBLENDCAPS_MODULATE | D3DPTBLENDCAPS_DECALALPHA |
1456 D3DPTBLENDCAPS_MODULATEALPHA | D3DPTBLENDCAPS_DECALMASK | D3DPTBLENDCAPS_MODULATEMASK |
1457 D3DPTBLENDCAPS_COPY | D3DPTBLENDCAPS_ADD);
1459 Desc7->dpcLineCaps.dwTextureAddressCaps &= (
1460 D3DPTADDRESSCAPS_WRAP | D3DPTADDRESSCAPS_MIRROR | D3DPTADDRESSCAPS_CLAMP |
1461 D3DPTADDRESSCAPS_BORDER | D3DPTADDRESSCAPS_INDEPENDENTUV);
1463 if(!(Desc7->dpcLineCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2)) {
1464 /* DirectX7 always has the np2 flag set, no matter what the card supports. Some old games(rollcage)
1465 * check the caps incorrectly. If wined3d supports nonpow2 textures it also has np2 conditional support
1467 Desc7->dpcLineCaps.dwTextureCaps |= D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
1469 /* Fill the missing members, and do some fixup */
1470 Desc7->dpcLineCaps.dwSize = sizeof(Desc7->dpcLineCaps);
1471 Desc7->dpcLineCaps.dwTextureBlendCaps = D3DPTBLENDCAPS_ADD | D3DPTBLENDCAPS_MODULATEMASK |
1472 D3DPTBLENDCAPS_COPY | D3DPTBLENDCAPS_DECAL |
1473 D3DPTBLENDCAPS_DECALALPHA | D3DPTBLENDCAPS_DECALMASK |
1474 D3DPTBLENDCAPS_MODULATE | D3DPTBLENDCAPS_MODULATEALPHA;
1475 Desc7->dpcLineCaps.dwStippleWidth = 32;
1476 Desc7->dpcLineCaps.dwStippleHeight = 32;
1477 /* Use the same for the TriCaps */
1478 Desc7->dpcTriCaps = Desc7->dpcLineCaps;
1480 Desc7->dwDeviceRenderBitDepth = DDBD_16 | DDBD_24 | DDBD_32;
1481 Desc7->dwDeviceZBufferBitDepth = DDBD_16 | DDBD_24;
1482 Desc7->dwMinTextureWidth = 1;
1483 Desc7->dwMinTextureHeight = 1;
1485 /* Convert DWORDs safely to WORDs */
1486 if(MaxTextureBlendStages > 65535) Desc7->wMaxTextureBlendStages = 65535;
1487 else Desc7->wMaxTextureBlendStages = (WORD) MaxTextureBlendStages;
1488 if(MaxSimultaneousTextures > 65535) Desc7->wMaxSimultaneousTextures = 65535;
1489 else Desc7->wMaxSimultaneousTextures = (WORD) MaxSimultaneousTextures;
1491 if(MaxUserClipPlanes > 65535) Desc7->wMaxUserClipPlanes = 65535;
1492 else Desc7->wMaxUserClipPlanes = (WORD) MaxUserClipPlanes;
1493 if(MaxVertexBlendMatrices > 65535) Desc7->wMaxVertexBlendMatrices = 65535;
1494 else Desc7->wMaxVertexBlendMatrices = (WORD) MaxVertexBlendMatrices;
1496 Desc7->deviceGUID = IID_IDirect3DTnLHalDevice;
1498 Desc7->dwReserved1 = 0;
1499 Desc7->dwReserved2 = 0;
1500 Desc7->dwReserved3 = 0;
1501 Desc7->dwReserved4 = 0;
1503 /* Fill the old structure */
1504 memset(Desc123, 0x0, sizeof(D3DDEVICEDESC));
1505 Desc123->dwSize = sizeof(D3DDEVICEDESC);
1506 Desc123->dwFlags = D3DDD_COLORMODEL |
1508 D3DDD_TRANSFORMCAPS |
1510 D3DDD_LIGHTINGCAPS |
1513 D3DDD_DEVICERENDERBITDEPTH |
1514 D3DDD_DEVICEZBUFFERBITDEPTH |
1515 D3DDD_MAXBUFFERSIZE |
1516 D3DDD_MAXVERTEXCOUNT;
1517 Desc123->dcmColorModel = D3DCOLOR_RGB;
1518 Desc123->dwDevCaps = Desc7->dwDevCaps;
1519 Desc123->dtcTransformCaps.dwSize = sizeof(D3DTRANSFORMCAPS);
1520 Desc123->dtcTransformCaps.dwCaps = D3DTRANSFORMCAPS_CLIP;
1521 Desc123->bClipping = TRUE;
1522 Desc123->dlcLightingCaps.dwSize = sizeof(D3DLIGHTINGCAPS);
1523 Desc123->dlcLightingCaps.dwCaps = D3DLIGHTCAPS_DIRECTIONAL | D3DLIGHTCAPS_PARALLELPOINT | D3DLIGHTCAPS_POINT | D3DLIGHTCAPS_SPOT;
1524 Desc123->dlcLightingCaps.dwLightingModel = D3DLIGHTINGMODEL_RGB;
1525 Desc123->dlcLightingCaps.dwNumLights = Desc7->dwMaxActiveLights;
1527 Desc123->dpcLineCaps.dwSize = sizeof(D3DPRIMCAPS);
1528 Desc123->dpcLineCaps.dwMiscCaps = Desc7->dpcLineCaps.dwMiscCaps;
1529 Desc123->dpcLineCaps.dwRasterCaps = Desc7->dpcLineCaps.dwRasterCaps;
1530 Desc123->dpcLineCaps.dwZCmpCaps = Desc7->dpcLineCaps.dwZCmpCaps;
1531 Desc123->dpcLineCaps.dwSrcBlendCaps = Desc7->dpcLineCaps.dwSrcBlendCaps;
1532 Desc123->dpcLineCaps.dwDestBlendCaps = Desc7->dpcLineCaps.dwDestBlendCaps;
1533 Desc123->dpcLineCaps.dwShadeCaps = Desc7->dpcLineCaps.dwShadeCaps;
1534 Desc123->dpcLineCaps.dwTextureCaps = Desc7->dpcLineCaps.dwTextureCaps;
1535 Desc123->dpcLineCaps.dwTextureFilterCaps = Desc7->dpcLineCaps.dwTextureFilterCaps;
1536 Desc123->dpcLineCaps.dwTextureBlendCaps = Desc7->dpcLineCaps.dwTextureBlendCaps;
1537 Desc123->dpcLineCaps.dwTextureAddressCaps = Desc7->dpcLineCaps.dwTextureAddressCaps;
1538 Desc123->dpcLineCaps.dwStippleWidth = Desc7->dpcLineCaps.dwStippleWidth;
1539 Desc123->dpcLineCaps.dwAlphaCmpCaps = Desc7->dpcLineCaps.dwAlphaCmpCaps;
1541 Desc123->dpcTriCaps.dwSize = sizeof(D3DPRIMCAPS);
1542 Desc123->dpcTriCaps.dwMiscCaps = Desc7->dpcTriCaps.dwMiscCaps;
1543 Desc123->dpcTriCaps.dwRasterCaps = Desc7->dpcTriCaps.dwRasterCaps;
1544 Desc123->dpcTriCaps.dwZCmpCaps = Desc7->dpcTriCaps.dwZCmpCaps;
1545 Desc123->dpcTriCaps.dwSrcBlendCaps = Desc7->dpcTriCaps.dwSrcBlendCaps;
1546 Desc123->dpcTriCaps.dwDestBlendCaps = Desc7->dpcTriCaps.dwDestBlendCaps;
1547 Desc123->dpcTriCaps.dwShadeCaps = Desc7->dpcTriCaps.dwShadeCaps;
1548 Desc123->dpcTriCaps.dwTextureCaps = Desc7->dpcTriCaps.dwTextureCaps;
1549 Desc123->dpcTriCaps.dwTextureFilterCaps = Desc7->dpcTriCaps.dwTextureFilterCaps;
1550 Desc123->dpcTriCaps.dwTextureBlendCaps = Desc7->dpcTriCaps.dwTextureBlendCaps;
1551 Desc123->dpcTriCaps.dwTextureAddressCaps = Desc7->dpcTriCaps.dwTextureAddressCaps;
1552 Desc123->dpcTriCaps.dwStippleWidth = Desc7->dpcTriCaps.dwStippleWidth;
1553 Desc123->dpcTriCaps.dwAlphaCmpCaps = Desc7->dpcTriCaps.dwAlphaCmpCaps;
1555 Desc123->dwDeviceRenderBitDepth = Desc7->dwDeviceRenderBitDepth;
1556 Desc123->dwDeviceZBufferBitDepth = Desc7->dwDeviceZBufferBitDepth;
1557 Desc123->dwMaxBufferSize = 0;
1558 Desc123->dwMaxVertexCount = 65536;
1559 Desc123->dwMinTextureWidth = Desc7->dwMinTextureWidth;
1560 Desc123->dwMinTextureHeight = Desc7->dwMinTextureHeight;
1561 Desc123->dwMaxTextureWidth = Desc7->dwMaxTextureWidth;
1562 Desc123->dwMaxTextureHeight = Desc7->dwMaxTextureHeight;
1563 Desc123->dwMinStippleWidth = 1;
1564 Desc123->dwMinStippleHeight = 1;
1565 Desc123->dwMaxStippleWidth = 32;
1566 Desc123->dwMaxStippleHeight = 32;
1567 Desc123->dwMaxTextureRepeat = Desc7->dwMaxTextureRepeat;
1568 Desc123->dwMaxTextureAspectRatio = Desc7->dwMaxTextureAspectRatio;
1569 Desc123->dwMaxAnisotropy = Desc7->dwMaxAnisotropy;
1570 Desc123->dvGuardBandLeft = Desc7->dvGuardBandLeft;
1571 Desc123->dvGuardBandRight = Desc7->dvGuardBandRight;
1572 Desc123->dvGuardBandTop = Desc7->dvGuardBandTop;
1573 Desc123->dvGuardBandBottom = Desc7->dvGuardBandBottom;
1574 Desc123->dvExtentsAdjust = Desc7->dvExtentsAdjust;
1575 Desc123->dwStencilCaps = Desc7->dwStencilCaps;
1576 Desc123->dwFVFCaps = Desc7->dwFVFCaps;
1577 Desc123->dwTextureOpCaps = Desc7->dwTextureOpCaps;
1578 Desc123->wMaxTextureBlendStages = Desc7->wMaxTextureBlendStages;
1579 Desc123->wMaxSimultaneousTextures = Desc7->wMaxSimultaneousTextures;
1583 /*****************************************************************************
1584 * IDirect3D vtables in various versions
1585 *****************************************************************************/
1587 const IDirect3DVtbl IDirect3D1_Vtbl =
1589 /*** IUnknown methods ***/
1590 Thunk_IDirect3DImpl_1_QueryInterface,
1591 Thunk_IDirect3DImpl_1_AddRef,
1592 Thunk_IDirect3DImpl_1_Release,
1593 /*** IDirect3D methods ***/
1594 IDirect3DImpl_1_Initialize,
1595 Thunk_IDirect3DImpl_1_EnumDevices,
1596 Thunk_IDirect3DImpl_1_CreateLight,
1597 Thunk_IDirect3DImpl_1_CreateMaterial,
1598 Thunk_IDirect3DImpl_1_CreateViewport,
1599 Thunk_IDirect3DImpl_1_FindDevice
1602 const IDirect3D2Vtbl IDirect3D2_Vtbl =
1604 /*** IUnknown methods ***/
1605 Thunk_IDirect3DImpl_2_QueryInterface,
1606 Thunk_IDirect3DImpl_2_AddRef,
1607 Thunk_IDirect3DImpl_2_Release,
1608 /*** IDirect3D2 methods ***/
1609 Thunk_IDirect3DImpl_2_EnumDevices,
1610 Thunk_IDirect3DImpl_2_CreateLight,
1611 Thunk_IDirect3DImpl_2_CreateMaterial,
1612 Thunk_IDirect3DImpl_2_CreateViewport,
1613 Thunk_IDirect3DImpl_2_FindDevice,
1614 Thunk_IDirect3DImpl_2_CreateDevice
1617 const IDirect3D3Vtbl IDirect3D3_Vtbl =
1619 /*** IUnknown methods ***/
1620 Thunk_IDirect3DImpl_3_QueryInterface,
1621 Thunk_IDirect3DImpl_3_AddRef,
1622 Thunk_IDirect3DImpl_3_Release,
1623 /*** IDirect3D3 methods ***/
1624 IDirect3DImpl_3_EnumDevices,
1625 IDirect3DImpl_3_CreateLight,
1626 IDirect3DImpl_3_CreateMaterial,
1627 IDirect3DImpl_3_CreateViewport,
1628 IDirect3DImpl_3_FindDevice,
1629 Thunk_IDirect3DImpl_3_CreateDevice,
1630 Thunk_IDirect3DImpl_3_CreateVertexBuffer,
1631 Thunk_IDirect3DImpl_3_EnumZBufferFormats,
1632 Thunk_IDirect3DImpl_3_EvictManagedTextures
1635 const IDirect3D7Vtbl IDirect3D7_Vtbl =
1637 /*** IUnknown methods ***/
1638 Thunk_IDirect3DImpl_7_QueryInterface,
1639 Thunk_IDirect3DImpl_7_AddRef,
1640 Thunk_IDirect3DImpl_7_Release,
1641 /*** IDirect3D7 methods ***/
1642 IDirect3DImpl_7_EnumDevices,
1643 IDirect3DImpl_7_CreateDevice,
1644 IDirect3DImpl_7_CreateVertexBuffer,
1645 IDirect3DImpl_7_EnumZBufferFormats,
1646 IDirect3DImpl_7_EvictManagedTextures