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(