From 31727f114a909d2ec84a943de0340ba48c6a2915 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Sat, 16 Apr 2022 21:33:05 -0700 Subject: [PATCH] venus: use linear modifier for legacy common wsi path Towards the renderer, venus better uses VK_EXT_image_drm_format_modifier to force linear with tiling modifier and mod_linear. Doing so won't make any difference on the mesa implementations we care about given we have required VK_EXT_image_drm_format_modifier for wsi support. A lucky side effect of this is to allow common wsi to work with host implementations not supporting dma_buf export. Signed-off-by: Yiwei Zhang Part-of: --- src/virtio/vulkan/vn_wsi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/virtio/vulkan/vn_wsi.c b/src/virtio/vulkan/vn_wsi.c index 7f0ed9dbc37..007af746f4e 100644 --- a/src/virtio/vulkan/vn_wsi.c +++ b/src/virtio/vulkan/vn_wsi.c @@ -10,6 +10,7 @@ #include "vn_wsi.h" +#include "drm-uapi/drm_fourcc.h" #include "vk_enum_to_str.h" #include "wsi_common_entrypoints.h" @@ -110,17 +111,29 @@ vn_wsi_create_image(struct vn_device *dev, struct vn_image **out_img) { /* TODO This is the legacy path used by wsi_create_native_image when there - * is no modifier support. Instead of forcing VK_IMAGE_TILING_LINEAR, we - * should ask wsi to use wsi_create_prime_image instead. + * is no modifier support. Instead of forcing linear tiling, we should ask + * wsi to use wsi_create_prime_image instead. * * In fact, this is not enough when the image is truely used for scanout by * the host compositor. There can be requirements we fail to meet. We * should require modifier support at some point. */ + const uint64_t modifier = DRM_FORMAT_MOD_LINEAR; + const VkImageDrmFormatModifierListCreateInfoEXT mod_list_info = { + .sType = + VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT, + .pNext = create_info->pNext, + .drmFormatModifierCount = 1, + .pDrmFormatModifiers = &modifier, + }; VkImageCreateInfo local_create_info; if (wsi_info->scanout) { + assert(!vk_find_struct_const( + create_info->pNext, IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT)); + local_create_info = *create_info; - local_create_info.tiling = VK_IMAGE_TILING_LINEAR; + local_create_info.pNext = &mod_list_info; + local_create_info.tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT; create_info = &local_create_info; if (VN_DEBUG(WSI))