diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index d38ca9e5577..a05a4d3eca9 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -974,7 +974,8 @@ anv_get_image_format_properties( struct anv_physical_device *physical_device, const VkPhysicalDeviceImageFormatInfo2 *info, VkImageFormatProperties *pImageFormatProperties, - VkSamplerYcbcrConversionImageFormatProperties *pYcbcrImageFormatProperties) + VkSamplerYcbcrConversionImageFormatProperties *pYcbcrImageFormatProperties, + bool from_wsi) { VkFormatFeatureFlags2 format_feature_flags; VkExtent3D maxExtent; @@ -1199,7 +1200,7 @@ anv_get_image_format_properties( } } - if (info->flags & VK_IMAGE_CREATE_ALIAS_BIT) { + if ((info->flags & VK_IMAGE_CREATE_ALIAS_BIT) && !from_wsi) { /* Reject aliasing of images with non-linear DRM format modifiers because: * * 1. For modifiers with compression, we store aux tracking state in @@ -1209,6 +1210,9 @@ anv_get_image_format_properties( * 2. For tiled modifiers without compression, we may attempt to compress * them behind the scenes, in which case both the aux tracking state * and the CCS data are bound to ANV_IMAGE_MEMORY_BINDING_PRIVATE. + * + * 3. For WSI we should ignore ALIAS_BIT because we have the ability to + * bind the ANV_MEMORY_BINDING_PRIVATE from the other WSI image. */ if (info->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT && isl_mod_info->modifier != DRM_FORMAT_MOD_LINEAR) { @@ -1288,7 +1292,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( }; return anv_get_image_format_properties(physical_device, &info, - pImageFormatProperties, NULL); + pImageFormatProperties, NULL, false); } @@ -1354,10 +1358,11 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2( VkSamplerYcbcrConversionImageFormatProperties *ycbcr_props = NULL; VkAndroidHardwareBufferUsageANDROID *android_usage = NULL; VkResult result; + bool from_wsi = false; /* Extract input structs */ vk_foreach_struct_const(s, base_info->pNext) { - switch (s->sType) { + switch ((unsigned)s->sType) { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO: external_info = (const void *) s; break; @@ -1368,6 +1373,9 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2( case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO: /* Ignore but don't warn */ break; + case VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA: + from_wsi = true; + break; default: anv_debug_ignored_stype(s->sType); break; @@ -1393,7 +1401,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2( } result = anv_get_image_format_properties(physical_device, base_info, - &base_props->imageFormatProperties, ycbcr_props); + &base_props->imageFormatProperties, ycbcr_props, from_wsi); if (result != VK_SUCCESS) goto fail; diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index a88538b59b2..a6327cb9c06 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -793,7 +793,7 @@ add_aux_surface_if_supported(struct anv_device *device, return VK_SUCCESS; } - if ((image->vk.create_flags & VK_IMAGE_CREATE_ALIAS_BIT)) { + if ((image->vk.create_flags & VK_IMAGE_CREATE_ALIAS_BIT) && !image->from_wsi) { /* The image may alias a plane of a multiplanar image. Above we ban * CCS on multiplanar images. * @@ -1037,6 +1037,7 @@ check_memory_bindings(const struct anv_device *device, * live in a VkDeviceMemory. The one exception is swapchain images. */ assert(!(image->vk.create_flags & VK_IMAGE_CREATE_ALIAS_BIT) || + image->from_wsi || image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].memory_range.size == 0); /* Check primary surface */ @@ -1460,6 +1461,9 @@ anv_image_init(struct anv_device *device, struct anv_image *image, image->n_planes = anv_get_format_planes(image->vk.format); + image->from_wsi = + vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA) != NULL; + /* The Vulkan 1.2.165 glossary says: * * A disjoint image consists of multiple disjoint planes, and is created diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index deb0ce73a6d..fcd5f7415f7 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -3301,6 +3301,11 @@ struct anv_image { */ bool disjoint; + /** + * Image is a WSI image + */ + bool from_wsi; + /** * Image was imported from an struct AHardwareBuffer. We have to delay * final image creation until bind time.