Mesa (main): vulkan/wsi/wayland: Add support for more SRGB formats.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 9 12:11:58 UTC 2021
Module: Mesa
Branch: main
Commit: d8c1bf4a7dbac4cded7de5c6e4547ef62afc1b5f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d8c1bf4a7dbac4cded7de5c6e4547ef62afc1b5f
Author: Georg Lehmann <dadschoorse at gmail.com>
Date: Thu Jul 8 11:47:52 2021 +0200
vulkan/wsi/wayland: Add support for more SRGB formats.
This is required by the Vulkan specification:
If pSurfaceFormats includes an entry whose value for colorSpace is
VK_COLOR_SPACE_SRGB_NONLINEAR_KHR and whose value for format is a UNORM
(or SRGB) format and the corresponding SRGB (or UNORM) format is a color
renderable format for VK_IMAGE_TILING_OPTIMAL, then pSurfaceFormats must also
contain an entry with the same value for colorSpace and format equal to the
corresponding SRGB (or UNORM) format.
Signed-off-by: Georg Lehmann <dadschoorse at gmail.com>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Simon Ser <contact at emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11778>
---
src/vulkan/wsi/wsi_common_wayland.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 7530f58ec3a..67786e22881 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -183,12 +183,23 @@ wsi_wl_display_add_wl_format(struct wsi_wl_display *display,
/* Non-packed 8-bit formats have an inverted channel order compared to the
* little endian DRM formats, because the DRM channel ordering is high->low
- * but the vulkan channel ordering is in memory byte order */
+ * but the vulkan channel ordering is in memory byte order
+ *
+ * For all UNORM formats which have a SRGB variant, we must support both if
+ * we can. SRGB in this context means that rendering to it will result in a
+ * linear -> nonlinear SRGB colorspace conversion before the data is stored.
+ * The inverse function is applied when sampling from SRGB images.
+ * From Wayland's perspective nothing changes, the difference is just how
+ * Vulkan interprets the pixel data. */
case WL_DRM_FORMAT_XBGR8888:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_R8G8B8_SRGB);
wsi_wl_display_add_vk_format(display, formats,
VK_FORMAT_R8G8B8_UNORM);
FALLTHROUGH;
case WL_DRM_FORMAT_ABGR8888:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_R8G8B8A8_SRGB);
wsi_wl_display_add_vk_format(display, formats,
VK_FORMAT_R8G8B8A8_UNORM);
break;
@@ -243,8 +254,10 @@ wl_drm_format_for_vk_format(VkFormat vk_format, bool alpha)
return alpha ? WL_DRM_FORMAT_ABGR2101010 : WL_DRM_FORMAT_XBGR2101010;
#endif
case VK_FORMAT_R8G8B8_UNORM:
+ case VK_FORMAT_R8G8B8_SRGB:
return WL_DRM_FORMAT_XBGR8888;
case VK_FORMAT_R8G8B8A8_UNORM:
+ case VK_FORMAT_R8G8B8A8_SRGB:
return alpha ? WL_DRM_FORMAT_ABGR8888 : WL_DRM_FORMAT_XBGR8888;
case VK_FORMAT_B8G8R8_UNORM:
case VK_FORMAT_B8G8R8_SRGB:
More information about the mesa-commit
mailing list