Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/d3d8/directx.c | 8 ++++++--
dlls/d3d9/directx.c | 20 ++++++++++++++------
dlls/dxgi/output.c | 4 +---
dlls/wined3d/directx.c | 21 +++++++++------------
dlls/wined3d/wined3d.spec | 2 +-
include/wine/wined3d.h | 4 ++--
6 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
index 7e9b72eea30..b78b119d22c 100644
--- a/dlls/d3d8/directx.c
+++ b/dlls/d3d8/directx.c
@@ -134,12 +134,16 @@ static HRESULT WINAPI d3d8_GetAdapterIdentifier(IDirect3D8 *iface, UINT adapter,
static UINT WINAPI d3d8_GetAdapterModeCount(IDirect3D8 *iface, UINT adapter)
{
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
- UINT count;
+ unsigned int output_idx, count;
TRACE("iface %p, adapter %u.\n", iface, adapter);
+ output_idx = adapter;
+ if (output_idx >= d3d8->wined3d_output_count)
+ return 0;
+
wined3d_mutex_lock();
- count = wined3d_get_adapter_mode_count(d3d8->wined3d, adapter,
+ count = wined3d_output_get_mode_count(d3d8->wined3d_outputs[output_idx],
WINED3DFMT_UNKNOWN, WINED3D_SCANLINE_ORDERING_UNKNOWN);
wined3d_mutex_unlock();
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index 00632019c7d..83bb3d8217c 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -149,20 +149,24 @@ static HRESULT WINAPI d3d9_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT adapte
static UINT WINAPI d3d9_GetAdapterModeCount(IDirect3D9Ex *iface, UINT adapter, D3DFORMAT format)
{
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
- UINT ret;
+ unsigned int output_idx, count;
TRACE("iface %p, adapter %u, format %#x.\n", iface, adapter, format);
+ output_idx = adapter;
+ if (output_idx >= d3d9->wined3d_output_count)
+ return 0;
+
/* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out. */
if (format != D3DFMT_X8R8G8B8 && format != D3DFMT_R5G6B5)
return 0;
wined3d_mutex_lock();
- ret = wined3d_get_adapter_mode_count(d3d9->wined3d, adapter,
+ count = wined3d_output_get_mode_count(d3d9->wined3d_outputs[output_idx],
wined3dformat_from_d3dformat(format), WINED3D_SCANLINE_ORDERING_UNKNOWN);
wined3d_mutex_unlock();
- return ret;
+ return count;
}
static HRESULT WINAPI d3d9_EnumAdapterModes(IDirect3D9Ex *iface, UINT adapter,
@@ -440,19 +444,23 @@ static UINT WINAPI d3d9_GetAdapterModeCountEx(IDirect3D9Ex *iface,
UINT adapter, const D3DDISPLAYMODEFILTER *filter)
{
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
- UINT ret;
+ unsigned int output_idx, count;
TRACE("iface %p, adapter %u, filter %p.\n", iface, adapter, filter);
+ output_idx = adapter;
+ if (output_idx >= d3d9->wined3d_output_count)
+ return 0;
+
if (filter->Format != D3DFMT_X8R8G8B8 && filter->Format != D3DFMT_R5G6B5)
return 0;
wined3d_mutex_lock();
- ret = wined3d_get_adapter_mode_count(d3d9->wined3d, adapter,
+ count = wined3d_output_get_mode_count(d3d9->wined3d_outputs[output_idx],
wined3dformat_from_d3dformat(filter->Format), filter->ScanLineOrdering);
wined3d_mutex_unlock();
- return ret;
+ return count;
}
static HRESULT WINAPI d3d9_EnumAdapterModesEx(IDirect3D9Ex *iface,
diff --git a/dlls/dxgi/output.c b/dlls/dxgi/output.c
index 063d72e13fa..fe8dd7b5c0a 100644
--- a/dlls/dxgi/output.c
+++ b/dlls/dxgi/output.c
@@ -107,7 +107,6 @@ static HRESULT dxgi_output_get_display_mode_list(struct dxgi_output *output,
enum wined3d_format_id wined3d_format;
struct wined3d_display_mode mode;
unsigned int i, max_count;
- struct wined3d *wined3d;
HRESULT hr;
if (!mode_count)
@@ -122,8 +121,7 @@ static HRESULT dxgi_output_get_display_mode_list(struct dxgi_output *output,
wined3d_format = wined3dformat_from_dxgi_format(format);
wined3d_mutex_lock();
- wined3d = output->adapter->factory->wined3d;
- max_count = wined3d_get_adapter_mode_count(wined3d, output->adapter->ordinal,
+ max_count = wined3d_output_get_mode_count(output->wined3d_output,
wined3d_format, WINED3D_SCANLINE_ORDERING_UNKNOWN);
if (!modes)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 87beb98b3f4..614a6eea8d7 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -952,7 +952,7 @@ HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned in
of the same bpp but different resolutions */
/* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
-UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
+unsigned int CDECL wined3d_output_get_mode_count(const struct wined3d_output *output,
enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
{
const struct wined3d_adapter *adapter;
@@ -962,20 +962,17 @@ UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT ad
UINT format_bits;
DEVMODEW mode;
- TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n",
- wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering);
+ TRACE("output %p, format %s, scanline_ordering %#x.\n",
+ output, debug_d3dformat(format_id), scanline_ordering);
- if (adapter_idx >= wined3d->adapter_count)
- return 0;
-
- adapter = wined3d->adapters[adapter_idx];
+ adapter = output->adapter;
format = wined3d_get_format(adapter, format_id, WINED3D_BIND_RENDER_TARGET);
format_bits = format->byte_count * CHAR_BIT;
memset(&mode, 0, sizeof(mode));
mode.dmSize = sizeof(mode);
- while (EnumDisplaySettingsExW(adapter->device_name, j++, &mode, 0))
+ while (EnumDisplaySettingsExW(output->device_name, j++, &mode, 0))
{
if (mode.dmFields & DM_DISPLAYFLAGS)
{
@@ -999,7 +996,7 @@ UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT ad
}
}
- TRACE("Returning %u matching modes (out of %u total) for adapter %u.\n", i, j, adapter_idx);
+ TRACE("Returning %u matching modes (out of %u total) for output %p.\n", i, j, output);
return i;
}
@@ -1093,10 +1090,10 @@ HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *w
TRACE("wined3d %p, adapter_idx %u, mode %p.\n", wined3d, adapter_idx, mode);
- if (!(mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx,
+ if (!(mode_count = wined3d_output_get_mode_count(&wined3d->adapters[0]->outputs[0],
mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN)))
{
- WARN("Adapter has 0 matching modes.\n");
+ WARN("Output has 0 matching modes.\n");
return E_FAIL;
}
@@ -1831,7 +1828,7 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap
if (!windowed)
{
/* If the requested display format is not available, don't continue. */
- if (!wined3d_get_adapter_mode_count(wined3d, adapter_idx,
+ if (!wined3d_output_get_mode_count(&wined3d->adapters[0]->outputs[0],
display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN))
{
TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index b8d93ef2393..ca626638338 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -14,7 +14,6 @@
@ cdecl wined3d_get_adapter_count(ptr)
@ 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_raster_status(ptr long ptr)
@ cdecl wined3d_get_device_caps(ptr long long ptr)
@ cdecl wined3d_get_output_desc(ptr long ptr)
@@ -194,6 +193,7 @@
@ cdecl wined3d_device_validate_device(ptr ptr)
@ cdecl wined3d_output_get_mode(ptr long long long ptr)
+@ cdecl wined3d_output_get_mode_count(ptr long long)
@ cdecl wined3d_output_release_ownership(ptr)
@ cdecl wined3d_output_take_ownership(ptr long)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 0bd8cbdddbc..9600bf63ee7 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2267,8 +2267,6 @@ HRESULT __cdecl wined3d_get_adapter_display_mode(const struct wined3d *wined3d,
struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation);
HRESULT __cdecl wined3d_get_adapter_identifier(const struct wined3d *wined3d, UINT adapter_idx,
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);
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,
@@ -2557,6 +2555,8 @@ HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *devi
HRESULT __cdecl wined3d_output_get_mode(const struct wined3d_output *output,
enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
unsigned int mode_idx, struct wined3d_display_mode *mode);
+unsigned int __cdecl wined3d_output_get_mode_count(const struct wined3d_output *output,
+ enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering);
void __cdecl wined3d_output_release_ownership(const struct wined3d_output *output);
HRESULT __cdecl wined3d_output_take_ownership(const struct wined3d_output *output, BOOL exclusive);
--
2.20.1