anv: Allow aliasing with modifiers for WSI images

Ignore ALIAS_BIT when format comes from WSI because
we have the ability to bind the MEMORY_BINDING_PRIVATE
from the other WSI image.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7019

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18347>
This commit is contained in:
Oleksii Bozhenko
2022-09-08 22:45:45 +03:00
committed by Marge Bot
parent 949edb7ffa
commit f350b78b73
3 changed files with 23 additions and 6 deletions

View File

@@ -974,7 +974,8 @@ anv_get_image_format_properties(
struct anv_physical_device *physical_device, struct anv_physical_device *physical_device,
const VkPhysicalDeviceImageFormatInfo2 *info, const VkPhysicalDeviceImageFormatInfo2 *info,
VkImageFormatProperties *pImageFormatProperties, VkImageFormatProperties *pImageFormatProperties,
VkSamplerYcbcrConversionImageFormatProperties *pYcbcrImageFormatProperties) VkSamplerYcbcrConversionImageFormatProperties *pYcbcrImageFormatProperties,
bool from_wsi)
{ {
VkFormatFeatureFlags2 format_feature_flags; VkFormatFeatureFlags2 format_feature_flags;
VkExtent3D maxExtent; 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: /* Reject aliasing of images with non-linear DRM format modifiers because:
* *
* 1. For modifiers with compression, we store aux tracking state in * 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 * 2. For tiled modifiers without compression, we may attempt to compress
* them behind the scenes, in which case both the aux tracking state * them behind the scenes, in which case both the aux tracking state
* and the CCS data are bound to ANV_IMAGE_MEMORY_BINDING_PRIVATE. * 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 && if (info->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
isl_mod_info->modifier != DRM_FORMAT_MOD_LINEAR) { isl_mod_info->modifier != DRM_FORMAT_MOD_LINEAR) {
@@ -1288,7 +1292,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties(
}; };
return anv_get_image_format_properties(physical_device, &info, 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; VkSamplerYcbcrConversionImageFormatProperties *ycbcr_props = NULL;
VkAndroidHardwareBufferUsageANDROID *android_usage = NULL; VkAndroidHardwareBufferUsageANDROID *android_usage = NULL;
VkResult result; VkResult result;
bool from_wsi = false;
/* Extract input structs */ /* Extract input structs */
vk_foreach_struct_const(s, base_info->pNext) { 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: case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
external_info = (const void *) s; external_info = (const void *) s;
break; break;
@@ -1368,6 +1373,9 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2(
case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO: case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO:
/* Ignore but don't warn */ /* Ignore but don't warn */
break; break;
case VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA:
from_wsi = true;
break;
default: default:
anv_debug_ignored_stype(s->sType); anv_debug_ignored_stype(s->sType);
break; break;
@@ -1393,7 +1401,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2(
} }
result = anv_get_image_format_properties(physical_device, base_info, 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) if (result != VK_SUCCESS)
goto fail; goto fail;

View File

@@ -793,7 +793,7 @@ add_aux_surface_if_supported(struct anv_device *device,
return VK_SUCCESS; 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 /* The image may alias a plane of a multiplanar image. Above we ban
* CCS on multiplanar images. * 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. * live in a VkDeviceMemory. The one exception is swapchain images.
*/ */
assert(!(image->vk.create_flags & VK_IMAGE_CREATE_ALIAS_BIT) || assert(!(image->vk.create_flags & VK_IMAGE_CREATE_ALIAS_BIT) ||
image->from_wsi ||
image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].memory_range.size == 0); image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].memory_range.size == 0);
/* Check primary surface */ /* 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->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: /* The Vulkan 1.2.165 glossary says:
* *
* A disjoint image consists of multiple disjoint planes, and is created * A disjoint image consists of multiple disjoint planes, and is created

View File

@@ -3301,6 +3301,11 @@ struct anv_image {
*/ */
bool disjoint; bool disjoint;
/**
* Image is a WSI image
*/
bool from_wsi;
/** /**
* Image was imported from an struct AHardwareBuffer. We have to delay * Image was imported from an struct AHardwareBuffer. We have to delay
* final image creation until bind time. * final image creation until bind time.