hasvk: 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.

This commit is the same as f350b78b but for hasvk.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19840>
This commit is contained in:
Väinö Mäkelä 2022-11-18 08:56:46 +02:00 committed by Marge Bot
parent 586ba9c223
commit d4bcfed422
3 changed files with 22 additions and 6 deletions

View file

@ -984,7 +984,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;
@ -1216,7 +1217,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
@ -1226,6 +1227,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) {
@ -1309,7 +1313,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties(
};
return anv_get_image_format_properties(physical_device, &info,
pImageFormatProperties, NULL);
pImageFormatProperties, NULL, false);
}
@ -1375,10 +1379,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;
@ -1389,6 +1394,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;
@ -1414,7 +1422,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;

View file

@ -627,7 +627,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.
*
@ -855,6 +855,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 */
@ -1277,6 +1278,8 @@ 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:
*

View file

@ -3239,6 +3239,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.