2009-09-11 19:01:14 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Henri Verbeet for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include "dxgi_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
|
|
|
|
|
2020-05-10 23:43:06 +02:00
|
|
|
static inline DXGI_MODE_SCANLINE_ORDER dxgi_mode_scanline_order_from_wined3d(enum wined3d_scanline_ordering ordering)
|
|
|
|
{
|
|
|
|
return (DXGI_MODE_SCANLINE_ORDER)ordering;
|
|
|
|
}
|
|
|
|
|
2016-08-25 12:22:50 +02:00
|
|
|
static void dxgi_mode_from_wined3d(DXGI_MODE_DESC *mode, const struct wined3d_display_mode *wined3d_mode)
|
|
|
|
{
|
|
|
|
mode->Width = wined3d_mode->width;
|
|
|
|
mode->Height = wined3d_mode->height;
|
|
|
|
mode->RefreshRate.Numerator = wined3d_mode->refresh_rate;
|
|
|
|
mode->RefreshRate.Denominator = 1;
|
|
|
|
mode->Format = dxgi_format_from_wined3dformat(wined3d_mode->format_id);
|
2020-05-10 23:43:06 +02:00
|
|
|
mode->ScanlineOrdering = dxgi_mode_scanline_order_from_wined3d(wined3d_mode->scanline_ordering);
|
2016-08-25 12:22:50 +02:00
|
|
|
mode->Scaling = DXGI_MODE_SCALING_UNSPECIFIED; /* FIXME */
|
|
|
|
}
|
|
|
|
|
2019-03-06 14:19:54 +01:00
|
|
|
static void dxgi_mode1_from_wined3d(DXGI_MODE_DESC1 *mode, const struct wined3d_display_mode *wined3d_mode)
|
|
|
|
{
|
|
|
|
mode->Width = wined3d_mode->width;
|
|
|
|
mode->Height = wined3d_mode->height;
|
|
|
|
mode->RefreshRate.Numerator = wined3d_mode->refresh_rate;
|
|
|
|
mode->RefreshRate.Denominator = 1;
|
|
|
|
mode->Format = dxgi_format_from_wined3dformat(wined3d_mode->format_id);
|
2020-05-10 23:43:06 +02:00
|
|
|
mode->ScanlineOrdering = dxgi_mode_scanline_order_from_wined3d(wined3d_mode->scanline_ordering);
|
2019-03-06 14:19:54 +01:00
|
|
|
mode->Scaling = DXGI_MODE_SCALING_UNSPECIFIED; /* FIXME */
|
|
|
|
mode->Stereo = FALSE; /* FIXME */
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT dxgi_output_find_closest_matching_mode(struct dxgi_output *output,
|
|
|
|
struct wined3d_display_mode *mode, IUnknown *device)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!mode->width != !mode->height)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
|
|
|
if (mode->format_id == WINED3DFMT_UNKNOWN && !device)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
|
|
|
if (mode->format_id == WINED3DFMT_UNKNOWN)
|
|
|
|
{
|
|
|
|
FIXME("Matching formats to device not implemented.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2020-03-06 14:16:48 +01:00
|
|
|
hr = wined3d_output_find_closest_matching_mode(output->wined3d_output, mode);
|
2019-03-06 14:19:54 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-10-28 14:29:18 +01:00
|
|
|
static int dxgi_mode_desc_compare(const void *l, const void *r)
|
|
|
|
{
|
|
|
|
const DXGI_MODE_DESC *left = l, *right = r;
|
|
|
|
int a, b;
|
|
|
|
|
|
|
|
if (left->Width != right->Width)
|
|
|
|
return left->Width - right->Width;
|
|
|
|
|
|
|
|
if (left->Height != right->Height)
|
|
|
|
return left->Height - right->Height;
|
|
|
|
|
|
|
|
a = left->RefreshRate.Numerator * right->RefreshRate.Denominator;
|
|
|
|
b = right->RefreshRate.Numerator * left->RefreshRate.Denominator;
|
|
|
|
if (a != b)
|
|
|
|
return a - b;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-07 11:21:23 +01:00
|
|
|
enum dxgi_mode_struct_version
|
|
|
|
{
|
|
|
|
DXGI_MODE_STRUCT_VERSION_0,
|
|
|
|
DXGI_MODE_STRUCT_VERSION_1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT dxgi_output_get_display_mode_list(struct dxgi_output *output,
|
|
|
|
DXGI_FORMAT format, unsigned int *mode_count, void *modes,
|
|
|
|
enum dxgi_mode_struct_version struct_version)
|
|
|
|
{
|
|
|
|
enum wined3d_format_id wined3d_format;
|
|
|
|
struct wined3d_display_mode mode;
|
|
|
|
unsigned int i, max_count;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!mode_count)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
|
|
|
if (format == DXGI_FORMAT_UNKNOWN)
|
|
|
|
{
|
|
|
|
*mode_count = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
wined3d_format = wined3dformat_from_dxgi_format(format);
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2020-03-05 16:03:40 +01:00
|
|
|
max_count = wined3d_output_get_mode_count(output->wined3d_output,
|
2019-03-07 11:21:23 +01:00
|
|
|
wined3d_format, WINED3D_SCANLINE_ORDERING_UNKNOWN);
|
|
|
|
|
|
|
|
if (!modes)
|
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
*mode_count = max_count;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (max_count > *mode_count)
|
|
|
|
{
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return DXGI_ERROR_MORE_DATA;
|
|
|
|
}
|
|
|
|
|
|
|
|
*mode_count = max_count;
|
|
|
|
|
|
|
|
for (i = 0; i < *mode_count; ++i)
|
|
|
|
{
|
2020-03-05 16:03:23 +01:00
|
|
|
if (FAILED(hr = wined3d_output_get_mode(output->wined3d_output, wined3d_format,
|
|
|
|
WINED3D_SCANLINE_ORDERING_UNKNOWN, i, &mode)))
|
2019-03-07 11:21:23 +01:00
|
|
|
{
|
2020-03-05 16:03:23 +01:00
|
|
|
WARN("Failed to get output mode %u, hr %#x.\n", i, hr);
|
2019-03-07 11:21:23 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (struct_version)
|
|
|
|
{
|
|
|
|
case DXGI_MODE_STRUCT_VERSION_0:
|
|
|
|
{
|
|
|
|
DXGI_MODE_DESC *desc = modes;
|
|
|
|
dxgi_mode_from_wined3d(&desc[i], &mode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DXGI_MODE_STRUCT_VERSION_1:
|
|
|
|
{
|
|
|
|
DXGI_MODE_DESC1 *desc = modes;
|
|
|
|
dxgi_mode1_from_wined3d(&desc[i], &mode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2019-10-28 14:29:18 +01:00
|
|
|
switch (struct_version)
|
|
|
|
{
|
|
|
|
case DXGI_MODE_STRUCT_VERSION_0:
|
|
|
|
qsort(modes, *mode_count, sizeof(DXGI_MODE_DESC), dxgi_mode_desc_compare);
|
|
|
|
break;
|
|
|
|
case DXGI_MODE_STRUCT_VERSION_1:
|
|
|
|
qsort(modes, *mode_count, sizeof(DXGI_MODE_DESC1), dxgi_mode_desc_compare);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-03-07 11:21:23 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static inline struct dxgi_output *impl_from_IDXGIOutput6(IDXGIOutput6 *iface)
|
2011-06-06 10:21:49 +02:00
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dxgi_output, IDXGIOutput6_iface);
|
2011-06-06 10:21:49 +02:00
|
|
|
}
|
|
|
|
|
2009-09-11 19:01:14 +02:00
|
|
|
/* IUnknown methods */
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_QueryInterface(IDXGIOutput6 *iface, REFIID iid, void **object)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
2018-09-06 22:01:54 +02:00
|
|
|
TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object);
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
if (IsEqualGUID(iid, &IID_IDXGIOutput6)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIOutput5)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIOutput4)
|
2018-09-06 22:01:54 +02:00
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIOutput3)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIOutput2)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIOutput1)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIOutput)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDXGIObject)
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*object = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-06 22:01:54 +02:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
2009-09-11 19:01:14 +02:00
|
|
|
|
|
|
|
*object = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_output_AddRef(IDXGIOutput6 *iface)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2018-01-30 15:54:57 +01:00
|
|
|
ULONG refcount = InterlockedIncrement(&output->refcount);
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2018-01-30 15:54:57 +01:00
|
|
|
TRACE("%p increasing refcount to %u.\n", output, refcount);
|
2009-09-11 19:01:14 +02:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE dxgi_output_Release(IDXGIOutput6 *iface)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2016-04-14 12:20:21 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&output->refcount);
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2016-04-14 12:20:21 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", output, refcount);
|
2009-09-11 19:01:14 +02:00
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
2016-04-14 12:20:21 +02:00
|
|
|
wined3d_private_store_cleanup(&output->private_store);
|
2018-01-30 15:54:56 +01:00
|
|
|
IWineDXGIAdapter_Release(&output->adapter->IWineDXGIAdapter_iface);
|
2018-02-06 00:34:19 +01:00
|
|
|
heap_free(output);
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGIObject methods */
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_SetPrivateData(IDXGIOutput6 *iface,
|
2009-09-11 19:01:14 +02:00
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2015-02-16 12:25:52 +01:00
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return dxgi_set_private_data(&output->private_store, guid, data_size, data);
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_SetPrivateDataInterface(IDXGIOutput6 *iface,
|
2009-09-11 19:01:14 +02:00
|
|
|
REFGUID guid, const IUnknown *object)
|
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2015-02-16 12:25:53 +01:00
|
|
|
TRACE("iface %p, guid %s, object %p.\n", iface, debugstr_guid(guid), object);
|
|
|
|
|
|
|
|
return dxgi_set_private_data_interface(&output->private_store, guid, object);
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetPrivateData(IDXGIOutput6 *iface,
|
2009-09-11 19:01:14 +02:00
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2015-02-16 12:25:54 +01:00
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
|
|
|
return dxgi_get_private_data(&output->private_store, guid, data_size, data);
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetParent(IDXGIOutput6 *iface,
|
2009-09-11 19:01:14 +02:00
|
|
|
REFIID riid, void **parent)
|
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2009-12-03 11:38:19 +01:00
|
|
|
TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
|
|
|
|
|
2018-01-30 15:54:56 +01:00
|
|
|
return IWineDXGIAdapter_QueryInterface(&output->adapter->IWineDXGIAdapter_iface, riid, parent);
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGIOutput methods */
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetDesc(IDXGIOutput6 *iface, DXGI_OUTPUT_DESC *desc)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2015-11-24 18:06:17 +01:00
|
|
|
struct wined3d_output_desc wined3d_desc;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, desc %p.\n", iface, desc);
|
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2020-03-19 10:07:30 +01:00
|
|
|
hr = wined3d_output_get_desc(output->wined3d_output, &wined3d_desc);
|
2015-11-24 18:06:17 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to get output desc, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(desc->DeviceName, wined3d_desc.device_name, sizeof(desc->DeviceName));
|
|
|
|
desc->DesktopCoordinates = wined3d_desc.desktop_rect;
|
|
|
|
desc->AttachedToDesktop = wined3d_desc.attached_to_desktop;
|
|
|
|
desc->Rotation = wined3d_desc.rotation;
|
|
|
|
desc->Monitor = wined3d_desc.monitor;
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2015-11-24 18:06:17 +01:00
|
|
|
return S_OK;
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput6 *iface,
|
2019-03-07 11:21:23 +01:00
|
|
|
DXGI_FORMAT format, UINT flags, UINT *mode_count, DXGI_MODE_DESC *modes)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2011-05-16 11:52:33 +02:00
|
|
|
|
2019-03-07 11:21:23 +01:00
|
|
|
FIXME("iface %p, format %s, flags %#x, mode_count %p, modes %p partial stub!\n",
|
|
|
|
iface, debug_dxgi_format(format), flags, mode_count, modes);
|
2009-12-09 20:32:10 +01:00
|
|
|
|
2019-03-07 11:21:23 +01:00
|
|
|
return dxgi_output_get_display_mode_list(output,
|
|
|
|
format, mode_count, modes, DXGI_MODE_STRUCT_VERSION_0);
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_FindClosestMatchingMode(IDXGIOutput6 *iface,
|
2009-09-11 19:01:14 +02:00
|
|
|
const DXGI_MODE_DESC *mode, DXGI_MODE_DESC *closest_match, IUnknown *device)
|
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2016-08-25 12:22:52 +02:00
|
|
|
struct wined3d_display_mode wined3d_mode;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-03-07 11:21:24 +01:00
|
|
|
TRACE("iface %p, mode %p, closest_match %p, device %p.\n",
|
|
|
|
iface, mode, closest_match, device);
|
|
|
|
|
|
|
|
TRACE("Mode: %s.\n", debug_dxgi_mode(mode));
|
2016-08-25 12:22:52 +02:00
|
|
|
|
|
|
|
wined3d_display_mode_from_dxgi(&wined3d_mode, mode);
|
2019-03-06 14:19:54 +01:00
|
|
|
hr = dxgi_output_find_closest_matching_mode(output, &wined3d_mode, device);
|
2016-08-25 12:22:52 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
dxgi_mode_from_wined3d(closest_match, &wined3d_mode);
|
|
|
|
TRACE("Returning %s.\n", debug_dxgi_mode(closest_match));
|
|
|
|
}
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2016-08-25 12:22:52 +02:00
|
|
|
return hr;
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_WaitForVBlank(IDXGIOutput6 *iface)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
2017-02-08 05:38:22 +01:00
|
|
|
static BOOL once = FALSE;
|
|
|
|
|
|
|
|
if (!once++)
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
else
|
|
|
|
TRACE("iface %p stub!\n", iface);
|
2009-09-11 19:01:14 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_TakeOwnership(IDXGIOutput6 *iface, IUnknown *device, BOOL exclusive)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2020-03-03 15:18:14 +01:00
|
|
|
HRESULT hr;
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2019-10-30 15:01:30 +01:00
|
|
|
TRACE("iface %p, device %p, exclusive %d.\n", iface, device, exclusive);
|
|
|
|
|
|
|
|
if (!device)
|
|
|
|
return DXGI_ERROR_INVALID_CALL;
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2020-03-03 15:18:14 +01:00
|
|
|
hr = wined3d_output_take_ownership(output->wined3d_output, exclusive);
|
2019-10-30 15:01:30 +01:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
return hr;
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static void STDMETHODCALLTYPE dxgi_output_ReleaseOwnership(IDXGIOutput6 *iface)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2019-10-30 15:01:29 +01:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2020-03-03 15:18:14 +01:00
|
|
|
wined3d_output_release_ownership(output->wined3d_output);
|
2019-10-30 15:01:29 +01:00
|
|
|
wined3d_mutex_unlock();
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetGammaControlCapabilities(IDXGIOutput6 *iface,
|
2009-09-11 19:01:14 +02:00
|
|
|
DXGI_GAMMA_CONTROL_CAPABILITIES *gamma_caps)
|
|
|
|
{
|
2018-11-30 14:43:03 +01:00
|
|
|
unsigned int i;
|
2009-09-11 19:01:14 +02:00
|
|
|
|
2018-11-30 14:43:03 +01:00
|
|
|
TRACE("iface %p, gamma_caps %p.\n", iface, gamma_caps);
|
|
|
|
|
|
|
|
if (!gamma_caps)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
gamma_caps->ScaleAndOffsetSupported = FALSE;
|
|
|
|
gamma_caps->MaxConvertedValue = 1.0f;
|
|
|
|
gamma_caps->MinConvertedValue = 0.0f;
|
|
|
|
gamma_caps->NumGammaControlPoints = 256;
|
|
|
|
|
|
|
|
for (i = 0; i < gamma_caps->NumGammaControlPoints; ++i)
|
|
|
|
gamma_caps->ControlPointPositions[i] = i / 255.0f;
|
|
|
|
|
|
|
|
return S_OK;
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_SetGammaControl(IDXGIOutput6 *iface,
|
2009-09-11 19:01:14 +02:00
|
|
|
const DXGI_GAMMA_CONTROL *gamma_control)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, gamma_control %p stub!\n", iface, gamma_control);
|
|
|
|
|
2018-11-30 14:43:04 +01:00
|
|
|
return S_OK;
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetGammaControl(IDXGIOutput6 *iface,
|
2018-11-30 14:43:04 +01:00
|
|
|
DXGI_GAMMA_CONTROL *gamma_control)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, gamma_control %p stub!\n", iface, gamma_control);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_SetDisplaySurface(IDXGIOutput6 *iface, IDXGISurface *surface)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, surface %p stub!\n", iface, surface);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplaySurfaceData(IDXGIOutput6 *iface, IDXGISurface *surface)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, surface %p stub!\n", iface, surface);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetFrameStatistics(IDXGIOutput6 *iface, DXGI_FRAME_STATISTICS *stats)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p, stats %p stub!\n", iface, stats);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-01-30 15:54:57 +01:00
|
|
|
/* IDXGIOutput1 methods */
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList1(IDXGIOutput6 *iface,
|
2018-01-30 15:54:57 +01:00
|
|
|
DXGI_FORMAT format, UINT flags, UINT *mode_count, DXGI_MODE_DESC1 *modes)
|
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2018-01-30 15:54:57 +01:00
|
|
|
|
2019-03-07 11:21:23 +01:00
|
|
|
FIXME("iface %p, format %s, flags %#x, mode_count %p, modes %p partial stub!\n",
|
|
|
|
iface, debug_dxgi_format(format), flags, mode_count, modes);
|
|
|
|
|
|
|
|
return dxgi_output_get_display_mode_list(output,
|
|
|
|
format, mode_count, modes, DXGI_MODE_STRUCT_VERSION_1);
|
2018-01-30 15:54:57 +01:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_FindClosestMatchingMode1(IDXGIOutput6 *iface,
|
2018-01-30 15:54:57 +01:00
|
|
|
const DXGI_MODE_DESC1 *mode, DXGI_MODE_DESC1 *closest_match, IUnknown *device)
|
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
2019-03-06 14:19:54 +01:00
|
|
|
struct wined3d_display_mode wined3d_mode;
|
|
|
|
HRESULT hr;
|
2018-01-30 15:54:57 +01:00
|
|
|
|
2019-03-07 11:21:24 +01:00
|
|
|
TRACE("iface %p, mode %p, closest_match %p, device %p.\n",
|
|
|
|
iface, mode, closest_match, device);
|
|
|
|
|
|
|
|
TRACE("Mode: %s.\n", debug_dxgi_mode1(mode));
|
2019-03-06 14:19:54 +01:00
|
|
|
|
|
|
|
wined3d_display_mode_from_dxgi1(&wined3d_mode, mode);
|
|
|
|
hr = dxgi_output_find_closest_matching_mode(output, &wined3d_mode, device);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
dxgi_mode1_from_wined3d(closest_match, &wined3d_mode);
|
|
|
|
TRACE("Returning %s.\n", debug_dxgi_mode1(closest_match));
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2018-01-30 15:54:57 +01:00
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplaySurfaceData1(IDXGIOutput6 *iface,
|
2018-01-30 15:54:57 +01:00
|
|
|
IDXGIResource *resource)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, resource %p stub!\n", iface, resource);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_DuplicateOutput(IDXGIOutput6 *iface,
|
2018-01-30 15:54:57 +01:00
|
|
|
IUnknown *device, IDXGIOutputDuplication **output_duplication)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, device %p, output_duplication %p stub!\n", iface, device, output_duplication);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGIOutput2 methods */
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static BOOL STDMETHODCALLTYPE dxgi_output_SupportsOverlays(IDXGIOutput6 *iface)
|
2018-01-30 15:54:57 +01:00
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGIOutput3 methods */
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_CheckOverlaySupport(IDXGIOutput6 *iface,
|
2018-01-30 15:54:57 +01:00
|
|
|
DXGI_FORMAT format, IUnknown *device, UINT *flags)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, format %#x, device %p, flags %p stub!\n", iface, format, device, flags);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGIOutput4 methods */
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_CheckOverlayColorSpaceSupport(IDXGIOutput6 *iface,
|
2018-01-30 15:54:57 +01:00
|
|
|
DXGI_FORMAT format, DXGI_COLOR_SPACE_TYPE color_space, IUnknown *device, UINT *flags)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, format %#x, color_space %#x, device %p, flags %p stub!\n",
|
|
|
|
iface, format, color_space, device, flags);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-07-16 17:26:52 +02:00
|
|
|
/* IDXGIOutput5 methods */
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_DuplicateOutput1(IDXGIOutput6 *iface,
|
|
|
|
IUnknown *device, UINT flags, UINT format_count, const DXGI_FORMAT *formats,
|
|
|
|
IDXGIOutputDuplication **output_duplication)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, device %p, flags %#x, format_count %u, formats %p, "
|
|
|
|
"output_duplication %p stub!\n", iface, device, flags, format_count,
|
|
|
|
formats, output_duplication);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IDXGIOutput6 methods */
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_GetDesc1(IDXGIOutput6 *iface,
|
|
|
|
DXGI_OUTPUT_DESC1 *desc)
|
|
|
|
{
|
|
|
|
struct dxgi_output *output = impl_from_IDXGIOutput6(iface);
|
|
|
|
struct wined3d_output_desc wined3d_desc;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
FIXME("iface %p, desc %p semi-stub!\n", iface, desc);
|
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
|
|
|
hr = wined3d_output_get_desc(output->wined3d_output, &wined3d_desc);
|
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to get output desc, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(desc->DeviceName, wined3d_desc.device_name, sizeof(desc->DeviceName));
|
|
|
|
desc->DesktopCoordinates = wined3d_desc.desktop_rect;
|
|
|
|
desc->AttachedToDesktop = wined3d_desc.attached_to_desktop;
|
|
|
|
desc->Rotation = wined3d_desc.rotation;
|
|
|
|
desc->Monitor = wined3d_desc.monitor;
|
|
|
|
|
|
|
|
/* FIXME: fill this from monitor EDID */
|
|
|
|
desc->BitsPerColor = 0;
|
|
|
|
desc->ColorSpace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
|
|
|
|
desc->RedPrimary[0] = 0.f;
|
|
|
|
desc->RedPrimary[1] = 0.f;
|
|
|
|
desc->GreenPrimary[0] = 0.f;
|
|
|
|
desc->GreenPrimary[1] = 0.f;
|
|
|
|
desc->BluePrimary[0] = 0.f;
|
|
|
|
desc->BluePrimary[1] = 0.f;
|
|
|
|
desc->WhitePoint[0] = 0.f;
|
|
|
|
desc->WhitePoint[1] = 0.f;
|
|
|
|
desc->MinLuminance = 0.f;
|
|
|
|
desc->MaxLuminance = 0.f;
|
|
|
|
desc->MaxFullFrameLuminance = 0.f;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE dxgi_output_CheckHardwareCompositionSupport(IDXGIOutput6 *iface,
|
|
|
|
UINT *flags)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, flags %p stub!\n", iface, flags);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDXGIOutput6Vtbl dxgi_output_vtbl =
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
|
|
|
dxgi_output_QueryInterface,
|
|
|
|
dxgi_output_AddRef,
|
|
|
|
dxgi_output_Release,
|
|
|
|
/* IDXGIObject methods */
|
|
|
|
dxgi_output_SetPrivateData,
|
|
|
|
dxgi_output_SetPrivateDataInterface,
|
|
|
|
dxgi_output_GetPrivateData,
|
|
|
|
dxgi_output_GetParent,
|
|
|
|
/* IDXGIOutput methods */
|
|
|
|
dxgi_output_GetDesc,
|
|
|
|
dxgi_output_GetDisplayModeList,
|
|
|
|
dxgi_output_FindClosestMatchingMode,
|
|
|
|
dxgi_output_WaitForVBlank,
|
|
|
|
dxgi_output_TakeOwnership,
|
|
|
|
dxgi_output_ReleaseOwnership,
|
|
|
|
dxgi_output_GetGammaControlCapabilities,
|
|
|
|
dxgi_output_SetGammaControl,
|
|
|
|
dxgi_output_GetGammaControl,
|
|
|
|
dxgi_output_SetDisplaySurface,
|
|
|
|
dxgi_output_GetDisplaySurfaceData,
|
|
|
|
dxgi_output_GetFrameStatistics,
|
2018-01-30 15:54:57 +01:00
|
|
|
/* IDXGIOutput1 methods */
|
|
|
|
dxgi_output_GetDisplayModeList1,
|
|
|
|
dxgi_output_FindClosestMatchingMode1,
|
|
|
|
dxgi_output_GetDisplaySurfaceData1,
|
|
|
|
dxgi_output_DuplicateOutput,
|
|
|
|
/* IDXGIOutput2 methods */
|
|
|
|
dxgi_output_SupportsOverlays,
|
|
|
|
/* IDXGIOutput3 methods */
|
|
|
|
dxgi_output_CheckOverlaySupport,
|
|
|
|
/* IDXGIOutput4 methods */
|
|
|
|
dxgi_output_CheckOverlayColorSpaceSupport,
|
2020-07-16 17:26:52 +02:00
|
|
|
/* IDXGIOutput5 methods */
|
|
|
|
dxgi_output_DuplicateOutput1,
|
|
|
|
/* IDXGIOutput6 methods */
|
|
|
|
dxgi_output_GetDesc1,
|
|
|
|
dxgi_output_CheckHardwareCompositionSupport,
|
2009-09-11 19:01:14 +02:00
|
|
|
};
|
|
|
|
|
2019-07-31 22:29:46 +02:00
|
|
|
struct dxgi_output *unsafe_impl_from_IDXGIOutput(IDXGIOutput *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == (IDXGIOutputVtbl *)&dxgi_output_vtbl);
|
2020-07-16 17:26:52 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dxgi_output, IDXGIOutput6_iface);
|
2019-07-31 22:29:46 +02:00
|
|
|
}
|
|
|
|
|
2020-03-03 15:18:14 +01:00
|
|
|
static void dxgi_output_init(struct dxgi_output *output, unsigned int output_idx,
|
|
|
|
struct dxgi_adapter *adapter)
|
2009-09-11 19:01:14 +02:00
|
|
|
{
|
2020-07-16 17:26:52 +02:00
|
|
|
output->IDXGIOutput6_iface.lpVtbl = &dxgi_output_vtbl;
|
2009-09-11 19:01:14 +02:00
|
|
|
output->refcount = 1;
|
2020-03-03 15:18:14 +01:00
|
|
|
output->wined3d_output = wined3d_adapter_get_output(adapter->wined3d_adapter, output_idx);
|
2015-02-16 12:25:52 +01:00
|
|
|
wined3d_private_store_init(&output->private_store);
|
2009-12-03 11:38:19 +01:00
|
|
|
output->adapter = adapter;
|
2018-01-30 15:54:56 +01:00
|
|
|
IWineDXGIAdapter_AddRef(&output->adapter->IWineDXGIAdapter_iface);
|
2016-04-14 12:20:21 +02:00
|
|
|
}
|
|
|
|
|
2020-03-03 15:18:14 +01:00
|
|
|
HRESULT dxgi_output_create(struct dxgi_adapter *adapter, unsigned int output_idx,
|
|
|
|
struct dxgi_output **output)
|
2016-04-14 12:20:21 +02:00
|
|
|
{
|
2018-02-06 00:34:19 +01:00
|
|
|
if (!(*output = heap_alloc_zero(sizeof(**output))))
|
2016-04-14 12:20:21 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2020-03-03 15:18:14 +01:00
|
|
|
dxgi_output_init(*output, output_idx, adapter);
|
2016-04-14 12:20:21 +02:00
|
|
|
return S_OK;
|
2009-09-11 19:01:14 +02:00
|
|
|
}
|