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
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static inline struct d3d8 *impl_from_IDirect3D8(IDirect3D8 *iface)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3d8, IDirect3D8_iface);
|
2011-01-23 21:49:42 +01:00
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_QueryInterface(IDirect3D8 *iface, REFIID riid, void **out)
|
2002-09-28 00:46:16 +02:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
2009-10-19 10:12:20 +02:00
|
|
|
|
2012-03-25 20:56:28 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IDirect3D8)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2012-08-27 12:27:34 +02:00
|
|
|
IDirect3D8_AddRef(iface);
|
2012-05-03 21:49:37 +02:00
|
|
|
*out = iface;
|
2006-06-07 15:13:29 +02:00
|
|
|
return S_OK;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2012-03-25 20:56:28 +02:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
*out = NULL;
|
2002-09-28 00:46:16 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static ULONG WINAPI d3d8_AddRef(IDirect3D8 *iface)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&d3d8->refcount);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
return refcount;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static ULONG WINAPI d3d8_Release(IDirect3D8 *iface)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&d3d8->refcount);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
2009-08-25 08:17:14 +02:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
if (!refcount)
|
|
|
|
{
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-05-03 21:49:37 +02:00
|
|
|
wined3d_decref(d3d8->wined3d);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, d3d8);
|
2004-09-28 04:12:12 +02:00
|
|
|
}
|
2006-02-25 13:15:08 +01:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
return refcount;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_RegisterSoftwareDevice(IDirect3D8 *iface, void *init_function)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
TRACE("iface %p, init_function %p.\n", iface, init_function);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-05-03 21:49:37 +02:00
|
|
|
hr = wined3d_register_software_device(d3d8->wined3d, init_function);
|
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
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static UINT WINAPI d3d8_GetAdapterCount(IDirect3D8 *iface)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(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();
|
2012-05-03 21:49:37 +02:00
|
|
|
hr = wined3d_get_adapter_count(d3d8->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
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_GetAdapterIdentifier(IDirect3D8 *iface, UINT adapter,
|
|
|
|
DWORD flags, D3DADAPTER_IDENTIFIER8 *identifier)
|
2009-07-07 11:08:03 +02:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
2011-11-23 21:14:57 +01:00
|
|
|
struct wined3d_adapter_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",
|
2012-05-03 21:49:37 +02:00
|
|
|
iface, adapter, flags, identifier);
|
2004-09-29 23:26:47 +02:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
adapter_id.driver = identifier->Driver;
|
|
|
|
adapter_id.driver_size = sizeof(identifier->Driver);
|
|
|
|
adapter_id.description = identifier->Description;
|
|
|
|
adapter_id.description_size = sizeof(identifier->Description);
|
2009-07-07 11:08:03 +02:00
|
|
|
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();
|
2012-05-03 21:49:37 +02:00
|
|
|
hr = wined3d_get_adapter_identifier(d3d8->wined3d, adapter, flags, &adapter_id);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-07-07 11:08:03 +02:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
identifier->DriverVersion = adapter_id.driver_version;
|
|
|
|
identifier->VendorId = adapter_id.vendor_id;
|
|
|
|
identifier->DeviceId = adapter_id.device_id;
|
|
|
|
identifier->SubSysId = adapter_id.subsystem_id;
|
|
|
|
identifier->Revision = adapter_id.revision;
|
|
|
|
memcpy(&identifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(identifier->DeviceIdentifier));
|
|
|
|
identifier->WHQLLevel = adapter_id.whql_level;
|
2009-07-07 11:08:03 +02:00
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static UINT WINAPI d3d8_GetAdapterModeCount(IDirect3D8 *iface, UINT adapter)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
2007-05-23 00:33:42 +02:00
|
|
|
HRESULT hr;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
2012-05-03 21:49:37 +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();
|
2012-06-29 07:37:57 +02:00
|
|
|
hr = wined3d_get_adapter_mode_count(d3d8->wined3d, adapter,
|
|
|
|
WINED3DFMT_UNKNOWN, WINED3D_SCANLINE_ORDERING_UNKNOWN);
|
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
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_EnumAdapterModes(IDirect3D8 *iface, UINT adapter, UINT mode_idx, D3DDISPLAYMODE *mode)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
2012-06-27 19:02:27 +02:00
|
|
|
struct wined3d_display_mode wined3d_mode;
|
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",
|
2012-05-03 21:49:37 +02:00
|
|
|
iface, adapter, mode_idx, mode);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-07-02 14:45:56 +02:00
|
|
|
hr = wined3d_enum_adapter_modes(d3d8->wined3d, adapter, WINED3DFMT_UNKNOWN,
|
|
|
|
WINED3D_SCANLINE_ORDERING_UNKNOWN, mode_idx, &wined3d_mode);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-02-19 16:59:41 +01:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2012-06-27 19:02:27 +02:00
|
|
|
{
|
|
|
|
mode->Width = wined3d_mode.width;
|
|
|
|
mode->Height = wined3d_mode.height;
|
|
|
|
mode->RefreshRate = wined3d_mode.refresh_rate;
|
|
|
|
mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
|
|
|
|
}
|
2009-02-19 16:59:41 +01:00
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_GetAdapterDisplayMode(IDirect3D8 *iface, UINT adapter, D3DDISPLAYMODE *mode)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
2012-06-27 19:02:27 +02:00
|
|
|
struct wined3d_display_mode wined3d_mode;
|
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",
|
2012-05-03 21:49:37 +02:00
|
|
|
iface, adapter, mode);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-06-27 19:02:28 +02:00
|
|
|
hr = wined3d_get_adapter_display_mode(d3d8->wined3d, adapter, &wined3d_mode, NULL);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-02-19 16:59:41 +01:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2012-06-27 19:02:27 +02:00
|
|
|
{
|
|
|
|
mode->Width = wined3d_mode.width;
|
|
|
|
mode->Height = wined3d_mode.height;
|
|
|
|
mode->RefreshRate = wined3d_mode.refresh_rate;
|
|
|
|
mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
|
|
|
|
}
|
2009-02-19 16:59:41 +01:00
|
|
|
|
2007-05-23 00:33:42 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_CheckDeviceType(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
|
|
|
|
D3DFORMAT display_format, D3DFORMAT backbuffer_format, BOOL windowed)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(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",
|
2012-05-03 21:49:37 +02:00
|
|
|
iface, adapter, device_type, display_format, backbuffer_format, windowed);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-05-03 21:49:37 +02:00
|
|
|
hr = wined3d_check_device_type(d3d8->wined3d, adapter, device_type, wined3dformat_from_d3dformat(display_format),
|
|
|
|
wined3dformat_from_d3dformat(backbuffer_format), 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
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_CheckDeviceFormat(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
|
|
|
|
D3DFORMAT adapter_format, DWORD usage, D3DRESOURCETYPE resource_type, D3DFORMAT format)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
2012-01-17 21:13:36 +01:00
|
|
|
enum wined3d_resource_type wined3d_rtype;
|
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, usage %#x, resource_type %#x, format %#x.\n",
|
2012-05-03 21:49:37 +02:00
|
|
|
iface, adapter, device_type, adapter_format, usage, resource_type, format);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
switch (resource_type)
|
|
|
|
{
|
2009-04-06 16:44:00 +02:00
|
|
|
case D3DRTYPE_VERTEXBUFFER:
|
|
|
|
case D3DRTYPE_INDEXBUFFER:
|
2012-01-17 21:13:36 +01:00
|
|
|
wined3d_rtype = WINED3D_RTYPE_BUFFER;
|
2009-04-06 16:44:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-05-03 21:49:37 +02:00
|
|
|
wined3d_rtype = resource_type;
|
2009-04-06 16:44:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-05-03 21:49:37 +02:00
|
|
|
hr = wined3d_check_device_format(d3d8->wined3d, adapter, device_type, wined3dformat_from_d3dformat(adapter_format),
|
2013-01-17 10:24:28 +01:00
|
|
|
usage, wined3d_rtype, wined3dformat_from_d3dformat(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
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
|
|
|
|
D3DFORMAT format, BOOL windowed, D3DMULTISAMPLE_TYPE multisample_type)
|
2009-08-25 08:17:13 +02:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(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",
|
2012-05-03 21:49:37 +02:00
|
|
|
iface, adapter, device_type, format, windowed, multisample_type);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-05-03 21:49:37 +02:00
|
|
|
hr = wined3d_check_device_multisample_type(d3d8->wined3d, adapter, device_type,
|
|
|
|
wined3dformat_from_d3dformat(format), windowed,
|
|
|
|
(enum wined3d_multisample_type)multisample_type, 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
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_CheckDepthStencilMatch(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
|
|
|
|
D3DFORMAT adapter_format, D3DFORMAT rt_format, D3DFORMAT ds_format)
|
2009-08-25 08:17:13 +02:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(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",
|
2012-05-03 21:49:37 +02:00
|
|
|
iface, adapter, device_type, adapter_format, rt_format, ds_format);
|
2007-05-23 00:33:42 +02:00
|
|
|
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-05-03 21:49:37 +02:00
|
|
|
hr = wined3d_check_depth_stencil_match(d3d8->wined3d, adapter, device_type,
|
|
|
|
wined3dformat_from_d3dformat(adapter_format), wined3dformat_from_d3dformat(rt_format),
|
|
|
|
wined3dformat_from_d3dformat(ds_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
|
|
|
}
|
|
|
|
|
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 */
|
2011-10-25 16:58:44 +02:00
|
|
|
if (caps->PixelShaderVersion)
|
2009-08-07 12:17:41 +02:00
|
|
|
caps->PixelShaderVersion = D3DPS_VERSION(1,4);
|
2011-10-25 16:58:44 +02:00
|
|
|
else
|
|
|
|
caps->PixelShaderVersion = D3DPS_VERSION(0,0);
|
|
|
|
if (caps->VertexShaderVersion)
|
2009-08-07 12:17:41 +02:00
|
|
|
caps->VertexShaderVersion = D3DVS_VERSION(1,1);
|
2011-10-25 16:58:44 +02:00
|
|
|
else
|
|
|
|
caps->VertexShaderVersion = D3DVS_VERSION(0,0);
|
2009-08-07 12:17:41 +02:00
|
|
|
caps->MaxVertexShaderConst = min(D3D8_MAX_VERTEX_SHADER_CONSTANTF, caps->MaxVertexShaderConst);
|
|
|
|
|
|
|
|
caps->StencilCaps &= ~WINED3DSTENCILCAPS_TWOSIDED;
|
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_GetDeviceCaps(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type, D3DCAPS8 *caps)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
|
|
|
WINED3DCAPS *wined3d_caps;
|
|
|
|
HRESULT hr;
|
2005-06-17 11:59:03 +02:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, adapter, device_type, caps);
|
2005-06-17 11:59:03 +02:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
if (!caps)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
|
|
|
if (!(wined3d_caps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wined3d_caps))))
|
2005-06-17 11:59:03 +02:00
|
|
|
return D3DERR_INVALIDCALL;
|
2009-08-25 08:17:14 +02:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2012-05-03 21:49:37 +02:00
|
|
|
hr = wined3d_get_device_caps(d3d8->wined3d, adapter, device_type, wined3d_caps);
|
2009-08-25 08:17:14 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
fixup_caps(wined3d_caps);
|
|
|
|
WINECAPSTOD3D8CAPS(caps, wined3d_caps)
|
|
|
|
HeapFree(GetProcessHeap(), 0, wined3d_caps);
|
2006-12-23 14:41:53 +01:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
return hr;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HMONITOR WINAPI d3d8_GetAdapterMonitor(IDirect3D8 *iface, UINT adapter)
|
2011-01-23 21:49:42 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
2007-05-23 00:33:42 +02:00
|
|
|
HMONITOR ret;
|
2009-10-19 10:12:20 +02:00
|
|
|
|
2012-05-03 21:49:37 +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();
|
2012-05-03 21:49:37 +02:00
|
|
|
ret = wined3d_get_adapter_monitor(d3d8->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
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static HRESULT WINAPI d3d8_CreateDevice(IDirect3D8 *iface, UINT adapter,
|
2011-01-23 21:49:42 +01:00
|
|
|
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
|
|
|
|
IDirect3DDevice8 **device)
|
2009-11-17 09:43:14 +01:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
|
2012-05-21 20:48:36 +02:00
|
|
|
struct d3d8_device *object;
|
2006-02-25 13:15:08 +01:00
|
|
|
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",
|
2009-11-17 09:43:14 +01:00
|
|
|
iface, adapter, device_type, focus_window, flags, parameters, device);
|
2006-02-25 13:15:08 +01:00
|
|
|
|
2009-11-17 09:43:14 +01:00
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate device memory.\n");
|
|
|
|
return E_OUTOFMEMORY;
|
2002-12-18 06:05:41 +01:00
|
|
|
}
|
2006-02-25 13:15:08 +01:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
hr = device_init(object, d3d8, d3d8->wined3d, adapter, device_type, focus_window, flags, parameters);
|
2009-11-17 09:43:14 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize device, hr %#x.\n", hr);
|
2006-04-12 21:08:57 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-11-17 09:43:14 +01:00
|
|
|
TRACE("Created device %p.\n", object);
|
2011-01-28 01:17:54 +01:00
|
|
|
*device = &object->IDirect3DDevice8_iface;
|
2007-02-15 22:36:50 +01:00
|
|
|
|
2009-10-20 10:20:18 +02:00
|
|
|
return D3D_OK;
|
2002-09-28 00:46:16 +02:00
|
|
|
}
|
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
static const struct IDirect3D8Vtbl d3d8_vtbl =
|
2002-09-28 00:46:16 +02:00
|
|
|
{
|
2006-02-25 13:15:08 +01:00
|
|
|
/* IUnknown */
|
2012-05-03 21:49:37 +02:00
|
|
|
d3d8_QueryInterface,
|
|
|
|
d3d8_AddRef,
|
|
|
|
d3d8_Release,
|
2006-02-25 13:15:08 +01:00
|
|
|
/* IDirect3D8 */
|
2012-05-03 21:49:37 +02:00
|
|
|
d3d8_RegisterSoftwareDevice,
|
|
|
|
d3d8_GetAdapterCount,
|
|
|
|
d3d8_GetAdapterIdentifier,
|
|
|
|
d3d8_GetAdapterModeCount,
|
|
|
|
d3d8_EnumAdapterModes,
|
|
|
|
d3d8_GetAdapterDisplayMode,
|
|
|
|
d3d8_CheckDeviceType,
|
|
|
|
d3d8_CheckDeviceFormat,
|
|
|
|
d3d8_CheckDeviceMultiSampleType,
|
|
|
|
d3d8_CheckDepthStencilMatch,
|
|
|
|
d3d8_GetDeviceCaps,
|
|
|
|
d3d8_GetAdapterMonitor,
|
|
|
|
d3d8_CreateDevice,
|
2002-09-28 00:46:16 +02:00
|
|
|
};
|
2012-05-03 21:49:36 +02:00
|
|
|
|
2012-05-03 21:49:37 +02:00
|
|
|
BOOL d3d8_init(struct d3d8 *d3d8)
|
2012-05-03 21:49:36 +02:00
|
|
|
{
|
2012-05-03 21:49:37 +02:00
|
|
|
d3d8->IDirect3D8_iface.lpVtbl = &d3d8_vtbl;
|
|
|
|
d3d8->refcount = 1;
|
2012-05-03 21:49:36 +02:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2012-05-03 21:49:37 +02:00
|
|
|
d3d8->wined3d = wined3d_create(8, WINED3D_LEGACY_DEPTH_BIAS);
|
2012-05-03 21:49:36 +02:00
|
|
|
wined3d_mutex_unlock();
|
2012-05-03 21:49:37 +02:00
|
|
|
if (!d3d8->wined3d)
|
2012-05-03 21:49:36 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|