Commit ca9b5f67 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

wined3d: Introduce wined3d_adapter_get_output().

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