2003-07-01 03:09:17 +02:00
|
|
|
/*
|
|
|
|
* IDirect3D9 implementation
|
|
|
|
*
|
|
|
|
* Copyright 2002 Jason Edmeades
|
2005-06-17 11:59:03 +02:00
|
|
|
* Copyright 2005 Oliver Stieber
|
2003-07-01 03:09:17 +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
|
2003-07-01 03:09:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "d3d9_private.h"
|
|
|
|
|
2005-08-23 11:34:57 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
|
2003-07-01 03:09:17 +02:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static inline struct d3d9 *impl_from_IDirect3D9Ex(IDirect3D9Ex *iface)
|
2003-07-01 03:09:17 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3d9, IDirect3D9Ex_iface);
|
2011-04-10 22:20:18 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_QueryInterface(IDirect3D9Ex *iface, REFIID riid, void **out)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2003-07-01 03:09:17 +02:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2012-03-12 19:56:06 +01:00
|
|
|
if (IsEqualGUID(riid, &IID_IDirect3D9)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
IDirect3D9Ex_AddRef(&d3d9->IDirect3D9Ex_iface);
|
2012-05-25 16:10:31 +02:00
|
|
|
*out = &d3d9->IDirect3D9Ex_iface;
|
2006-06-07 15:13:29 +02:00
|
|
|
return S_OK;
|
2012-03-12 19:56:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IDirect3D9Ex))
|
|
|
|
{
|
|
|
|
if (!d3d9->extended)
|
|
|
|
{
|
|
|
|
WARN("Application asks for IDirect3D9Ex, but this instance wasn't created with Direct3DCreate9Ex.\n");
|
2012-05-25 16:10:31 +02:00
|
|
|
*out = NULL;
|
2008-02-28 21:25:35 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2012-03-12 19:56:06 +01:00
|
|
|
|
|
|
|
IDirect3D9Ex_AddRef(&d3d9->IDirect3D9Ex_iface);
|
2012-05-25 16:10:31 +02:00
|
|
|
*out = &d3d9->IDirect3D9Ex_iface;
|
2012-03-12 19:56:06 +01:00
|
|
|
return S_OK;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-03-12 19:56:06 +01:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
*out = NULL;
|
2003-07-01 03:09:17 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static ULONG WINAPI d3d9_AddRef(IDirect3D9Ex *iface)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&d3d9->refcount);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
return refcount;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static ULONG WINAPI d3d9_Release(IDirect3D9Ex *iface)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&d3d9->refcount);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
wined3d_decref(d3d9->wined3d);
|
2009-08-26 10:18:09 +02:00
|
|
|
|
2020-03-03 15:18:46 +01:00
|
|
|
heap_free(d3d9->wined3d_outputs);
|
2018-02-06 23:41:32 +01:00
|
|
|
heap_free(d3d9);
|
2004-09-28 04:12:12 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
return refcount;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_RegisterSoftwareDevice(IDirect3D9Ex *iface, void *init_function)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2007-06-10 17:32:37 +02:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
TRACE("iface %p, init_function %p.\n", iface, init_function);
|
2007-06-10 17:32:37 +02:00
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2012-05-25 16:10:31 +02:00
|
|
|
hr = wined3d_register_software_device(d3d9->wined3d, init_function);
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-06-10 17:32:37 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static UINT WINAPI d3d9_GetAdapterCount(IDirect3D9Ex *iface)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2009-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2007-06-10 17:32:37 +02:00
|
|
|
|
2020-03-03 15:18:46 +01:00
|
|
|
return d3d9->wined3d_output_count;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT adapter,
|
|
|
|
DWORD flags, D3DADAPTER_IDENTIFIER9 *identifier)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2011-11-23 21:14:57 +01:00
|
|
|
struct wined3d_adapter_identifier adapter_id;
|
2020-03-10 10:35:09 +01:00
|
|
|
struct wined3d_adapter *wined3d_adapter;
|
2020-03-25 10:51:09 +01:00
|
|
|
struct wined3d_output_desc output_desc;
|
2020-03-10 10:35:09 +01:00
|
|
|
unsigned int output_idx;
|
2007-06-10 17:32:37 +02:00
|
|
|
HRESULT hr;
|
2004-09-29 23:26:47 +02:00
|
|
|
|
2009-10-20 11:05:02 +02:00
|
|
|
TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n",
|
2012-05-25 16:10:31 +02:00
|
|
|
iface, adapter, flags, identifier);
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2020-03-10 10:35:09 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2020-03-25 10:51:09 +01:00
|
|
|
wined3d_mutex_lock();
|
|
|
|
if (FAILED(hr = wined3d_output_get_desc(d3d9->wined3d_outputs[output_idx], &output_desc)))
|
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
WARN("Failed to get output description, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, output_desc.device_name, -1, identifier->DeviceName,
|
|
|
|
sizeof(identifier->DeviceName), NULL, NULL);
|
|
|
|
|
2012-05-25 16:10:31 +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);
|
2004-09-29 23:26:47 +02:00
|
|
|
|
2020-03-10 10:35:09 +01:00
|
|
|
wined3d_adapter = wined3d_output_get_adapter(d3d9->wined3d_outputs[output_idx]);
|
|
|
|
if (SUCCEEDED(hr = wined3d_adapter_get_identifier(wined3d_adapter, flags, &adapter_id)))
|
2018-12-03 14:41:09 +01: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;
|
|
|
|
}
|
2020-03-25 10:51:09 +01:00
|
|
|
wined3d_mutex_unlock();
|
2009-07-07 11:08:03 +02:00
|
|
|
|
2007-06-10 17:32:37 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static UINT WINAPI d3d9_GetAdapterModeCount(IDirect3D9Ex *iface, UINT adapter, D3DFORMAT format)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2020-03-05 16:03:40 +01:00
|
|
|
unsigned int output_idx, count;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
TRACE("iface %p, adapter %u, format %#x.\n", iface, adapter, format);
|
2007-04-13 16:38:10 +02:00
|
|
|
|
2020-03-05 16:03:40 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return 0;
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
/* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out. */
|
|
|
|
if (format != D3DFMT_X8R8G8B8 && format != D3DFMT_R5G6B5)
|
2007-04-13 16:38:10 +02:00
|
|
|
return 0;
|
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-03-05 16:03:40 +01:00
|
|
|
count = wined3d_output_get_mode_count(d3d9->wined3d_outputs[output_idx],
|
2012-06-29 07:37:57 +02:00
|
|
|
wined3dformat_from_d3dformat(format), WINED3D_SCANLINE_ORDERING_UNKNOWN);
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2020-03-05 16:03:40 +01:00
|
|
|
return count;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_EnumAdapterModes(IDirect3D9Ex *iface, UINT adapter,
|
|
|
|
D3DFORMAT format, UINT mode_idx, D3DDISPLAYMODE *mode)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2012-06-27 19:02:27 +02:00
|
|
|
struct wined3d_display_mode wined3d_mode;
|
2020-03-05 16:03:23 +01:00
|
|
|
unsigned int output_idx;
|
2007-06-10 17:32:37 +02:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, format %#x, mode_idx %u, mode %p.\n",
|
2012-05-25 16:10:31 +02:00
|
|
|
iface, adapter, format, mode_idx, mode);
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2020-03-05 16:03:23 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
if (format != D3DFMT_X8R8G8B8 && format != D3DFMT_R5G6B5)
|
2006-12-20 13:44:08 +01:00
|
|
|
return D3DERR_INVALIDCALL;
|
2007-06-10 17:32:37 +02:00
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-03-05 16:03:23 +01:00
|
|
|
hr = wined3d_output_get_mode(d3d9->wined3d_outputs[output_idx],
|
|
|
|
wined3dformat_from_d3dformat(format), WINED3D_SCANLINE_ORDERING_UNKNOWN, mode_idx,
|
|
|
|
&wined3d_mode);
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-02-19 16:59:42 +01:00
|
|
|
|
2012-05-25 16:10:31 +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:42 +01:00
|
|
|
|
2007-06-10 17:32:37 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_GetAdapterDisplayMode(IDirect3D9Ex *iface, UINT adapter, D3DDISPLAYMODE *mode)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2012-06-27 19:02:27 +02:00
|
|
|
struct wined3d_display_mode wined3d_mode;
|
2020-03-06 14:16:29 +01:00
|
|
|
unsigned int output_idx;
|
2009-02-19 16:59:42 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
TRACE("iface %p, adapter %u, mode %p.\n", iface, adapter, mode);
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2020-03-06 14:16:29 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-03-06 14:16:29 +01:00
|
|
|
hr = wined3d_output_get_display_mode(d3d9->wined3d_outputs[output_idx], &wined3d_mode, NULL);
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-03-23 08:30:16 +01:00
|
|
|
|
2012-05-25 16:10:31 +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:42 +01:00
|
|
|
|
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_CheckDeviceType(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
|
|
|
|
D3DFORMAT display_format, D3DFORMAT backbuffer_format, BOOL windowed)
|
2009-08-26 10:18:08 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2020-03-09 08:40:53 +01:00
|
|
|
unsigned int output_idx;
|
2007-06-10 17:32:37 +02:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
|
2012-05-25 16:10:31 +02:00
|
|
|
iface, adapter, device_type, display_format, backbuffer_format, windowed);
|
2007-06-10 17:32:37 +02:00
|
|
|
|
2020-03-09 08:40:53 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2014-01-27 20:32:02 +01:00
|
|
|
/* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out. */
|
|
|
|
if (!windowed && display_format != D3DFMT_X8R8G8B8 && display_format != D3DFMT_R5G6B5)
|
|
|
|
return WINED3DERR_NOTAVAILABLE;
|
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-04-02 12:34:56 +02:00
|
|
|
hr = wined3d_check_device_type(d3d9->wined3d, d3d9->wined3d_outputs[output_idx],
|
|
|
|
wined3d_device_type_from_d3d(device_type), wined3dformat_from_d3dformat(display_format),
|
2012-05-25 16:10:31 +02:00
|
|
|
wined3dformat_from_d3dformat(backbuffer_format), windowed);
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-06-10 17:32:37 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
|
|
|
|
D3DFORMAT adapter_format, DWORD usage, D3DRESOURCETYPE resource_type, D3DFORMAT format)
|
2009-08-26 10:18:08 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2012-01-17 21:13:36 +01:00
|
|
|
enum wined3d_resource_type wined3d_rtype;
|
2020-03-10 10:35:20 +01:00
|
|
|
struct wined3d_adapter *wined3d_adapter;
|
2018-10-31 10:31:49 +01:00
|
|
|
unsigned int bind_flags;
|
2020-03-10 10:35:20 +01:00
|
|
|
unsigned int output_idx;
|
2007-06-10 17:32:37 +02:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
|
2012-05-25 16:10:31 +02:00
|
|
|
iface, adapter, device_type, adapter_format, usage, resource_type, format);
|
2007-06-10 17:32:37 +02:00
|
|
|
|
2020-03-10 10:35:20 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2019-03-05 18:47:21 +01:00
|
|
|
if (adapter_format != D3DFMT_X8R8G8B8 && adapter_format != D3DFMT_R5G6B5
|
|
|
|
&& adapter_format != D3DFMT_X1R5G5B5)
|
2018-04-17 14:26:53 +02:00
|
|
|
{
|
|
|
|
WARN("Invalid adapter format.\n");
|
2019-03-05 18:47:21 +01:00
|
|
|
return adapter_format ? D3DERR_NOTAVAILABLE : D3DERR_INVALIDCALL;
|
2018-04-17 14:26:53 +02:00
|
|
|
}
|
|
|
|
|
2018-10-31 10:31:49 +01:00
|
|
|
bind_flags = wined3d_bind_flags_from_d3d9_usage(usage);
|
2016-01-27 00:06:23 +01:00
|
|
|
usage = usage & (WINED3DUSAGE_MASK | WINED3DUSAGE_QUERY_MASK);
|
2012-05-25 16:10:31 +02:00
|
|
|
switch (resource_type)
|
|
|
|
{
|
2016-04-18 19:06:31 +02:00
|
|
|
case D3DRTYPE_CUBETEXTURE:
|
|
|
|
usage |= WINED3DUSAGE_LEGACY_CUBEMAP;
|
2016-01-27 00:06:23 +01:00
|
|
|
case D3DRTYPE_TEXTURE:
|
2018-10-31 10:31:49 +01:00
|
|
|
bind_flags |= WINED3D_BIND_SHADER_RESOURCE;
|
2016-04-18 19:06:31 +02:00
|
|
|
case D3DRTYPE_SURFACE:
|
2016-01-27 00:06:23 +01:00
|
|
|
wined3d_rtype = WINED3D_RTYPE_TEXTURE_2D;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D3DRTYPE_VOLUMETEXTURE:
|
2016-04-18 19:06:31 +02:00
|
|
|
case D3DRTYPE_VOLUME:
|
2018-10-31 10:31:49 +01:00
|
|
|
bind_flags |= WINED3D_BIND_SHADER_RESOURCE;
|
2016-01-27 00:06:24 +01:00
|
|
|
wined3d_rtype = WINED3D_RTYPE_TEXTURE_3D;
|
2016-01-27 00:06:23 +01:00
|
|
|
break;
|
|
|
|
|
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:
|
2016-01-27 00:06:23 +01:00
|
|
|
FIXME("Unhandled resource type %#x.\n", resource_type);
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2009-04-06 16:44:00 +02:00
|
|
|
}
|
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-03-10 10:35:35 +01:00
|
|
|
wined3d_adapter = wined3d_output_get_adapter(d3d9->wined3d_outputs[output_idx]);
|
2020-01-27 16:23:14 +01:00
|
|
|
if (format == D3DFMT_RESZ && resource_type == D3DRTYPE_SURFACE && usage == D3DUSAGE_RENDERTARGET)
|
|
|
|
{
|
|
|
|
DWORD levels;
|
2020-03-10 10:35:20 +01:00
|
|
|
|
2020-04-02 12:34:56 +02:00
|
|
|
hr = wined3d_check_device_multisample_type(wined3d_adapter, wined3d_device_type_from_d3d(device_type),
|
2020-01-27 16:23:14 +01:00
|
|
|
WINED3DFMT_D24_UNORM_S8_UINT, FALSE, WINED3D_MULTISAMPLE_NON_MASKABLE, &levels);
|
|
|
|
if (SUCCEEDED(hr) && !levels)
|
|
|
|
hr = D3DERR_NOTAVAILABLE;
|
|
|
|
}
|
|
|
|
else
|
2020-04-02 12:34:56 +02:00
|
|
|
hr = wined3d_check_device_format(d3d9->wined3d, wined3d_adapter, wined3d_device_type_from_d3d(device_type),
|
2020-01-27 16:23:14 +01:00
|
|
|
wined3dformat_from_d3dformat(adapter_format), usage, bind_flags,
|
|
|
|
wined3d_rtype, wined3dformat_from_d3dformat(format));
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-06-10 17:32:37 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_CheckDeviceMultiSampleType(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
|
|
|
|
D3DFORMAT format, BOOL windowed, D3DMULTISAMPLE_TYPE multisample_type, DWORD *levels)
|
2009-08-26 10:18:08 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2020-03-10 10:35:20 +01:00
|
|
|
struct wined3d_adapter *wined3d_adapter;
|
|
|
|
unsigned int output_idx;
|
2007-06-10 17:32:37 +02:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x, levels %p.\n",
|
2012-05-25 16:10:31 +02:00
|
|
|
iface, adapter, device_type, format, windowed, multisample_type, levels);
|
2007-06-10 17:32:37 +02:00
|
|
|
|
2020-03-10 10:35:20 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2016-02-04 20:10:43 +01:00
|
|
|
if (multisample_type > D3DMULTISAMPLE_16_SAMPLES)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-03-10 10:35:20 +01:00
|
|
|
wined3d_adapter = wined3d_output_get_adapter(d3d9->wined3d_outputs[output_idx]);
|
2020-04-02 12:34:56 +02:00
|
|
|
hr = wined3d_check_device_multisample_type(wined3d_adapter,
|
|
|
|
wined3d_device_type_from_d3d(device_type), wined3dformat_from_d3dformat(format),
|
2020-04-02 12:34:54 +02:00
|
|
|
windowed, wined3d_multisample_type_from_d3d(multisample_type), levels);
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
2016-01-26 22:51:33 +01:00
|
|
|
if (hr == WINED3DERR_NOTAVAILABLE && levels)
|
|
|
|
*levels = 1;
|
2009-08-26 10:18:09 +02:00
|
|
|
|
2007-06-10 17:32:37 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_CheckDepthStencilMatch(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
|
|
|
|
D3DFORMAT adapter_format, D3DFORMAT rt_format, D3DFORMAT ds_format)
|
2009-08-26 10:18:08 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2020-03-09 08:41:33 +01:00
|
|
|
struct wined3d_adapter *wined3d_adapter;
|
|
|
|
unsigned int output_idx;
|
2007-06-10 17:32:37 +02:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
|
2012-05-25 16:10:31 +02:00
|
|
|
iface, adapter, device_type, adapter_format, rt_format, ds_format);
|
2007-06-10 17:32:37 +02:00
|
|
|
|
2020-03-09 08:41:33 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-03-09 08:41:33 +01:00
|
|
|
wined3d_adapter = wined3d_output_get_adapter(d3d9->wined3d_outputs[output_idx]);
|
2020-04-02 12:34:56 +02:00
|
|
|
hr = wined3d_check_depth_stencil_match(wined3d_adapter,
|
|
|
|
wined3d_device_type_from_d3d(device_type), wined3dformat_from_d3dformat(adapter_format),
|
|
|
|
wined3dformat_from_d3dformat(rt_format), wined3dformat_from_d3dformat(ds_format));
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-06-10 17:32:37 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_CheckDeviceFormatConversion(IDirect3D9Ex *iface, UINT adapter,
|
|
|
|
D3DDEVTYPE device_type, D3DFORMAT src_format, D3DFORMAT dst_format)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2020-03-09 08:40:40 +01:00
|
|
|
unsigned int output_idx;
|
2007-06-10 17:32:37 +02:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, src_format %#x, dst_format %#x.\n",
|
2012-05-25 16:10:31 +02:00
|
|
|
iface, adapter, device_type, src_format, dst_format);
|
2007-06-10 17:32:37 +02:00
|
|
|
|
2020-03-09 08:40:40 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-03-09 08:40:40 +01:00
|
|
|
hr = wined3d_check_device_format_conversion(d3d9->wined3d_outputs[output_idx],
|
2020-04-02 12:34:56 +02:00
|
|
|
wined3d_device_type_from_d3d(device_type), wined3dformat_from_d3dformat(src_format),
|
2020-03-09 08:40:40 +01:00
|
|
|
wined3dformat_from_d3dformat(dst_format));
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-06-10 17:32:37 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_GetDeviceCaps(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type, D3DCAPS9 *caps)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2020-03-13 10:35:29 +01:00
|
|
|
struct wined3d_adapter *wined3d_adapter;
|
2018-06-13 12:23:59 +02:00
|
|
|
struct wined3d_caps wined3d_caps;
|
2020-03-13 10:35:29 +01:00
|
|
|
unsigned int output_idx;
|
2012-05-25 16:10:31 +02:00
|
|
|
HRESULT hr;
|
2005-06-17 11:59:03 +02:00
|
|
|
|
2012-05-25 16:10:31 +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
|
|
|
|
2020-03-13 10:35:29 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
if (!caps)
|
2005-06-17 11:59:03 +02:00
|
|
|
return D3DERR_INVALIDCALL;
|
2012-05-25 16:10:31 +02:00
|
|
|
|
|
|
|
memset(caps, 0, sizeof(*caps));
|
2009-08-26 10:18:09 +02:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2020-03-13 10:35:29 +01:00
|
|
|
wined3d_adapter = wined3d_output_get_adapter(d3d9->wined3d_outputs[output_idx]);
|
2020-04-02 12:34:56 +02:00
|
|
|
hr = wined3d_get_device_caps(wined3d_adapter, wined3d_device_type_from_d3d(device_type), &wined3d_caps);
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2020-03-19 10:08:09 +01:00
|
|
|
d3d9_caps_from_wined3dcaps(d3d9, adapter, caps, &wined3d_caps);
|
2007-01-12 00:08:29 +01:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
return hr;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HMONITOR WINAPI d3d9_GetAdapterMonitor(IDirect3D9Ex *iface, UINT adapter)
|
2011-04-10 22:20:18 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2015-11-24 18:06:17 +01:00
|
|
|
struct wined3d_output_desc desc;
|
2020-03-19 10:07:30 +01:00
|
|
|
unsigned int output_idx;
|
2015-11-24 18:06:17 +01:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
TRACE("iface %p, adapter %u.\n", iface, adapter);
|
2007-06-10 17:32:37 +02:00
|
|
|
|
2020-03-19 10:07:30 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return NULL;
|
|
|
|
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-03-19 10:07:30 +01:00
|
|
|
hr = wined3d_output_get_desc(d3d9->wined3d_outputs[output_idx], &desc);
|
2009-08-26 10:18:09 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2015-11-24 18:06:17 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to get output desc, hr %#x.\n", hr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return desc.monitor;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDevice(IDirect3D9Ex *iface, UINT adapter,
|
2009-11-18 10:45:50 +01:00
|
|
|
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
|
|
|
|
IDirect3DDevice9 **device)
|
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2012-05-28 18:17:28 +02:00
|
|
|
struct d3d9_device *object;
|
2005-06-23 13:05:24 +02:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n",
|
2009-11-18 10:45:50 +01:00
|
|
|
iface, adapter, device_type, focus_window, flags, parameters, device);
|
2006-04-12 21:08:57 +02:00
|
|
|
|
2018-02-06 23:41:32 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2009-11-18 10:45:50 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2007-02-15 22:36:50 +01:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, NULL);
|
2009-11-18 10:45:50 +01:00
|
|
|
if (FAILED(hr))
|
2009-03-11 10:15:10 +01:00
|
|
|
{
|
2009-11-18 10:45:50 +01:00
|
|
|
WARN("Failed to initialize device, hr %#x.\n", hr);
|
2018-02-06 23:41:32 +01:00
|
|
|
heap_free(object);
|
2009-11-18 10:45:50 +01:00
|
|
|
return hr;
|
2005-06-23 13:05:24 +02:00
|
|
|
}
|
2009-03-11 10:15:10 +01:00
|
|
|
|
2009-11-18 10:45:50 +01:00
|
|
|
TRACE("Created device %p.\n", object);
|
2016-09-07 13:17:19 +02:00
|
|
|
*device = (IDirect3DDevice9 *)&object->IDirect3DDevice9Ex_iface;
|
2007-03-04 17:03:03 +01:00
|
|
|
|
2009-11-18 10:45:50 +01:00
|
|
|
return D3D_OK;
|
2003-07-01 03:09:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static UINT WINAPI d3d9_GetAdapterModeCountEx(IDirect3D9Ex *iface,
|
2009-10-20 11:05:02 +02:00
|
|
|
UINT adapter, const D3DDISPLAYMODEFILTER *filter)
|
|
|
|
{
|
2012-06-29 07:37:57 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2020-03-05 16:03:40 +01:00
|
|
|
unsigned int output_idx, count;
|
2012-06-29 07:37:57 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, filter %p.\n", iface, adapter, filter);
|
|
|
|
|
2020-03-05 16:03:40 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return 0;
|
|
|
|
|
2012-06-29 07:37:57 +02:00
|
|
|
if (filter->Format != D3DFMT_X8R8G8B8 && filter->Format != D3DFMT_R5G6B5)
|
|
|
|
return 0;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2012-06-29 07:37:57 +02:00
|
|
|
wined3d_mutex_lock();
|
2020-03-05 16:03:40 +01:00
|
|
|
count = wined3d_output_get_mode_count(d3d9->wined3d_outputs[output_idx],
|
2020-04-02 12:34:55 +02:00
|
|
|
wined3dformat_from_d3dformat(filter->Format), wined3d_scanline_ordering_from_d3d(filter->ScanLineOrdering));
|
2012-06-29 07:37:57 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2020-03-05 16:03:40 +01:00
|
|
|
return count;
|
2008-02-28 21:10:46 +01:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_EnumAdapterModesEx(IDirect3D9Ex *iface,
|
2009-10-20 11:05:02 +02:00
|
|
|
UINT adapter, const D3DDISPLAYMODEFILTER *filter, UINT mode_idx, D3DDISPLAYMODEEX *mode)
|
|
|
|
{
|
2012-07-02 14:45:56 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
|
|
|
struct wined3d_display_mode wined3d_mode;
|
2020-03-05 16:03:23 +01:00
|
|
|
unsigned int output_idx;
|
2012-07-02 14:45:56 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, filter %p, mode_idx %u, mode %p.\n",
|
2009-10-20 11:05:02 +02:00
|
|
|
iface, adapter, filter, mode_idx, mode);
|
|
|
|
|
2020-03-05 16:03:23 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2012-07-02 14:45:56 +02:00
|
|
|
if (filter->Format != D3DFMT_X8R8G8B8 && filter->Format != D3DFMT_R5G6B5)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2020-04-02 12:34:55 +02:00
|
|
|
hr = wined3d_output_get_mode(d3d9->wined3d_outputs[output_idx], wined3dformat_from_d3dformat(filter->Format),
|
|
|
|
wined3d_scanline_ordering_from_d3d(filter->ScanLineOrdering), mode_idx, &wined3d_mode);
|
2012-07-02 14:45:56 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
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);
|
2020-04-02 12:34:55 +02:00
|
|
|
mode->ScanLineOrdering = d3dscanlineordering_from_wined3d(wined3d_mode.scanline_ordering);
|
2012-07-02 14:45:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2008-02-28 21:10:46 +01:00
|
|
|
}
|
2005-06-23 13:05:24 +02:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_GetAdapterDisplayModeEx(IDirect3D9Ex *iface,
|
2009-10-20 11:05:02 +02:00
|
|
|
UINT adapter, D3DDISPLAYMODEEX *mode, D3DDISPLAYROTATION *rotation)
|
|
|
|
{
|
2012-06-27 19:02:28 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
|
|
|
struct wined3d_display_mode wined3d_mode;
|
2020-03-06 14:16:29 +01:00
|
|
|
unsigned int output_idx;
|
2012-06-27 19:02:28 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, mode %p, rotation %p.\n",
|
2009-10-20 11:05:02 +02:00
|
|
|
iface, adapter, mode, rotation);
|
|
|
|
|
2020-03-06 14:16:29 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2012-06-27 19:02:28 +02:00
|
|
|
if (mode->Size != sizeof(*mode))
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2020-03-06 14:16:29 +01:00
|
|
|
hr = wined3d_output_get_display_mode(d3d9->wined3d_outputs[output_idx], &wined3d_mode,
|
2012-06-27 19:02:28 +02:00
|
|
|
(enum wined3d_display_rotation *)rotation);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
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);
|
2020-04-02 12:34:55 +02:00
|
|
|
mode->ScanLineOrdering = d3dscanlineordering_from_wined3d(wined3d_mode.scanline_ordering);
|
2012-06-27 19:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2008-02-28 21:10:46 +01:00
|
|
|
}
|
2005-06-23 13:05:24 +02:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDeviceEx(IDirect3D9Ex *iface,
|
2009-10-20 11:05:02 +02:00
|
|
|
UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags,
|
|
|
|
D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode, IDirect3DDevice9Ex **device)
|
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2012-05-28 18:17:28 +02:00
|
|
|
struct d3d9_device *object;
|
2010-10-27 11:36:16 +02:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2010-10-27 11:36:16 +02:00
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, mode %p, device %p.\n",
|
|
|
|
iface, adapter, device_type, focus_window, flags, parameters, mode, device);
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2018-02-06 23:41:32 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2010-10-27 11:36:16 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags, parameters, mode);
|
2010-10-27 11:36:16 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize device, hr %#x.\n", hr);
|
2018-02-06 23:41:32 +01:00
|
|
|
heap_free(object);
|
2010-10-27 11:36:16 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created device %p.\n", object);
|
2011-04-24 21:34:30 +02:00
|
|
|
*device = &object->IDirect3DDevice9Ex_iface;
|
2010-10-27 11:36:16 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
2008-02-28 21:10:46 +01:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static HRESULT WINAPI d3d9_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUID *luid)
|
2009-10-20 11:05:02 +02:00
|
|
|
{
|
2012-05-25 16:10:31 +02:00
|
|
|
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
|
2011-11-23 21:14:57 +01:00
|
|
|
struct wined3d_adapter_identifier adapter_id;
|
2020-03-10 10:35:09 +01:00
|
|
|
struct wined3d_adapter *wined3d_adapter;
|
|
|
|
unsigned int output_idx;
|
2009-12-02 10:41:23 +01:00
|
|
|
HRESULT hr;
|
2009-10-20 11:05:02 +02:00
|
|
|
|
2009-12-02 10:41:23 +01:00
|
|
|
TRACE("iface %p, adapter %u, luid %p.\n", iface, adapter, luid);
|
|
|
|
|
2020-03-10 10:35:09 +01:00
|
|
|
output_idx = adapter;
|
|
|
|
if (output_idx >= d3d9->wined3d_output_count)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2009-12-02 10:41:23 +01:00
|
|
|
adapter_id.driver_size = 0;
|
|
|
|
adapter_id.description_size = 0;
|
|
|
|
|
2020-03-10 10:35:09 +01:00
|
|
|
wined3d_adapter = wined3d_output_get_adapter(d3d9->wined3d_outputs[output_idx]);
|
|
|
|
if (SUCCEEDED(hr = wined3d_adapter_get_identifier(wined3d_adapter, 0, &adapter_id)))
|
2018-12-03 14:41:08 +01:00
|
|
|
*luid = adapter_id.adapter_luid;
|
2009-12-02 10:41:23 +01:00
|
|
|
|
|
|
|
return hr;
|
2008-02-28 21:10:46 +01:00
|
|
|
}
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
static const struct IDirect3D9ExVtbl d3d9_vtbl =
|
2003-07-01 03:09:17 +02:00
|
|
|
{
|
2005-08-23 11:34:57 +02:00
|
|
|
/* IUnknown */
|
2012-05-25 16:10:31 +02:00
|
|
|
d3d9_QueryInterface,
|
|
|
|
d3d9_AddRef,
|
|
|
|
d3d9_Release,
|
2005-08-23 11:34:57 +02:00
|
|
|
/* IDirect3D9 */
|
2012-05-25 16:10:31 +02:00
|
|
|
d3d9_RegisterSoftwareDevice,
|
|
|
|
d3d9_GetAdapterCount,
|
|
|
|
d3d9_GetAdapterIdentifier,
|
|
|
|
d3d9_GetAdapterModeCount,
|
|
|
|
d3d9_EnumAdapterModes,
|
|
|
|
d3d9_GetAdapterDisplayMode,
|
|
|
|
d3d9_CheckDeviceType,
|
|
|
|
d3d9_CheckDeviceFormat,
|
|
|
|
d3d9_CheckDeviceMultiSampleType,
|
|
|
|
d3d9_CheckDepthStencilMatch,
|
|
|
|
d3d9_CheckDeviceFormatConversion,
|
|
|
|
d3d9_GetDeviceCaps,
|
|
|
|
d3d9_GetAdapterMonitor,
|
|
|
|
d3d9_CreateDevice,
|
2008-02-28 21:10:46 +01:00
|
|
|
/* IDirect3D9Ex */
|
2012-05-25 16:10:31 +02:00
|
|
|
d3d9_GetAdapterModeCountEx,
|
|
|
|
d3d9_EnumAdapterModesEx,
|
|
|
|
d3d9_GetAdapterDisplayModeEx,
|
|
|
|
d3d9_CreateDeviceEx,
|
|
|
|
d3d9_GetAdapterLUID,
|
2003-07-01 03:09:17 +02:00
|
|
|
};
|
2012-05-25 16:10:30 +02:00
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
|
2012-05-25 16:10:30 +02:00
|
|
|
{
|
2016-02-08 00:04:37 +01:00
|
|
|
DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
|
2016-12-07 12:43:01 +01:00
|
|
|
| WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR
|
2017-12-06 11:00:34 +01:00
|
|
|
| WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING
|
|
|
|
| WINED3D_NORMALIZED_DEPTH_BIAS;
|
2020-03-03 15:18:46 +01:00
|
|
|
unsigned int adapter_idx, output_idx, adapter_count, output_count = 0;
|
|
|
|
struct wined3d_adapter *wined3d_adapter;
|
2014-01-29 19:28:35 +01:00
|
|
|
|
|
|
|
if (!extended)
|
|
|
|
flags |= WINED3D_VIDMEM_ACCOUNTING;
|
2014-11-18 21:26:57 +01:00
|
|
|
else
|
|
|
|
flags |= WINED3D_RESTORE_MODE_ON_ACTIVATE;
|
|
|
|
|
2012-05-25 16:10:31 +02:00
|
|
|
d3d9->IDirect3D9Ex_iface.lpVtbl = &d3d9_vtbl;
|
|
|
|
d3d9->refcount = 1;
|
2012-05-25 16:10:30 +02:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2014-03-20 15:51:45 +01:00
|
|
|
d3d9->wined3d = wined3d_create(flags);
|
2012-05-25 16:10:31 +02:00
|
|
|
if (!d3d9->wined3d)
|
2020-03-03 15:18:46 +01:00
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
2012-05-25 16:10:30 +02:00
|
|
|
return FALSE;
|
2020-03-03 15:18:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
adapter_count = wined3d_get_adapter_count(d3d9->wined3d);
|
|
|
|
for (adapter_idx = 0; adapter_idx < adapter_count; ++adapter_idx)
|
|
|
|
{
|
|
|
|
wined3d_adapter = wined3d_get_adapter(d3d9->wined3d, adapter_idx);
|
|
|
|
output_count += wined3d_adapter_get_output_count(wined3d_adapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
d3d9->wined3d_outputs = heap_calloc(output_count, sizeof(*d3d9->wined3d_outputs));
|
|
|
|
if (!d3d9->wined3d_outputs)
|
|
|
|
{
|
|
|
|
wined3d_decref(d3d9->wined3d);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
d3d9->wined3d_output_count = 0;
|
|
|
|
for (adapter_idx = 0; adapter_idx < adapter_count; ++adapter_idx)
|
|
|
|
{
|
|
|
|
wined3d_adapter = wined3d_get_adapter(d3d9->wined3d, adapter_idx);
|
|
|
|
output_count = wined3d_adapter_get_output_count(wined3d_adapter);
|
|
|
|
for (output_idx = 0; output_idx < output_count; ++output_idx)
|
|
|
|
{
|
|
|
|
d3d9->wined3d_outputs[d3d9->wined3d_output_count] =
|
|
|
|
wined3d_adapter_get_output(wined3d_adapter, output_idx);
|
|
|
|
++d3d9->wined3d_output_count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wined3d_mutex_unlock();
|
2012-05-25 16:10:30 +02:00
|
|
|
d3d9->extended = extended;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|