anv: Prevent clear color modifier corruption with views

If a dmabuf is shared with a clear color, the raw clear color channels
generally won't be interpreted correctly during format reinterpretation.
So, prevent Vulkan apps from trying to use such dmabufs as mutable
format render targets. Also, prevent such apps from using such dmabufs
as blorp_copy() destinations if doing so would require format
reinterpretation.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31136>
This commit is contained in:
Nanley Chery
2024-09-05 09:45:28 -04:00
committed by Marge Bot
parent edfb33efdd
commit 10bcfb63d5
+19
View File
@@ -840,6 +840,16 @@ anv_get_image_format_features2(const struct anv_physical_device *physical_device
flags &= ~VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT;
flags &= ~VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT;
}
if (isl_mod_info->supports_clear_color && plane_format.isl_format !=
blorp_copy_get_color_format(&physical_device->isl_dev,
plane_format.isl_format)) {
/* If the clear color is non-zero, blorp_copy() may interpret the raw
* clear color channels incorrectly when it changes the surface
* format. Disable support for this format as a copy destination.
*/
flags &= ~VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT;
}
}
if (devinfo->has_coarse_pixel_primitive_and_cb &&
@@ -1500,6 +1510,15 @@ anv_get_image_format_properties(
maxMipLevels = 1;
sampleCounts = VK_SAMPLE_COUNT_1_BIT;
if (isl_mod_info->supports_clear_color &&
(info->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) &&
(info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) {
/* Format reinterpretation generally won't work correctly with the
* raw clear color channels.
*/
goto unsupported;
}
if (isl_drm_modifier_has_aux(isl_mod_info->modifier) &&
!anv_formats_ccs_e_compatible(devinfo, info->flags, info->format,
info->tiling, info->usage,