Module: Mesa Branch: main Commit: 833d228f53a0ac01828a2a004695e8a70776fbef URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=833d228f53a0ac01828a2a004695e8a70776fbef
Author: Ryan Neph <ryann...@google.com> Date: Wed Nov 8 11:12:23 2023 -0800 venus: strip ALIAS_BIT for WSI image creation on ANV For compositors that advertise modifier support, Vulkan common WSI modifier support queries still fail in Venus on the Intel ANV driver. This is due to the presence of VK_CREATE_IMAGE_ALIAS_BIT, without accompanying wsi_image_create_info struct, which is implicitly excluded from serialized messages over the venus-protocol. By removing ALIAS_BIT, modifier queries begin to pass when the host supports them. Signed-off-by: Ryan Neph <ryann...@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26240> --- src/virtio/vulkan/vn_physical_device.c | 19 +++++++++++++++++-- src/virtio/vulkan/vn_wsi.c | 11 ++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index ecd776724f9..4cb80d13095 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -2023,12 +2023,13 @@ vn_GetPhysicalDeviceImageFormatProperties2( const VkExternalMemoryHandleTypeFlags supported_handle_types = physical_dev->external_memory.supported_handle_types; + const struct wsi_image_create_info *wsi_info = vk_find_struct_const( + pImageFormatInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA); + /* force common wsi into choosing DRM_FORMAT_MOD_LINEAR or else fall back * to the legacy path, for which Venus also forces LINEAR for wsi images. */ if (VN_PERF(NO_TILED_WSI_IMAGE)) { - const struct wsi_image_create_info *wsi_info = vk_find_struct_const( - pImageFormatInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA); const VkPhysicalDeviceImageDrmFormatModifierInfoEXT *modifier_info = vk_find_struct_const( pImageFormatInfo->pNext, @@ -2088,6 +2089,20 @@ vn_GetPhysicalDeviceImageFormatProperties2( } } + /* Since venus-protocol doesn't pass the wsi_image_create_info struct, we + * must remove the ALIAS_BIT here and in vn_wsi_create_image(). + * ANV rejects the bit for external+nonlinear images that don't have WSI + * info chained. + */ + if (wsi_info && physical_dev->renderer_driver_id == + VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA) { + if (pImageFormatInfo != &local_info.format) { + local_info.format = *pImageFormatInfo; + pImageFormatInfo = &local_info.format; + } + local_info.format.flags &= ~VK_IMAGE_CREATE_ALIAS_BIT; + } + VkResult result; /* TODO per-device cache */ result = vn_call_vkGetPhysicalDeviceImageFormatProperties2( diff --git a/src/virtio/vulkan/vn_wsi.c b/src/virtio/vulkan/vn_wsi.c index 66ba7de8b69..b070226d938 100644 --- a/src/virtio/vulkan/vn_wsi.c +++ b/src/virtio/vulkan/vn_wsi.c @@ -122,15 +122,14 @@ vn_wsi_create_image(struct vn_device *dev, .drmFormatModifierCount = 1, .pDrmFormatModifiers = &modifier, }; - VkImageCreateInfo local_create_info; + VkImageCreateInfo local_create_info = *create_info; + create_info = &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.pNext = &mod_list_info; local_create_info.tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT; - create_info = &local_create_info; if (VN_DEBUG(WSI)) { vn_log( @@ -138,6 +137,12 @@ vn_wsi_create_image(struct vn_device *dev, "forcing scanout image linear (no explicit modifier support)"); } } else { + if (dev->physical_device->renderer_driver_id == + VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA) { + /* See explanation in vn_GetPhysicalDeviceImageFormatProperties2() */ + local_create_info.flags &= ~VK_IMAGE_CREATE_ALIAS_BIT; + } + if (VN_PERF(NO_TILED_WSI_IMAGE)) { const VkImageDrmFormatModifierListCreateInfoEXT *modifier_info = vk_find_struct_const(