wined3d: Use the device name stored in the adapter in wined3d_enum_adapter_modes().

This commit is contained in:
Henri Verbeet 2012-06-28 13:11:12 +02:00 committed by Alexandre Julliard
parent b6bdb4286d
commit e9d0367d29

View File

@ -2942,30 +2942,29 @@ UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT ad
HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx, HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
enum wined3d_format_id format_id, UINT mode_idx, struct wined3d_display_mode *mode) enum wined3d_format_id format_id, UINT mode_idx, struct wined3d_display_mode *mode)
{ {
const struct wined3d_adapter *adapter;
const struct wined3d_format *format;
UINT format_bits;
DEVMODEW m;
UINT i = 0;
int j = 0;
TRACE("wined3d %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n", TRACE("wined3d %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n",
wined3d, adapter_idx, debug_d3dformat(format_id), mode_idx, mode); wined3d, adapter_idx, debug_d3dformat(format_id), mode_idx, mode);
if (!mode || adapter_idx >= wined3d->adapter_count) if (!mode || adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
/* TODO: Store modes per adapter and read it from the adapter structure */ adapter = &wined3d->adapters[adapter_idx];
if (!adapter_idx) format = wined3d_get_format(&adapter->gl_info, format_id);
{ format_bits = format->byte_count * CHAR_BIT;
const struct wined3d_format *format = wined3d_get_format(&wined3d->adapters[adapter_idx].gl_info, format_id);
UINT format_bits = format->byte_count * CHAR_BIT;
DEVMODEW DevModeW;
UINT i = 0;
int j = 0;
ZeroMemory(&DevModeW, sizeof(DevModeW)); memset(&m, 0, sizeof(m));
DevModeW.dmSize = sizeof(DevModeW); m.dmSize = sizeof(m);
/* If we are filtering to a specific format (D3D9), then need to skip
all unrelated modes, but if mode is irrelevant (D3D8), then we can
just count through the ones with valid bit depths */
while (i <= mode_idx) while (i <= mode_idx)
{ {
if (!EnumDisplaySettingsExW(NULL, j++, &DevModeW, 0)) if (!EnumDisplaySettingsExW(adapter->DeviceName, j++, &m, 0))
{ {
WARN("Invalid mode_idx %u.\n", mode_idx); WARN("Invalid mode_idx %u.\n", mode_idx);
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
@ -2973,40 +2972,35 @@ HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT ada
if (format_id == WINED3DFMT_UNKNOWN) if (format_id == WINED3DFMT_UNKNOWN)
{ {
/* This is for D3D8, do not enumerate P8 here */ /* This is for d3d8, do not enumerate P8 here. */
if (DevModeW.dmBitsPerPel == 32 || DevModeW.dmBitsPerPel == 16) ++i; if (m.dmBitsPerPel == 32 || m.dmBitsPerPel == 16) ++i;
} }
else if (DevModeW.dmBitsPerPel == format_bits) else if (m.dmBitsPerPel == format_bits)
{ {
++i; ++i;
} }
} }
mode->width = DevModeW.dmPelsWidth; mode->width = m.dmPelsWidth;
mode->height = DevModeW.dmPelsHeight; mode->height = m.dmPelsHeight;
mode->refresh_rate = DEFAULT_REFRESH_RATE; mode->refresh_rate = DEFAULT_REFRESH_RATE;
if (DevModeW.dmFields & DM_DISPLAYFREQUENCY) if (m.dmFields & DM_DISPLAYFREQUENCY)
mode->refresh_rate = DevModeW.dmDisplayFrequency; mode->refresh_rate = m.dmDisplayFrequency;
if (format_id == WINED3DFMT_UNKNOWN) if (format_id == WINED3DFMT_UNKNOWN)
mode->format_id = pixelformat_for_depth(DevModeW.dmBitsPerPel); mode->format_id = pixelformat_for_depth(m.dmBitsPerPel);
else else
mode->format_id = format_id; mode->format_id = format_id;
if (!(DevModeW.dmFields & DM_DISPLAYFLAGS)) if (!(m.dmFields & DM_DISPLAYFLAGS))
mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN; mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
else if (DevModeW.u2.dmDisplayFlags & DM_INTERLACED) else if (m.u2.dmDisplayFlags & DM_INTERLACED)
mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED; mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_INTERLACED;
else else
mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE; mode->scanline_ordering = WINED3D_SCANLINE_ORDERING_PROGRESSIVE;
TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate, TRACE("%ux%u@%u %u bpp, %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
DevModeW.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering); m.dmBitsPerPel, debug_d3dformat(mode->format_id), mode->scanline_ordering);
}
else
{
FIXME("Adapter not primary display.\n");
}
return WINED3D_OK; return WINED3D_OK;
} }