Commit 1bb5c918 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

wined3d: Refactor wined3d_get_adapter_mode_count() to wined3d_output_get_mode_count().

parent a0dbb1e4
...@@ -134,12 +134,16 @@ static HRESULT WINAPI d3d8_GetAdapterIdentifier(IDirect3D8 *iface, UINT adapter, ...@@ -134,12 +134,16 @@ static HRESULT WINAPI d3d8_GetAdapterIdentifier(IDirect3D8 *iface, UINT adapter,
static UINT WINAPI d3d8_GetAdapterModeCount(IDirect3D8 *iface, UINT adapter) static UINT WINAPI d3d8_GetAdapterModeCount(IDirect3D8 *iface, UINT adapter)
{ {
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface); struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
UINT count; unsigned int output_idx, count;
TRACE("iface %p, adapter %u.\n", iface, adapter); TRACE("iface %p, adapter %u.\n", iface, adapter);
output_idx = adapter;
if (output_idx >= d3d8->wined3d_output_count)
return 0;
wined3d_mutex_lock(); 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); WINED3DFMT_UNKNOWN, WINED3D_SCANLINE_ORDERING_UNKNOWN);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
......
...@@ -149,20 +149,24 @@ static HRESULT WINAPI d3d9_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT adapte ...@@ -149,20 +149,24 @@ static HRESULT WINAPI d3d9_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT adapte
static UINT WINAPI d3d9_GetAdapterModeCount(IDirect3D9Ex *iface, UINT adapter, D3DFORMAT format) static UINT WINAPI d3d9_GetAdapterModeCount(IDirect3D9Ex *iface, UINT adapter, D3DFORMAT format)
{ {
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface); 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); 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. */ /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out. */
if (format != D3DFMT_X8R8G8B8 && format != D3DFMT_R5G6B5) if (format != D3DFMT_X8R8G8B8 && format != D3DFMT_R5G6B5)
return 0; return 0;
wined3d_mutex_lock(); 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); wined3dformat_from_d3dformat(format), WINED3D_SCANLINE_ORDERING_UNKNOWN);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return ret; return count;
} }
static HRESULT WINAPI d3d9_EnumAdapterModes(IDirect3D9Ex *iface, UINT adapter, static HRESULT WINAPI d3d9_EnumAdapterModes(IDirect3D9Ex *iface, UINT adapter,
...@@ -440,19 +444,23 @@ static UINT WINAPI d3d9_GetAdapterModeCountEx(IDirect3D9Ex *iface, ...@@ -440,19 +444,23 @@ static UINT WINAPI d3d9_GetAdapterModeCountEx(IDirect3D9Ex *iface,
UINT adapter, const D3DDISPLAYMODEFILTER *filter) UINT adapter, const D3DDISPLAYMODEFILTER *filter)
{ {
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface); 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); 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) if (filter->Format != D3DFMT_X8R8G8B8 && filter->Format != D3DFMT_R5G6B5)
return 0; return 0;
wined3d_mutex_lock(); 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); wined3dformat_from_d3dformat(filter->Format), filter->ScanLineOrdering);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return ret; return count;
} }
static HRESULT WINAPI d3d9_EnumAdapterModesEx(IDirect3D9Ex *iface, static HRESULT WINAPI d3d9_EnumAdapterModesEx(IDirect3D9Ex *iface,
......
...@@ -107,7 +107,6 @@ static HRESULT dxgi_output_get_display_mode_list(struct dxgi_output *output, ...@@ -107,7 +107,6 @@ static HRESULT dxgi_output_get_display_mode_list(struct dxgi_output *output,
enum wined3d_format_id wined3d_format; enum wined3d_format_id wined3d_format;
struct wined3d_display_mode mode; struct wined3d_display_mode mode;
unsigned int i, max_count; unsigned int i, max_count;
struct wined3d *wined3d;
HRESULT hr; HRESULT hr;
if (!mode_count) if (!mode_count)
...@@ -122,8 +121,7 @@ static HRESULT dxgi_output_get_display_mode_list(struct dxgi_output *output, ...@@ -122,8 +121,7 @@ static HRESULT dxgi_output_get_display_mode_list(struct dxgi_output *output,
wined3d_format = wined3dformat_from_dxgi_format(format); wined3d_format = wined3dformat_from_dxgi_format(format);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d = output->adapter->factory->wined3d; max_count = wined3d_output_get_mode_count(output->wined3d_output,
max_count = wined3d_get_adapter_mode_count(wined3d, output->adapter->ordinal,
wined3d_format, WINED3D_SCANLINE_ORDERING_UNKNOWN); wined3d_format, WINED3D_SCANLINE_ORDERING_UNKNOWN);
if (!modes) if (!modes)
......
...@@ -952,7 +952,7 @@ HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned in ...@@ -952,7 +952,7 @@ HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned in
of the same bpp but different resolutions */ of the same bpp but different resolutions */
/* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */ /* 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) enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering)
{ {
const struct wined3d_adapter *adapter; const struct wined3d_adapter *adapter;
...@@ -962,20 +962,17 @@ UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT ad ...@@ -962,20 +962,17 @@ UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT ad
UINT format_bits; UINT format_bits;
DEVMODEW mode; DEVMODEW mode;
TRACE("wined3d %p, adapter_idx %u, format %s, scanline_ordering %#x.\n", TRACE("output %p, format %s, scanline_ordering %#x.\n",
wined3d, adapter_idx, debug_d3dformat(format_id), scanline_ordering); output, debug_d3dformat(format_id), scanline_ordering);
if (adapter_idx >= wined3d->adapter_count) adapter = output->adapter;
return 0;
adapter = wined3d->adapters[adapter_idx];
format = wined3d_get_format(adapter, format_id, WINED3D_BIND_RENDER_TARGET); format = wined3d_get_format(adapter, format_id, WINED3D_BIND_RENDER_TARGET);
format_bits = format->byte_count * CHAR_BIT; format_bits = format->byte_count * CHAR_BIT;
memset(&mode, 0, sizeof(mode)); memset(&mode, 0, sizeof(mode));
mode.dmSize = 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) if (mode.dmFields & DM_DISPLAYFLAGS)
{ {
...@@ -999,7 +996,7 @@ UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT ad ...@@ -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; return i;
} }
...@@ -1093,10 +1090,10 @@ HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *w ...@@ -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); 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[adapter_idx]->outputs[0],
mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN))) mode->format_id, WINED3D_SCANLINE_ORDERING_UNKNOWN)))
{ {
WARN("Adapter has 0 matching modes.\n"); WARN("Output has 0 matching modes.\n");
return E_FAIL; return E_FAIL;
} }
...@@ -1829,7 +1826,7 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap ...@@ -1829,7 +1826,7 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap
if (!windowed) if (!windowed)
{ {
/* If the requested display format is not available, don't continue. */ /* 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[adapter_idx]->outputs[0],
display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN)) display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN))
{ {
TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format)); TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format));
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
@ cdecl wined3d_get_adapter_count(ptr) @ cdecl wined3d_get_adapter_count(ptr)
@ 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_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)
...@@ -162,6 +161,7 @@ ...@@ -162,6 +161,7 @@
@ cdecl wined3d_device_validate_device(ptr ptr) @ cdecl wined3d_device_validate_device(ptr ptr)
@ cdecl wined3d_output_get_mode(ptr long long long 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_release_ownership(ptr)
@ cdecl wined3d_output_take_ownership(ptr long) @ cdecl wined3d_output_take_ownership(ptr long)
......
...@@ -2267,8 +2267,6 @@ HRESULT __cdecl wined3d_get_adapter_display_mode(const struct wined3d *wined3d, ...@@ -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); struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation);
HRESULT __cdecl wined3d_get_adapter_identifier(const struct wined3d *wined3d, UINT adapter_idx, HRESULT __cdecl wined3d_get_adapter_identifier(const struct wined3d *wined3d, UINT adapter_idx,
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,
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, 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,
...@@ -2501,6 +2499,8 @@ HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *devi ...@@ -2501,6 +2499,8 @@ HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *devi
HRESULT __cdecl wined3d_output_get_mode(const struct wined3d_output *output, HRESULT __cdecl wined3d_output_get_mode(const struct wined3d_output *output,
enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering, enum wined3d_format_id format_id, enum wined3d_scanline_ordering scanline_ordering,
unsigned int mode_idx, struct wined3d_display_mode *mode); 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); void __cdecl wined3d_output_release_ownership(const struct wined3d_output *output);
HRESULT __cdecl wined3d_output_take_ownership(const struct wined3d_output *output, BOOL exclusive); HRESULT __cdecl wined3d_output_take_ownership(const struct wined3d_output *output, BOOL exclusive);
......
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