wined3d: Introduce wined3d_adapter_get_output().
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2f9037c75d
commit
ca9b5f6748
|
@ -57,12 +57,15 @@ static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMC
|
|||
void *context)
|
||||
{
|
||||
struct wined3d_adapter_identifier adapter_id;
|
||||
struct wined3d_adapter *wined3d_adapter;
|
||||
struct wined3d_output_desc output_desc;
|
||||
unsigned int interface_count = 0;
|
||||
unsigned int adapter_idx = 0;
|
||||
unsigned int output_idx;
|
||||
BOOL cont_enum = TRUE;
|
||||
HRESULT hr = S_OK;
|
||||
UINT adapter = 0;
|
||||
HRESULT hr;
|
||||
|
||||
for (adapter = 0; SUCCEEDED(hr) && cont_enum; adapter++)
|
||||
while (cont_enum && (wined3d_adapter = wined3d_get_adapter(wined3d, adapter_idx)))
|
||||
{
|
||||
char DriverName[512] = "", DriverDescription[512] = "";
|
||||
|
||||
|
@ -73,16 +76,38 @@ static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMC
|
|||
adapter_id.device_name_size = sizeof(DriverName);
|
||||
adapter_id.description = DriverDescription;
|
||||
adapter_id.description_size = sizeof(DriverDescription);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
if (SUCCEEDED(hr = wined3d_get_adapter_identifier(wined3d, adapter, 0x0, &adapter_id)))
|
||||
hr = wined3d_get_output_desc(wined3d, adapter, &output_desc);
|
||||
wined3d_mutex_unlock();
|
||||
if (SUCCEEDED(hr))
|
||||
if (FAILED(hr = wined3d_get_adapter_identifier(wined3d, adapter_idx, 0x0, &adapter_id)))
|
||||
{
|
||||
TRACE("Interface %d: %s\n", adapter, wine_dbgstr_guid(&adapter_id.device_identifier));
|
||||
WARN("Failed to get adapter identifier, hr %#x.\n", hr);
|
||||
wined3d_mutex_unlock();
|
||||
break;
|
||||
}
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
for (output_idx = 0; cont_enum && wined3d_adapter_get_output(wined3d_adapter, output_idx);
|
||||
++output_idx)
|
||||
{
|
||||
wined3d_mutex_lock();
|
||||
if (FAILED(hr = wined3d_get_output_desc(wined3d, output_idx, &output_desc)))
|
||||
{
|
||||
WARN("Failed to get output description, hr %#x.\n", hr);
|
||||
wined3d_mutex_unlock();
|
||||
break;
|
||||
}
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
TRACE("Interface %u: %s\n", interface_count++,
|
||||
wine_dbgstr_guid(&adapter_id.device_identifier));
|
||||
cont_enum = callback(&adapter_id.device_identifier, adapter_id.description,
|
||||
adapter_id.device_name, context, output_desc.monitor);
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
break;
|
||||
|
||||
++adapter_idx;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_EnumOutputs(IWineDXGIAdapter *ifac
|
|||
return DXGI_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (FAILED(hr = dxgi_output_create(adapter, &output_object)))
|
||||
if (FAILED(hr = dxgi_output_create(adapter, output_idx, &output_object)))
|
||||
{
|
||||
*output = NULL;
|
||||
return hr;
|
||||
|
|
|
@ -144,11 +144,13 @@ struct dxgi_output
|
|||
{
|
||||
IDXGIOutput4 IDXGIOutput4_iface;
|
||||
LONG refcount;
|
||||
struct wined3d_output *wined3d_output;
|
||||
struct wined3d_private_store private_store;
|
||||
struct dxgi_adapter *adapter;
|
||||
};
|
||||
|
||||
HRESULT dxgi_output_create(struct dxgi_adapter *adapter, struct dxgi_output **output) DECLSPEC_HIDDEN;
|
||||
HRESULT dxgi_output_create(struct dxgi_adapter *adapter, unsigned int output_idx,
|
||||
struct dxgi_output **output) DECLSPEC_HIDDEN;
|
||||
struct dxgi_output *unsafe_impl_from_IDXGIOutput(IDXGIOutput *iface) DECLSPEC_HIDDEN;
|
||||
|
||||
/* IDXGIAdapter */
|
||||
|
|
|
@ -365,8 +365,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_WaitForVBlank(IDXGIOutput4 *iface)
|
|||
static HRESULT STDMETHODCALLTYPE dxgi_output_TakeOwnership(IDXGIOutput4 *iface, IUnknown *device, BOOL exclusive)
|
||||
{
|
||||
struct dxgi_output *output = impl_from_IDXGIOutput4(iface);
|
||||
struct wined3d_output *wined3d_output;
|
||||
HRESULT hr = DXGI_ERROR_INVALID_CALL;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, device %p, exclusive %d.\n", iface, device, exclusive);
|
||||
|
||||
|
@ -374,9 +373,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_TakeOwnership(IDXGIOutput4 *iface,
|
|||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
if ((wined3d_output = wined3d_get_adapter_output(output->adapter->factory->wined3d,
|
||||
output->adapter->ordinal)))
|
||||
hr = wined3d_output_take_ownership(wined3d_output, exclusive);
|
||||
hr = wined3d_output_take_ownership(output->wined3d_output, exclusive);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
|
@ -385,14 +382,11 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_TakeOwnership(IDXGIOutput4 *iface,
|
|||
static void STDMETHODCALLTYPE dxgi_output_ReleaseOwnership(IDXGIOutput4 *iface)
|
||||
{
|
||||
struct dxgi_output *output = impl_from_IDXGIOutput4(iface);
|
||||
struct wined3d_output *wined3d_output;
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
if ((wined3d_output = wined3d_get_adapter_output(output->adapter->factory->wined3d,
|
||||
output->adapter->ordinal)))
|
||||
wined3d_output_release_ownership(wined3d_output);
|
||||
wined3d_output_release_ownership(output->wined3d_output);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
|
@ -581,20 +575,23 @@ struct dxgi_output *unsafe_impl_from_IDXGIOutput(IDXGIOutput *iface)
|
|||
return CONTAINING_RECORD(iface, struct dxgi_output, IDXGIOutput4_iface);
|
||||
}
|
||||
|
||||
static void dxgi_output_init(struct dxgi_output *output, struct dxgi_adapter *adapter)
|
||||
static void dxgi_output_init(struct dxgi_output *output, unsigned int output_idx,
|
||||
struct dxgi_adapter *adapter)
|
||||
{
|
||||
output->IDXGIOutput4_iface.lpVtbl = &dxgi_output_vtbl;
|
||||
output->refcount = 1;
|
||||
output->wined3d_output = wined3d_adapter_get_output(adapter->wined3d_adapter, output_idx);
|
||||
wined3d_private_store_init(&output->private_store);
|
||||
output->adapter = adapter;
|
||||
IWineDXGIAdapter_AddRef(&output->adapter->IWineDXGIAdapter_iface);
|
||||
}
|
||||
|
||||
HRESULT dxgi_output_create(struct dxgi_adapter *adapter, struct dxgi_output **output)
|
||||
HRESULT dxgi_output_create(struct dxgi_adapter *adapter, unsigned int output_idx,
|
||||
struct dxgi_output **output)
|
||||
{
|
||||
if (!(*output = heap_alloc_zero(sizeof(**output))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
dxgi_output_init(*output, adapter);
|
||||
dxgi_output_init(*output, output_idx, adapter);
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -155,7 +155,11 @@ UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount)
|
|||
|
||||
void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
|
||||
{
|
||||
wined3d_output_cleanup(&adapter->output);
|
||||
unsigned int output_idx;
|
||||
|
||||
for (output_idx = 0; output_idx < adapter->output_count; ++output_idx)
|
||||
wined3d_output_cleanup(&adapter->outputs[output_idx]);
|
||||
heap_free(adapter->outputs);
|
||||
heap_free(adapter->formats);
|
||||
}
|
||||
|
||||
|
@ -883,6 +887,17 @@ UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
|
|||
return wined3d->adapter_count;
|
||||
}
|
||||
|
||||
struct wined3d_output * CDECL wined3d_adapter_get_output(const struct wined3d_adapter *adapter,
|
||||
unsigned int idx)
|
||||
{
|
||||
TRACE("adapter %p, idx %u.\n", adapter, idx);
|
||||
|
||||
if (idx >= adapter->output_count)
|
||||
return NULL;
|
||||
|
||||
return &adapter->outputs[idx];
|
||||
}
|
||||
|
||||
unsigned int CDECL wined3d_adapter_get_output_count(const struct wined3d_adapter *adapter)
|
||||
{
|
||||
TRACE("adapter %p, reporting %u outputs.\n", adapter, adapter->output_count);
|
||||
|
@ -930,16 +945,6 @@ HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned in
|
|||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
struct wined3d_output * CDECL wined3d_get_adapter_output(const struct wined3d *wined3d, unsigned int adapter_idx)
|
||||
{
|
||||
TRACE("wined3d %p, adapter_idx %u.\n", wined3d, adapter_idx);
|
||||
|
||||
if (adapter_idx >= wined3d->adapter_count)
|
||||
return NULL;
|
||||
|
||||
return &wined3d->adapters[adapter_idx]->output;
|
||||
}
|
||||
|
||||
/* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
|
||||
of the same bpp but different resolutions */
|
||||
|
||||
|
@ -2828,26 +2833,35 @@ BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal,
|
|||
const struct wined3d_adapter_ops *adapter_ops)
|
||||
{
|
||||
DISPLAY_DEVICEW display_device;
|
||||
unsigned int output_idx;
|
||||
BOOL ret = FALSE;
|
||||
HRESULT hr;
|
||||
|
||||
adapter->ordinal = ordinal;
|
||||
adapter->output_count = 0;
|
||||
|
||||
display_device.cb = sizeof(display_device);
|
||||
EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
|
||||
TRACE("Display device: %s.\n", debugstr_w(display_device.DeviceName));
|
||||
strcpyW(adapter->device_name, display_device.DeviceName);
|
||||
if (FAILED(hr = wined3d_output_init(&adapter->output, adapter->device_name)))
|
||||
|
||||
if (!(adapter->outputs = heap_calloc(1, sizeof(*adapter->outputs))))
|
||||
{
|
||||
ERR("Failed to allocate outputs.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (FAILED(hr = wined3d_output_init(&adapter->outputs[0], adapter->device_name)))
|
||||
{
|
||||
ERR("Failed to initialise output, hr %#x.\n", hr);
|
||||
return FALSE;
|
||||
goto done;
|
||||
}
|
||||
adapter->output_count = 1;
|
||||
|
||||
if (!AllocateLocallyUniqueId(&adapter->luid))
|
||||
{
|
||||
ERR("Failed to set adapter LUID (%#x).\n", GetLastError());
|
||||
wined3d_output_cleanup(&adapter->output);
|
||||
return FALSE;
|
||||
goto done;
|
||||
}
|
||||
TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
|
||||
adapter->luid.HighPart, adapter->luid.LowPart, adapter);
|
||||
|
@ -2857,8 +2871,15 @@ BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal,
|
|||
|
||||
adapter->formats = NULL;
|
||||
adapter->adapter_ops = adapter_ops;
|
||||
|
||||
return TRUE;
|
||||
ret = TRUE;
|
||||
done:
|
||||
if (!ret)
|
||||
{
|
||||
for (output_idx = 0; output_idx < adapter->output_count; ++output_idx)
|
||||
wined3d_output_cleanup(&adapter->outputs[output_idx]);
|
||||
heap_free(adapter->outputs);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct wined3d_adapter *wined3d_adapter_create(unsigned int ordinal, DWORD wined3d_creation_flags)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
@ cdecl wined3d_get_adapter_display_mode(ptr long ptr ptr)
|
||||
@ cdecl wined3d_get_adapter_identifier(ptr long long ptr)
|
||||
@ cdecl wined3d_get_adapter_mode_count(ptr long long long)
|
||||
@ cdecl wined3d_get_adapter_output(ptr long ptr)
|
||||
@ cdecl wined3d_get_adapter_raster_status(ptr long ptr)
|
||||
@ cdecl wined3d_get_device_caps(ptr long long ptr)
|
||||
@ cdecl wined3d_get_output_desc(ptr long ptr)
|
||||
|
@ -26,6 +25,7 @@
|
|||
@ cdecl wined3d_set_adapter_display_mode(ptr long ptr)
|
||||
@ cdecl wined3d_unregister_windows(ptr)
|
||||
|
||||
@ cdecl wined3d_adapter_get_output(ptr long)
|
||||
@ cdecl wined3d_adapter_get_output_count(ptr)
|
||||
|
||||
@ cdecl wined3d_blend_state_create(ptr ptr ptr ptr ptr)
|
||||
|
|
|
@ -2913,7 +2913,7 @@ struct wined3d_adapter
|
|||
struct wined3d_gl_info gl_info;
|
||||
struct wined3d_d3d_info d3d_info;
|
||||
struct wined3d_driver_info driver_info;
|
||||
struct wined3d_output output;
|
||||
struct wined3d_output *outputs;
|
||||
unsigned int output_count;
|
||||
UINT64 vram_bytes_used;
|
||||
GUID driver_uuid;
|
||||
|
|
|
@ -2272,7 +2272,6 @@ HRESULT __cdecl wined3d_get_adapter_identifier(const struct wined3d *wined3d, UI
|
|||
DWORD flags, struct wined3d_adapter_identifier *identifier);
|
||||
UINT __cdecl wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
|
||||
enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering);
|
||||
struct wined3d_output * __cdecl wined3d_get_adapter_output(const struct wined3d *wined3d, unsigned int adapter_idx);
|
||||
HRESULT __cdecl wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,
|
||||
struct wined3d_raster_status *raster_status);
|
||||
HRESULT __cdecl wined3d_get_device_caps(const struct wined3d *wined3d, unsigned int adapter_idx,
|
||||
|
@ -2287,6 +2286,8 @@ HRESULT __cdecl wined3d_set_adapter_display_mode(struct wined3d *wined3d,
|
|||
UINT adapter_idx, const struct wined3d_display_mode *mode);
|
||||
void __cdecl wined3d_unregister_windows(struct wined3d *wined3d);
|
||||
|
||||
struct wined3d_output * __cdecl wined3d_adapter_get_output(const struct wined3d_adapter *adapter,
|
||||
unsigned int idx);
|
||||
unsigned int __cdecl wined3d_adapter_get_output_count(const struct wined3d_adapter *adapter);
|
||||
|
||||
HRESULT __cdecl wined3d_buffer_create(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
|
||||
|
|
Loading…
Reference in New Issue