2002-09-28 00:46:16 +02:00
|
|
|
/*
|
|
|
|
* IDirect3D8 implementation
|
|
|
|
*
|
2004-04-16 01:58:15 +02:00
|
|
|
* Copyright 2002-2004 Jason Edmeades
|
2004-04-20 01:04:58 +02:00
|
|
|
* Copyright 2003-2004 Raphael Junqueira
|
2004-04-16 01:58:15 +02:00
|
|
|
* Copyright 2004 Christian Costa
|
2002-09-28 00:46:16 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-09-28 00:46:16 +02:00
|
|
|
*/
|
|
|
|
|
2003-04-22 06:05:08 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2002-09-28 00:46:16 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
2003-09-16 22:24:49 +02:00
|
|
|
#include "winuser.h"
|
2002-09-28 00:46:16 +02:00
|
|
|
#include "wine/debug.h"
|
2003-06-05 00:55:19 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-09-28 00:46:16 +02:00
|
|
|
|
|
|
|
#include "d3d8_private.h"
|
|
|
|
|
2006-02-25 13:15:08 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
2002-09-28 00:46:16 +02:00
|
|
|
|
|
|
|
/* IDirect3D IUnknown parts follow: */
|
2006-06-10 11:48:24 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface, REFIID riid,LPVOID *ppobj)
|
2002-09-28 00:46:16 +02:00
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2002-09-28 00:46:16 +02:00
|
|
|
|
2009-10-19 10:12:20 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
|
|
|
|
|
2002-09-28 00:46:16 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
2002-12-17 02:15:15 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IDirect3D8)) {
|
2006-02-25 13:15:08 +01:00
|
|
|
IUnknown_AddRef(iface);
|
2002-09-28 00:46:16 +02:00
|
|
|
*ppobj = This;
|
2006-06-07 15:13:29 +02:00
|
|
|
return S_OK;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-02-25 13:15:08 +01:00
|
|
|
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid),ppobj);
|
2006-06-07 15:13:29 +02:00
|
|
|
*ppobj = NULL;
|
2002-09-28 00:46:16 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2005-01-24 12:31:45 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2009-10-19 10:12:20 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, ref);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
|
|
|
return ref;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2005-01-24 12:31:45 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2009-10-19 10:12:20 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, ref);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2004-09-28 04:12:12 +02:00
|
|
|
if (ref == 0) {
|
2006-02-25 13:15:08 +01:00
|
|
|
TRACE("Releasing wined3d %p\n", This->WineD3D);
|
2009-08-25 08:17:14 +02:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2004-09-28 04:12:12 +02:00
|
|
|
IWineD3D_Release(This->WineD3D);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2002-09-28 00:46:16 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2004-09-28 04:12:12 +02:00
|
|
|
}
|
2006-02-25 13:15:08 +01:00
|
|
|
|
2002-09-28 00:46:16 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2006-02-25 13:15:08 +01:00
|
|
|
/* IDirect3D8 Interface follow: */
|
2006-06-10 11:48:24 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, init_function %p.\n", iface, pInitializeFunction);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2007-05-23 00:33:42 +02:00
|
|
|
hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2007-05-23 00:33:42 +02:00
|
|
|
hr = IWineD3D_GetAdapterCount(This->WineD3D);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2009-07-07 11:08:03 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface,
|
|
|
|
UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8 *pIdentifier)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2004-09-29 23:26:47 +02:00
|
|
|
WINED3DADAPTER_IDENTIFIER adapter_id;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2004-09-29 23:26:47 +02:00
|
|
|
|
2009-10-19 10:12:20 +02:00
|
|
|
TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n",
|
|
|
|
iface, Adapter, Flags, pIdentifier);
|
2004-09-29 23:26:47 +02:00
|
|
|
|
2009-07-07 11:08:03 +02:00
|
|
|
adapter_id.driver = pIdentifier->Driver;
|
|
|
|
adapter_id.driver_size = sizeof(pIdentifier->Driver);
|
|
|
|
adapter_id.description = pIdentifier->Description;
|
|
|
|
adapter_id.description_size = sizeof(pIdentifier->Description);
|
|
|
|
adapter_id.device_name = NULL; /* d3d9 only */
|
|
|
|
adapter_id.device_name_size = 0; /* d3d9 only */
|
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2007-05-23 00:33:42 +02:00
|
|
|
hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-07-07 11:08:03 +02:00
|
|
|
|
|
|
|
pIdentifier->DriverVersion = adapter_id.driver_version;
|
|
|
|
pIdentifier->VendorId = adapter_id.vendor_id;
|
|
|
|
pIdentifier->DeviceId = adapter_id.device_id;
|
|
|
|
pIdentifier->SubSysId = adapter_id.subsystem_id;
|
|
|
|
pIdentifier->Revision = adapter_id.revision;
|
|
|
|
memcpy(&pIdentifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(pIdentifier->DeviceIdentifier));
|
|
|
|
pIdentifier->WHQLLevel = adapter_id.whql_level;
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Adapter) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u.\n", iface, Adapter);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2007-05-23 00:33:42 +02:00
|
|
|
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, mode_idx %u, mode %p.\n",
|
|
|
|
iface, Adapter, Mode, pMode);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2007-05-23 00:33:42 +02:00
|
|
|
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, Mode, (WINED3DDISPLAYMODE *) pMode);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-02-19 16:59:41 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, mode %p.\n",
|
|
|
|
iface, Adapter, pMode);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2007-05-23 00:33:42 +02:00
|
|
|
hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-02-19 16:59:41 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface,
|
2002-09-28 00:46:16 +02:00
|
|
|
UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
|
|
|
|
D3DFORMAT BackBufferFormat, BOOL Windowed) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
|
|
|
|
iface, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2009-02-19 16:59:41 +01:00
|
|
|
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
|
|
|
|
wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface,
|
2002-09-28 00:46:16 +02:00
|
|
|
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
|
|
|
|
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-04-06 16:44:00 +02:00
|
|
|
WINED3DRESOURCETYPE WineD3DRType;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
|
|
|
|
iface, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-05 20:55:51 +02:00
|
|
|
if(CheckFormat == D3DFMT_R8G8B8)
|
|
|
|
{
|
|
|
|
/* See comment in dlls/d3d9/directx.c, IDirect3D9Impl_CheckDeviceFormat for details */
|
|
|
|
WARN("D3DFMT_R8G8B8 is not available on windows, returning D3DERR_NOTAVAILABLE\n");
|
|
|
|
return D3DERR_NOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-06 16:44:00 +02:00
|
|
|
switch(RType) {
|
|
|
|
case D3DRTYPE_VERTEXBUFFER:
|
|
|
|
case D3DRTYPE_INDEXBUFFER:
|
|
|
|
WineD3DRType = WINED3DRTYPE_BUFFER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
WineD3DRType = RType;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2009-02-19 16:59:41 +01:00
|
|
|
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
|
2009-04-06 16:44:00 +02:00
|
|
|
Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2009-08-25 08:17:13 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT Adapter,
|
|
|
|
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x.\n",
|
|
|
|
iface, Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2009-02-19 16:59:41 +01:00
|
|
|
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
|
|
|
|
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2009-08-25 08:17:13 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(IDirect3D8 *iface, UINT Adapter, D3DDEVTYPE DeviceType,
|
|
|
|
D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
|
|
|
|
iface, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2009-02-19 16:59:41 +01:00
|
|
|
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
|
|
|
|
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
|
|
|
|
wined3dformat_from_d3dformat(DepthStencilFormat));
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2009-08-07 12:17:41 +02:00
|
|
|
void fixup_caps(WINED3DCAPS *caps)
|
|
|
|
{
|
|
|
|
/* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
|
|
|
|
if (caps->PixelShaderVersion > D3DPS_VERSION(1,4)) {
|
|
|
|
caps->PixelShaderVersion = D3DPS_VERSION(1,4);
|
|
|
|
}
|
|
|
|
if (caps->VertexShaderVersion > D3DVS_VERSION(1,1)) {
|
|
|
|
caps->VertexShaderVersion = D3DVS_VERSION(1,1);
|
|
|
|
}
|
|
|
|
caps->MaxVertexShaderConst = min(D3D8_MAX_VERTEX_SHADER_CONSTANTF, caps->MaxVertexShaderConst);
|
|
|
|
|
|
|
|
caps->StencilCaps &= ~WINED3DSTENCILCAPS_TWOSIDED;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2005-06-17 11:59:03 +02:00
|
|
|
HRESULT hrc = D3D_OK;
|
|
|
|
WINED3DCAPS *pWineCaps;
|
|
|
|
|
2009-10-19 10:12:20 +02:00
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, Adapter, DeviceType, pCaps);
|
2005-06-17 11:59:03 +02:00
|
|
|
|
|
|
|
if(NULL == pCaps){
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
|
|
|
|
if(pWineCaps == NULL){
|
|
|
|
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
|
|
|
|
}
|
2009-08-25 08:17:14 +02:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2005-06-17 11:59:03 +02:00
|
|
|
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2009-08-07 12:17:41 +02:00
|
|
|
fixup_caps(pWineCaps);
|
2008-03-18 19:26:00 +01:00
|
|
|
WINECAPSTOD3D8CAPS(pCaps, pWineCaps)
|
2005-06-17 11:59:03 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, pWineCaps);
|
2006-12-23 14:41:53 +01:00
|
|
|
|
2005-06-17 11:59:03 +02:00
|
|
|
TRACE("(%p) returning %p\n", This, pCaps);
|
|
|
|
return hrc;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
2007-05-23 00:33:42 +02:00
|
|
|
HMONITOR ret;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u.\n", iface, Adapter);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2007-05-23 00:33:42 +02:00
|
|
|
ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return ret;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2006-12-18 00:17:24 +01:00
|
|
|
ULONG WINAPI D3D8CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
|
|
|
|
IUnknown* swapChainParent;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("swapchain %p.\n", pSwapChain);
|
2006-12-18 00:17:24 +01:00
|
|
|
|
|
|
|
IWineD3DSwapChain_GetParent(pSwapChain, &swapChainParent);
|
|
|
|
IUnknown_Release(swapChainParent);
|
|
|
|
return IUnknown_Release(swapChainParent);
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:48:24 +02:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
|
2006-02-25 13:15:08 +01:00
|
|
|
DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
|
|
|
|
IDirect3DDevice8** ppReturnedDeviceInterface) {
|
2002-09-28 00:46:16 +02:00
|
|
|
|
2006-02-25 13:15:08 +01:00
|
|
|
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
|
|
|
IDirect3DDevice8Impl *object = NULL;
|
|
|
|
WINED3DPRESENT_PARAMETERS localParameters;
|
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n",
|
|
|
|
iface, Adapter, DeviceType, hFocusWindow, BehaviourFlags, pPresentationParameters,
|
|
|
|
ppReturnedDeviceInterface);
|
2006-02-25 13:15:08 +01:00
|
|
|
|
|
|
|
/* Check the validity range of the adapter parameter */
|
2004-05-19 06:33:42 +02:00
|
|
|
if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
|
2006-02-25 13:15:08 +01:00
|
|
|
*ppReturnedDeviceInterface = NULL;
|
2004-05-19 06:33:42 +02:00
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2006-02-25 13:15:08 +01:00
|
|
|
/* Allocate the storage for the device object */
|
2002-09-28 00:46:16 +02:00
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice8Impl));
|
2002-12-18 06:05:41 +01:00
|
|
|
if (NULL == object) {
|
2006-02-25 13:15:08 +01:00
|
|
|
FIXME("Allocation of memory failed\n");
|
|
|
|
*ppReturnedDeviceInterface = NULL;
|
|
|
|
return D3DERR_OUTOFVIDEOMEMORY;
|
2002-12-18 06:05:41 +01:00
|
|
|
}
|
2006-02-25 13:15:08 +01:00
|
|
|
|
2002-09-28 00:46:16 +02:00
|
|
|
object->lpVtbl = &Direct3DDevice8_Vtbl;
|
2009-01-16 10:14:24 +01:00
|
|
|
object->device_parent_vtbl = &d3d8_wined3d_device_parent_vtbl;
|
2002-09-28 00:46:16 +02:00
|
|
|
object->ref = 1;
|
2009-03-10 09:19:06 +01:00
|
|
|
object->handle_table.entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
D3D8_INITIAL_HANDLE_TABLE_SIZE * sizeof(*object->handle_table.entries));
|
|
|
|
object->handle_table.table_size = D3D8_INITIAL_HANDLE_TABLE_SIZE;
|
2006-02-25 13:15:08 +01:00
|
|
|
*ppReturnedDeviceInterface = (IDirect3DDevice8 *)object;
|
2003-01-28 02:12:23 +01:00
|
|
|
|
2004-10-08 22:52:33 +02:00
|
|
|
/* Allocate an associated WineD3DDevice object */
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2009-01-16 10:14:24 +01:00
|
|
|
hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags,
|
|
|
|
(IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice);
|
2006-04-12 21:08:57 +02:00
|
|
|
|
|
|
|
if (hr != D3D_OK) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
*ppReturnedDeviceInterface = NULL;
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2006-04-12 21:08:57 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(%p) : Created Device %p\n", This, object);
|
|
|
|
|
2007-02-15 22:36:50 +01:00
|
|
|
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
|
|
|
|
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
|
2009-02-19 16:59:41 +01:00
|
|
|
localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
|
2007-02-15 22:36:50 +01:00
|
|
|
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
|
|
|
|
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
|
|
|
|
localParameters.MultiSampleQuality = 0; /* d3d9 only */
|
|
|
|
localParameters.SwapEffect = pPresentationParameters->SwapEffect;
|
|
|
|
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
|
|
|
|
localParameters.Windowed = pPresentationParameters->Windowed;
|
|
|
|
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
|
2009-02-19 16:59:41 +01:00
|
|
|
localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
|
2007-02-15 22:36:50 +01:00
|
|
|
localParameters.Flags = pPresentationParameters->Flags;
|
|
|
|
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
|
|
|
|
localParameters.PresentationInterval = pPresentationParameters->FullScreen_PresentationInterval;
|
2008-11-01 22:35:23 +01:00
|
|
|
localParameters.AutoRestoreDisplayMode = TRUE;
|
2007-02-15 22:36:50 +01:00
|
|
|
|
2007-03-04 17:03:03 +01:00
|
|
|
if(BehaviourFlags & D3DCREATE_MULTITHREADED) {
|
|
|
|
IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);
|
|
|
|
}
|
|
|
|
|
2009-01-16 10:14:24 +01:00
|
|
|
hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters);
|
2009-10-20 10:20:18 +02:00
|
|
|
if (hr != D3D_OK) {
|
2009-10-20 10:26:06 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-10-20 10:20:18 +02:00
|
|
|
FIXME("(%p) D3D Initialization failed for WineD3DDevice %p\n", This, object->WineD3DDevice);
|
|
|
|
goto err;
|
|
|
|
}
|
2009-10-20 10:26:06 +02:00
|
|
|
hr = IWineD3DDevice_SetRenderState(object->WineD3DDevice, WINED3DRS_POINTSIZE_MIN, 0);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
FIXME("(%p) SetRenderState failed\n", This);
|
|
|
|
goto err;
|
|
|
|
}
|
2007-02-15 22:36:50 +01:00
|
|
|
|
|
|
|
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
|
|
|
|
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
|
2009-02-19 16:59:41 +01:00
|
|
|
pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
|
2007-02-15 22:36:50 +01:00
|
|
|
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
|
|
|
|
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
|
|
|
|
pPresentationParameters->SwapEffect = localParameters.SwapEffect;
|
|
|
|
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
|
|
|
|
pPresentationParameters->Windowed = localParameters.Windowed;
|
|
|
|
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
|
2009-02-19 16:59:41 +01:00
|
|
|
pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
|
2007-02-15 22:36:50 +01:00
|
|
|
pPresentationParameters->Flags = localParameters.Flags;
|
|
|
|
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
|
|
|
|
pPresentationParameters->FullScreen_PresentationInterval = localParameters.PresentationInterval;
|
|
|
|
|
2007-06-19 22:20:26 +02:00
|
|
|
object->declArraySize = 16;
|
|
|
|
object->decls = HeapAlloc(GetProcessHeap(), 0, object->declArraySize * sizeof(*object->decls));
|
|
|
|
if(!object->decls) {
|
|
|
|
ERR("Out of memory\n");
|
2009-10-20 10:20:18 +02:00
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
return D3D_OK;
|
2009-08-25 08:17:14 +02:00
|
|
|
|
2009-10-20 10:20:18 +02:00
|
|
|
err:
|
|
|
|
*ppReturnedDeviceInterface = NULL;
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, object->decls);
|
2009-11-08 09:16:22 +01:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
IWineD3DDevice_Uninit3D(object->WineD3DDevice, D3D8CB_DestroySwapChain);
|
|
|
|
IWineD3DDevice_Release(object->WineD3DDevice);
|
|
|
|
wined3d_mutex_unlock();
|
2009-10-20 10:20:18 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
2006-02-25 13:15:08 +01:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
const IDirect3D8Vtbl Direct3D8_Vtbl =
|
2002-09-28 00:46:16 +02:00
|
|
|
{
|
2006-02-25 13:15:08 +01:00
|
|
|
/* IUnknown */
|
2002-09-28 00:46:16 +02:00
|
|
|
IDirect3D8Impl_QueryInterface,
|
|
|
|
IDirect3D8Impl_AddRef,
|
|
|
|
IDirect3D8Impl_Release,
|
2006-02-25 13:15:08 +01:00
|
|
|
/* IDirect3D8 */
|
2002-09-28 00:46:16 +02:00
|
|
|
IDirect3D8Impl_RegisterSoftwareDevice,
|
|
|
|
IDirect3D8Impl_GetAdapterCount,
|
|
|
|
IDirect3D8Impl_GetAdapterIdentifier,
|
|
|
|
IDirect3D8Impl_GetAdapterModeCount,
|
|
|
|
IDirect3D8Impl_EnumAdapterModes,
|
|
|
|
IDirect3D8Impl_GetAdapterDisplayMode,
|
|
|
|
IDirect3D8Impl_CheckDeviceType,
|
|
|
|
IDirect3D8Impl_CheckDeviceFormat,
|
|
|
|
IDirect3D8Impl_CheckDeviceMultiSampleType,
|
|
|
|
IDirect3D8Impl_CheckDepthStencilMatch,
|
|
|
|
IDirect3D8Impl_GetDeviceCaps,
|
|
|
|
IDirect3D8Impl_GetAdapterMonitor,
|
|
|
|
IDirect3D8Impl_CreateDevice
|
|
|
|
};
|