From: Ken Thomases Subject: [PATCH 2/3] wined3d: Improve CheckDeviceType() support for windowed mode. Message-Id: Date: Wed, 22 Jan 2014 16:42:33 -0600 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. Fixes . --- dlls/wined3d/directx.c | 113 +++++++++++++++++++++++++++++------------------- 1 files changed, 68 insertions(+), 45 deletions(-) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index f98c56c..c861b70 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -4015,10 +4015,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 @@ -4039,53 +4036,79 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap 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) + if (windowed) { - TRACE("backbuffer_format WINED3FMT_UNKNOWN only available in windowed mode.\n"); - 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; + } - /* 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; - } + /* 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_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 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_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)) + else { - 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; + } - /* 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; + /* 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 */