Module: wine Branch: master Commit: d2c56a60271abc4d231c1f61510a7d24129ee815 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d2c56a60271abc4d231c1f6151...
Author: Ken Thomases ken@codeweavers.com Date: Mon Jan 27 13:33:03 2014 -0600
wined3d: Improve CheckDeviceType() support for windowed mode.
For windowed mode: * It doesn't matter if there are no adapter modes for the display format. * A backbuffer format is valid so long as there's support for color conversion to the display format. * A backbuffer format of D3DFMT_UNKNOWN is allowed and means that it should be the same as the display format.
---
dlls/wined3d/directx.c | 132 ++++++++++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 54 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 29ff883..6617c3a 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -4000,7 +4000,6 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap enum wined3d_device_type device_type, enum wined3d_format_id display_format, enum wined3d_format_id backbuffer_format, BOOL windowed) { - UINT mode_count; HRESULT hr;
TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n", @@ -4014,10 +4013,7 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap * combination is available on the given adapter. In fullscreen mode microsoft specified * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer * and display format should match exactly. - * In windowed mode format conversion can occur and this depends on the driver. When format - * conversion is done, this function should nevertheless fail and applications need to use - * CheckDeviceFormatConversion. - * At the moment we assume that fullscreen and windowed have the same capabilities. */ + * In windowed mode format conversion can occur and this depends on the driver. */
/* There are only 4 display formats. */ if (!(display_format == WINED3DFMT_B5G6R5_UNORM @@ -4029,62 +4025,90 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap return WINED3DERR_NOTAVAILABLE; }
- /* If the requested display format is not available, don't continue. */ - mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx, - display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN); - if (!mode_count) + if (windowed) { - TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format)); - return WINED3DERR_NOTAVAILABLE; - } + /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode. */ + if (display_format == WINED3DFMT_B10G10R10A2_UNORM) + { + TRACE("Unsupported display/backbuffer format combination %s / %s for windowed mode.\n", + debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); + return WINED3DERR_NOTAVAILABLE; + }
- /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format, - * it means 'reuse' the display format for the backbuffer. */ - if (!windowed && backbuffer_format == WINED3DFMT_UNKNOWN) - { - TRACE("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n"); - return WINED3DERR_NOTAVAILABLE; - } + /* Windowed mode allows you to specify WINED3DFMT_UNKNOWN for the backbuffer format, + * it means 'reuse' the display format for the backbuffer. */ + if (backbuffer_format == WINED3DFMT_UNKNOWN) + backbuffer_format = display_format;
- /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with - * backbuffer format WINED3DFMT_B5G6R5_UNORM. */ - if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM) - { - TRACE("Unsupported display/backbuffer format combination %s / %s.\n", - debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); - return WINED3DERR_NOTAVAILABLE; + /* In windowed mode, if color conversion from the backbuffer format to the + * display format is supported, then the format combination is supported. */ + hr = wined3d_check_device_format_conversion(wined3d, adapter_idx, device_type, backbuffer_format, display_format); + if (FAILED(hr)) + { + TRACE("Unsupported display/backbuffer format combination %s / %s; no color conversion.\n", + debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); + return WINED3DERR_NOTAVAILABLE; + } } - - /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with - * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and - * WINED3DFMT_B5G5R5A1_UNORM. */ - if (display_format == WINED3DFMT_B5G5R5X1_UNORM - && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM)) + else { - TRACE("Unsupported display/backbuffer format combination %s / %s.\n", - debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); - return WINED3DERR_NOTAVAILABLE; - } + UINT mode_count;
- /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with - * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and - * WINED3DFMT_B8G8R8A8_UNORM. */ - if (display_format == WINED3DFMT_B8G8R8X8_UNORM - && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM)) - { - TRACE("Unsupported display/backbuffer format combination %s / %s.\n", - debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); - return WINED3DERR_NOTAVAILABLE; - } + /* If the requested display format is not available, don't continue. */ + mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx, + display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN); + if (!mode_count) + { + TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format)); + return WINED3DERR_NOTAVAILABLE; + }
- /* WINED3DFMT_B10G10R10A2_UNORM is only allowed in fullscreen mode and it - * can only be mixed with backbuffer format WINED3DFMT_B10G10R10A2_UNORM. */ - if (display_format == WINED3DFMT_B10G10R10A2_UNORM - && (backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM || windowed)) - { - TRACE("Unsupported display/backbuffer format combination %s / %s.\n", - debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); - return WINED3DERR_NOTAVAILABLE; + if (backbuffer_format == WINED3DFMT_UNKNOWN) + { + TRACE("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n"); + return WINED3DERR_NOTAVAILABLE; + } + + /* In FULLSCREEN mode WINED3DFMT_B5G6R5_UNORM can only be mixed with + * backbuffer format WINED3DFMT_B5G6R5_UNORM. */ + if (display_format == WINED3DFMT_B5G6R5_UNORM && backbuffer_format != WINED3DFMT_B5G6R5_UNORM) + { + TRACE("Unsupported display/backbuffer format combination %s / %s.\n", + debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); + return WINED3DERR_NOTAVAILABLE; + } + + /* In FULLSCREEN mode WINED3DFMT_B5G5R5X1_UNORM can only be mixed with + * backbuffer formats WINED3DFMT_B5G5R5X1_UNORM and + * WINED3DFMT_B5G5R5A1_UNORM. */ + if (display_format == WINED3DFMT_B5G5R5X1_UNORM + && !(backbuffer_format == WINED3DFMT_B5G5R5X1_UNORM || backbuffer_format == WINED3DFMT_B5G5R5A1_UNORM)) + { + TRACE("Unsupported display/backbuffer format combination %s / %s.\n", + debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); + return WINED3DERR_NOTAVAILABLE; + } + + /* In FULLSCREEN mode WINED3DFMT_B8G8R8X8_UNORM can only be mixed with + * backbuffer formats WINED3DFMT_B8G8R8X8_UNORM and + * WINED3DFMT_B8G8R8A8_UNORM. */ + if (display_format == WINED3DFMT_B8G8R8X8_UNORM + && !(backbuffer_format == WINED3DFMT_B8G8R8X8_UNORM || backbuffer_format == WINED3DFMT_B8G8R8A8_UNORM)) + { + TRACE("Unsupported display/backbuffer format combination %s / %s.\n", + debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); + return WINED3DERR_NOTAVAILABLE; + } + + /* WINED3DFMT_B10G10R10A2_UNORM can only be mixed with backbuffer format + * WINED3DFMT_B10G10R10A2_UNORM. */ + if (display_format == WINED3DFMT_B10G10R10A2_UNORM + && backbuffer_format != WINED3DFMT_B10G10R10A2_UNORM) + { + TRACE("Unsupported display/backbuffer format combination %s / %s.\n", + debug_d3dformat(display_format), debug_d3dformat(backbuffer_format)); + return WINED3DERR_NOTAVAILABLE; + } }
/* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */