Mesa (main): vulkan/wsi/wayland: remove format switch from wl_shm_format_for_vk_format
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Feb 1 08:47:20 UTC 2022
Module: Mesa
Branch: main
Commit: 713a4363e5f2f1403bd373116985ee1eada5222c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=713a4363e5f2f1403bd373116985ee1eada5222c
Author: Simon Ser <contact at emersion.fr>
Date: Thu Jan 20 12:10:42 2022 +0100
vulkan/wsi/wayland: remove format switch from wl_shm_format_for_vk_format
Instead of maintaining two similar switches (one for DRM formats,
one for wl_shm formats), only maintain a single switch (for DRM)
and convert DRM formats to enum wl_shm_format. This reduces the
risk to have inconsistencies between these two functions.
Signed-off-by: Simon Ser <contact at emersion.fr>
Reviewed-by: Georg Lehmann <dadschoorse at gmail.com>
Reviewed-by: Daniel Stone <daniels at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14634>
---
src/vulkan/wsi/wsi_common_wayland.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 6c77ce42781..b66a49560ea 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -456,23 +456,19 @@ wl_drm_format_for_vk_format(VkFormat vk_format, bool alpha)
static enum wl_shm_format
wl_shm_format_for_vk_format(VkFormat vk_format, bool alpha)
{
- switch (vk_format) {
- case VK_FORMAT_R8G8B8A8_UNORM:
- case VK_FORMAT_R8G8B8A8_SRGB:
- return alpha ? WL_SHM_FORMAT_ABGR8888 : WL_SHM_FORMAT_XBGR8888;
- case VK_FORMAT_B8G8R8A8_UNORM:
- case VK_FORMAT_B8G8R8A8_SRGB:
- return alpha ? WL_SHM_FORMAT_ARGB8888 : WL_SHM_FORMAT_XRGB8888;
- case VK_FORMAT_R8G8B8_UNORM:
- case VK_FORMAT_R8G8B8_SRGB:
- return WL_SHM_FORMAT_XBGR8888;
- case VK_FORMAT_B8G8R8_UNORM:
- case VK_FORMAT_B8G8R8_SRGB:
- return WL_SHM_FORMAT_XRGB8888;
+ uint32_t drm_format = wl_drm_format_for_vk_format(vk_format, alpha);
+ if (drm_format == DRM_FORMAT_INVALID) {
+ return 0;
+ }
+ /* wl_shm formats are identical to DRM, except ARGB8888 and XRGB8888 */
+ switch (drm_format) {
+ case DRM_FORMAT_ARGB8888:
+ return WL_SHM_FORMAT_ARGB8888;
+ case DRM_FORMAT_XRGB8888:
+ return WL_SHM_FORMAT_XRGB8888;
default:
- assert(!"Unsupported Vulkan format");
- return 0;
+ return drm_format;
}
}
More information about the mesa-commit
mailing list