summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-02-11 21:25:49 -0800
committerKristian H. Kristensen <[email protected]>2019-04-09 00:42:30 +0000
commit22dcb080d9d966d5d81e65ab51f08f86977be8c0 (patch)
treeed58b75b49fcf63b23feb08b9d4c8ea78d1952c0
parent2d214d940524ffb74ebbaac641ed0d798a4e39c7 (diff)
vulkan/wsi: refactor drm_handle_format
Refactor the swtich statement in drm_handle_format out to wsi_wl_display_add_wl_format. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Daniel Stone <[email protected]>
-rw-r--r--src/vulkan/wsi/wsi_common_wayland.c128
1 files changed, 75 insertions, 53 deletions
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 362f5c21b5e..3113cba3079 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -83,11 +83,12 @@ struct wsi_wayland {
};
static void
-wsi_wl_display_add_vk_format(struct wsi_wl_display *display, VkFormat format)
+wsi_wl_display_add_vk_format(struct wsi_wl_display *display,
+ struct u_vector *formats, VkFormat format)
{
/* Don't add a format that's already in the list */
VkFormat *f;
- u_vector_foreach(f, &display->formats)
+ u_vector_foreach(f, formats)
if (*f == format)
return;
@@ -99,12 +100,82 @@ wsi_wl_display_add_vk_format(struct wsi_wl_display *display, VkFormat format)
if (!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
return;
- f = u_vector_add(&display->formats);
+ f = u_vector_add(formats);
if (f)
*f = format;
}
static void
+wsi_wl_display_add_wl_format(struct wsi_wl_display *display,
+ struct u_vector *formats, uint32_t wl_format)
+{
+ switch (wl_format) {
+#if 0
+ case WL_DRM_FORMAT_ABGR4444:
+ case WL_DRM_FORMAT_XBGR4444:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_R4G4B4A4_UNORM);
+ break;
+ case WL_DRM_FORMAT_BGR565:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_R5G6B5_UNORM);
+ break;
+ case WL_DRM_FORMAT_ABGR1555:
+ case WL_DRM_FORMAT_XBGR1555:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_R5G5B5A1_UNORM);
+ break;
+ case WL_DRM_FORMAT_XBGR8888:
+ 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_UNORM);
+ break;
+ case WL_DRM_FORMAT_ABGR2101010:
+ case WL_DRM_FORMAT_XBGR2101010:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_R10G10B10A2_UNORM);
+ break;
+ case WL_DRM_FORMAT_ARGB4444:
+ case WL_DRM_FORMAT_XRGB4444:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_B4G4R4A4_UNORM);
+ break;
+ case WL_DRM_FORMAT_RGB565:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_B5G6R5_UNORM);
+ break;
+ case WL_DRM_FORMAT_ARGB1555:
+ case WL_DRM_FORMAT_XRGB1555:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_B5G5R5A1_UNORM);
+ break;
+#endif
+ case WL_DRM_FORMAT_XRGB8888:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_B8G8R8_SRGB);
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_B8G8R8_UNORM);
+ /* fallthrough */
+ case WL_DRM_FORMAT_ARGB8888:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_B8G8R8A8_SRGB);
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_B8G8R8A8_UNORM);
+ break;
+#if 0
+ case WL_DRM_FORMAT_ARGB2101010:
+ case WL_DRM_FORMAT_XRGB2101010:
+ wsi_wl_display_add_vk_format(display, formats,
+ VK_FORMAT_B10G10R10A2_UNORM);
+ break;
+#endif
+ }
+}
+
+static void
drm_handle_device(void *data, struct wl_drm *drm, const char *name)
{
}
@@ -160,56 +231,7 @@ drm_handle_format(void *data, struct wl_drm *drm, uint32_t wl_format)
if (display->formats.element_size == 0)
return;
- switch (wl_format) {
-#if 0
- case WL_DRM_FORMAT_ABGR4444:
- case WL_DRM_FORMAT_XBGR4444:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_R4G4B4A4_UNORM);
- break;
- case WL_DRM_FORMAT_BGR565:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_R5G6B5_UNORM);
- break;
- case WL_DRM_FORMAT_ABGR1555:
- case WL_DRM_FORMAT_XBGR1555:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_R5G5B5A1_UNORM);
- break;
- case WL_DRM_FORMAT_XBGR8888:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_R8G8B8_UNORM);
- /* fallthrough */
- case WL_DRM_FORMAT_ABGR8888:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_R8G8B8A8_UNORM);
- break;
- case WL_DRM_FORMAT_ABGR2101010:
- case WL_DRM_FORMAT_XBGR2101010:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_R10G10B10A2_UNORM);
- break;
- case WL_DRM_FORMAT_ARGB4444:
- case WL_DRM_FORMAT_XRGB4444:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_B4G4R4A4_UNORM);
- break;
- case WL_DRM_FORMAT_RGB565:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_B5G6R5_UNORM);
- break;
- case WL_DRM_FORMAT_ARGB1555:
- case WL_DRM_FORMAT_XRGB1555:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_B5G5R5A1_UNORM);
- break;
-#endif
- case WL_DRM_FORMAT_XRGB8888:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_B8G8R8_SRGB);
- wsi_wl_display_add_vk_format(display, VK_FORMAT_B8G8R8_UNORM);
- /* fallthrough */
- case WL_DRM_FORMAT_ARGB8888:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_B8G8R8A8_SRGB);
- wsi_wl_display_add_vk_format(display, VK_FORMAT_B8G8R8A8_UNORM);
- break;
-#if 0
- case WL_DRM_FORMAT_ARGB2101010:
- case WL_DRM_FORMAT_XRGB2101010:
- wsi_wl_display_add_vk_format(display, VK_FORMAT_B10G10R10A2_UNORM);
- break;
-#endif
- }
+ wsi_wl_display_add_wl_format(display, &display->formats, wl_format);
}
static void