Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/d3d8/directx.c | 7 ++++++-
dlls/d3d9/directx.c | 7 ++++++-
dlls/ddraw/main.c | 7 ++++---
dlls/dxgi/output.c | 3 +--
dlls/wined3d/directx.c | 11 ++++-------
dlls/wined3d/wined3d.spec | 2 +-
include/wine/wined3d.h | 4 ++--
7 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
index 343073f351..509a76239d 100644
--- a/dlls/d3d8/directx.c
+++ b/dlls/d3d8/directx.c
@@ -398,12 +398,17 @@ static HMONITOR WINAPI d3d8_GetAdapterMonitor(IDirect3D8 *iface, UINT adapter)
{
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
struct wined3d_output_desc desc;
+ unsigned int output_idx;
HRESULT hr;
TRACE("iface %p, adapter %u.\n", iface, adapter);
+ output_idx = adapter;
+ if (output_idx >= d3d8->wined3d_output_count)
+ return NULL;
+
wined3d_mutex_lock();
- hr = wined3d_get_output_desc(d3d8->wined3d, adapter, &desc);
+ hr = wined3d_output_get_desc(d3d8->wined3d_outputs[output_idx], &desc);
wined3d_mutex_unlock();
if (FAILED(hr))
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index d79b32515f..9113ec1d5a 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -448,12 +448,17 @@ static HMONITOR WINAPI d3d9_GetAdapterMonitor(IDirect3D9Ex *iface, UINT adapter)
{
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
struct wined3d_output_desc desc;
+ unsigned int output_idx;
HRESULT hr;
TRACE("iface %p, adapter %u.\n", iface, adapter);
+ output_idx = adapter;
+ if (output_idx >= d3d9->wined3d_output_count)
+ return NULL;
+
wined3d_mutex_lock();
- hr = wined3d_get_output_desc(d3d9->wined3d, adapter, &desc);
+ hr = wined3d_output_get_desc(d3d9->wined3d_outputs[output_idx], &desc);
wined3d_mutex_unlock();
if (FAILED(hr))
diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c
index 20c0f3f953..b9fe6b1e4b 100644
--- a/dlls/ddraw/main.c
+++ b/dlls/ddraw/main.c
@@ -59,6 +59,7 @@ static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMC
struct wined3d_adapter_identifier adapter_id;
struct wined3d_adapter *wined3d_adapter;
struct wined3d_output_desc output_desc;
+ struct wined3d_output *wined3d_output;
unsigned int interface_count = 0;
unsigned int adapter_idx = 0;
unsigned int output_idx;
@@ -86,11 +87,11 @@ static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMC
}
wined3d_mutex_unlock();
- for (output_idx = 0; cont_enum && wined3d_adapter_get_output(wined3d_adapter, output_idx);
- ++output_idx)
+ for (output_idx = 0; cont_enum && (wined3d_output = 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)))
+ if (FAILED(hr = wined3d_output_get_desc(wined3d_output, &output_desc)))
{
WARN("Failed to get output description, hr %#x.\n", hr);
wined3d_mutex_unlock();
diff --git a/dlls/dxgi/output.c b/dlls/dxgi/output.c
index 8c94788fbf..85bfed0598 100644
--- a/dlls/dxgi/output.c
+++ b/dlls/dxgi/output.c
@@ -289,8 +289,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDesc(IDXGIOutput4 *iface, DXGI_O
return E_INVALIDARG;
wined3d_mutex_lock();
- hr = wined3d_get_output_desc(output->adapter->factory->wined3d,
- output->adapter->ordinal, &wined3d_desc);
+ hr = wined3d_output_get_desc(output->wined3d_output, &wined3d_desc);
wined3d_mutex_unlock();
if (FAILED(hr))
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 8cf0d77e82..9b99428134 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -915,7 +915,7 @@ HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *in
return WINED3D_OK;
}
-HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned int adapter_idx,
+HRESULT CDECL wined3d_output_get_desc(const struct wined3d_output *output,
struct wined3d_output_desc *desc)
{
enum wined3d_display_rotation rotation;
@@ -924,16 +924,13 @@ HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned in
HMONITOR monitor;
HRESULT hr;
- TRACE("wined3d %p, adapter_idx %u, desc %p.\n", wined3d, adapter_idx, desc);
+ TRACE("output %p, desc %p.\n", output, desc);
- if (adapter_idx >= wined3d->adapter_count)
- return WINED3DERR_INVALIDCALL;
-
- adapter = wined3d->adapters[adapter_idx];
+ adapter = output->adapter;
if (!(monitor = MonitorFromPoint(adapter->monitor_position, MONITOR_DEFAULTTOPRIMARY)))
return WINED3DERR_INVALIDCALL;
- if (FAILED(hr = wined3d_output_get_display_mode(&adapter->outputs[0], &mode, &rotation)))
+ if (FAILED(hr = wined3d_output_get_display_mode(output, &mode, &rotation)))
return hr;
memcpy(desc->device_name, adapter->device_name, sizeof(desc->device_name));
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index c06cca22ee..22a9a9dd74 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -12,7 +12,6 @@
@ cdecl wined3d_get_adapter(ptr long)
@ cdecl wined3d_get_adapter_count(ptr)
@ cdecl wined3d_get_device_caps(ptr long ptr)
-@ cdecl wined3d_get_output_desc(ptr long ptr)
@ cdecl wined3d_incref(ptr)
@ cdecl wined3d_register_software_device(ptr ptr)
@ cdecl wined3d_register_window(ptr ptr ptr long)
@@ -158,6 +157,7 @@
@ cdecl wined3d_output_find_closest_matching_mode(ptr ptr)
@ cdecl wined3d_output_get_adapter(ptr)
+@ cdecl wined3d_output_get_desc(ptr ptr)
@ cdecl wined3d_output_get_display_mode(ptr ptr ptr)
@ cdecl wined3d_output_get_mode(ptr long long long ptr)
@ cdecl wined3d_output_get_mode_count(ptr long long)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index d192266583..2c3f085623 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2281,8 +2281,6 @@ struct wined3d_adapter * __cdecl wined3d_get_adapter(const struct wined3d *wined
UINT __cdecl wined3d_get_adapter_count(const struct wined3d *wined3d);
HRESULT __cdecl wined3d_get_device_caps(const struct wined3d_adapter *adapter,
enum wined3d_device_type device_type, struct wined3d_caps *caps);
-HRESULT __cdecl wined3d_get_output_desc(const struct wined3d *wined3d, unsigned int adapter_idx,
- struct wined3d_output_desc *desc);
ULONG __cdecl wined3d_incref(struct wined3d *wined3d);
HRESULT __cdecl wined3d_register_software_device(struct wined3d *wined3d, void *init_function);
BOOL __cdecl wined3d_register_window(struct wined3d *wined3d, HWND window,
@@ -2509,6 +2507,8 @@ HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *devi
HRESULT __cdecl wined3d_output_find_closest_matching_mode(const struct wined3d_output *output,
struct wined3d_display_mode *mode);
struct wined3d_adapter * __cdecl wined3d_output_get_adapter(const struct wined3d_output *output);
+HRESULT __cdecl wined3d_output_get_desc(const struct wined3d_output *output,
+ struct wined3d_output_desc *desc);
HRESULT __cdecl wined3d_output_get_display_mode(const struct wined3d_output *output,
struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation);
HRESULT __cdecl wined3d_output_get_mode(const struct wined3d_output *output,
--
2.20.1