From 6f55c8d1c56ad0901a9a0d3a5216c97925a0c70f Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 9 Dec 2020 15:04:56 +0330 Subject: [PATCH] wined3d: Use an sRGB fallback format for sRGB formats in wined3d_swapchain_vk_select_vk_format(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50121 Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/swapchain.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index ffffc18aa84..0c5a75ed02d 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -635,6 +635,22 @@ done: return supported; } +static VkFormat get_swapchain_fallback_format(VkFormat vk_format) +{ + switch (vk_format) + { + case VK_FORMAT_R8G8B8A8_SRGB: + return VK_FORMAT_B8G8R8A8_SRGB; + case VK_FORMAT_R8G8B8A8_UNORM: + case VK_FORMAT_A2B10G10R10_UNORM_PACK32: + case VK_FORMAT_R16G16B16A16_SFLOAT: + return VK_FORMAT_B8G8R8A8_UNORM; + default: + WARN("Unhandled format %#x.\n", vk_format); + return VK_FORMAT_UNDEFINED; + } +} + static VkFormat wined3d_swapchain_vk_select_vk_format(struct wined3d_swapchain_vk *swapchain_vk, VkSurfaceKHR vk_surface) { @@ -684,7 +700,7 @@ static VkFormat wined3d_swapchain_vk_select_vk_format(struct wined3d_swapchain_v if (i == format_count) { /* Try to create a swapchain with format conversion. */ - vk_format = VK_FORMAT_B8G8R8A8_UNORM; + vk_format = get_swapchain_fallback_format(vk_format); WARN("Failed to find Vulkan swapchain format for %s.\n", debug_d3dformat(desc->backbuffer_format)); for (i = 0; i < format_count; ++i) {