From 37ab09bec87e359bc57ca6a4a18d65108c5a5689 Mon Sep 17 00:00:00 2001 From: Xuelian Bai Date: Tue, 7 Jun 2022 16:26:24 +0800 Subject: Fix red and blue inverted issue Non-packed 8-bit formats have an inverted channel order compared to the little endian DRM formats 1. Set supported surface format as VK_FORMAT_B8G8R8A8_* 2. Invert RGB to BGR in format map Change-Id: Iab05870d25a309f11666083fa3d56ca54a28b391 Signed-Off-by: Xuelian Bai --- wsi/tizen/surface_properties.cpp | 4 ++-- wsi/tizen/swapchain.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wsi/tizen/surface_properties.cpp b/wsi/tizen/surface_properties.cpp index d81649e..cb55f25 100644 --- a/wsi/tizen/surface_properties.cpp +++ b/wsi/tizen/surface_properties.cpp @@ -128,7 +128,7 @@ VkResult surface_properties::get_surface_formats(VkPhysicalDevice physical_devic VkResult res = VK_SUCCESS; /* TODO: Hardcoding a list of sensible formats, may be query it from compositor later. */ - static std::array formats = { VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SRGB }; + static std::array formats = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB }; assert(surfaceFormatCount != nullptr); res = VK_SUCCESS; @@ -160,7 +160,7 @@ VkResult surface_properties::get_surface_formats_2(VkPhysicalDevice physical_dev VkResult res = VK_SUCCESS; /* TODO: Hardcoding a list of sensible formats, may be query it from compositor later. */ - static std::array formats = { VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SRGB }; + static std::array formats = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB }; assert(surfaceFormatCount != nullptr); res = VK_SUCCESS; diff --git a/wsi/tizen/swapchain.cpp b/wsi/tizen/swapchain.cpp index 5e3f5cd..9ddddc6 100644 --- a/wsi/tizen/swapchain.cpp +++ b/wsi/tizen/swapchain.cpp @@ -137,12 +137,13 @@ wsi_tizen_get_tbm_format(VkFormat format, VkCompositeAlphaFlagBitsKHR comp) RETURN_FORMAT(comp, RGB888, RGB888, RGB888, RGB888); /* 8 8 8 8 */ case VK_FORMAT_B8G8R8A8_UNORM: - RETURN_FORMAT(comp, XRGB8888, ARGB8888, 0, ARGB8888); + case VK_FORMAT_B8G8R8A8_SRGB: + case VK_FORMAT_UNDEFINED:/*VK_FORMAT_UNDEFINED specifies that the format is not specified.*/ + RETURN_FORMAT(comp, XRGB8888, ARGB8888, ARGB8888, ARGB8888); /* Use RGBA in every alpha bit case.*/ case VK_FORMAT_R8G8B8A8_UNORM: - case VK_FORMAT_UNDEFINED:/*VK_FORMAT_UNDEFINED specifies that the format is not specified.*/ case VK_FORMAT_R8G8B8A8_SRGB: - RETURN_FORMAT(comp, RGBA8888, RGBA8888, RGBA8888, RGBA8888); + RETURN_FORMAT(comp, XBGR8888, ABGR8888, ABGR8888, ABGR8888); case VK_FORMAT_A8B8G8R8_UNORM_PACK32: RETURN_FORMAT(comp, XBGR8888, ABGR8888, 0, ABGR8888); /* 2 10 10 10 */ -- cgit v1.2.3