anv: Disable storage image compression for possible atomic ops

It looks like atomics are slow on compressed surfaces so when enabling
compression for storage images that can be possibly used for atomic
operation hinders performance. Lets just disable compression in this
scenario.

v2: Reword comment (Ken)
    Allow mutable with 16/32/64 bits (Ken)

Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14712>
This commit is contained in:
Sagar Ghuge 2021-11-03 18:20:58 -07:00 committed by Marge Bot
parent f052e00a58
commit 7e098db1ae

View file

@ -369,6 +369,46 @@ anv_image_plane_needs_shadow_surface(const struct intel_device_info *devinfo,
return false;
}
/**
* Return true if the storage image could be used with atomics.
*
* If the image was created with an explicit format, we check it for typed
* atomic support. If MUTABLE_FORMAT_BIT is set, then we check the optional
* format list, seeing if /any/ of the formats support typed atomics. If no
* list is supplied, we fall back to using the bpb, as the application could
* make an image view with a format that does use atomics.
*/
static bool
storage_image_format_supports_atomic(const struct intel_device_info *devinfo,
VkImageCreateFlags create_flags,
enum isl_format format,
VkImageTiling vk_tiling,
const VkImageFormatListCreateInfoKHR *fmt_list)
{
if (isl_format_supports_typed_atomics(devinfo, format))
return true;
if (!(create_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT))
return false;
if (fmt_list) {
for (uint32_t i = 0; i < fmt_list->viewFormatCount; i++) {
enum isl_format view_format =
anv_get_isl_format(devinfo, fmt_list->pViewFormats[i],
VK_IMAGE_ASPECT_COLOR_BIT, vk_tiling);
if (isl_format_supports_typed_atomics(devinfo, view_format))
return true;
}
return false;
}
/* No explicit format list. Any 16/32/64bpp format could be used with atomics. */
unsigned bpb = isl_format_get_layout(format)->bpb;
return bpb == 16 || bpb == 32 || bpb == 64;
}
static enum isl_format
anv_get_isl_format_with_usage(const struct intel_device_info *devinfo,
VkFormat vk_format,
@ -451,6 +491,13 @@ anv_formats_ccs_e_compatible(const struct intel_device_info *devinfo,
if (!formats_ccs_e_compatible(devinfo, create_flags, format, vk_tiling,
VK_IMAGE_USAGE_STORAGE_BIT, fmt_list))
return false;
/* Disable compression when surface can be potentially used for atomic
* operation.
*/
if (storage_image_format_supports_atomic(devinfo, create_flags, format,
vk_tiling, fmt_list))
return false;
}
return true;