From 73637dbce4d1c7ea7569ae6249ffa75b56f2508d Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Mon, 26 Aug 2024 14:31:37 -0400 Subject: [PATCH] intel/blorp: Choose some copy formats independently blorp_copy_get_formats() tries to make the source and destination view formats match as much as possible. This avoids some casting in the copy shader, but it makes determining the format that will be used for a surface impossible without having the ISL surface for both that surface and a source or destination. We'd like to enable the Vulkan driver to know as early as possible what format an image may be reinterpreted as for correctness. So, determine the copy formats more independently and expose a helper which does so for drivers. Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/blorp/blorp.h | 3 +++ src/intel/blorp/blorp_blit.c | 47 +++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h index 76afb9af784..5da4c1de372 100644 --- a/src/intel/blorp/blorp.h +++ b/src/intel/blorp/blorp.h @@ -232,6 +232,9 @@ blorp_blit(struct blorp_batch *batch, enum blorp_filter filter, bool mirror_x, bool mirror_y); +enum isl_format +blorp_copy_get_color_format(const struct isl_device *isl_dev, + enum isl_format surf_format); void blorp_copy_get_formats(const struct isl_device *isl_dev, const struct isl_surf *src_surf, diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c index af75d1394bd..156b78bbd18 100644 --- a/src/intel/blorp/blorp_blit.c +++ b/src/intel/blorp/blorp_blit.c @@ -2771,6 +2771,25 @@ get_ccs_compatible_copy_format(const struct isl_format_layout *fmtl) } } +enum isl_format +blorp_copy_get_color_format(const struct isl_device *isl_dev, + enum isl_format surf_format) +{ + const struct isl_format_layout *fmtl = isl_format_get_layout(surf_format); + + if (ISL_GFX_VER(isl_dev) <= 12 && + isl_format_supports_ccs_e(isl_dev->info, surf_format)) { + /* On gfx9-12, choose a copy format that maintains compatibility with + * CCS_E. Although format reinterpretation doesn't affect compression + * support while rendering on gfx12, the sampler does have reduced + * support for compression when the bits-per-channel changes. + */ + return get_ccs_compatible_copy_format(fmtl); + } else { + return get_copy_format_for_bpb(isl_dev, fmtl->bpb); + } +} + void blorp_surf_convert_to_uncompressed(const struct isl_device *isl_dev, struct blorp_surface_info *info, @@ -2874,33 +2893,17 @@ blorp_copy_get_formats(const struct isl_device *isl_dev, */ *src_view_format = dst_surf->format; *dst_view_format = dst_surf->format; - } else if (isl_surf_usage_is_depth(src_surf->usage) || - isl_surf_usage_is_depth(dst_surf->usage)) { + } else if (isl_surf_usage_is_depth_or_stencil(src_surf->usage) || + isl_surf_usage_is_depth_or_stencil(dst_surf->usage)) { assert(src_fmtl->bpb == dst_fmtl->bpb); *src_view_format = *dst_view_format = get_copy_format_for_bpb(isl_dev, dst_fmtl->bpb); - } else if (ISL_GFX_VER(isl_dev) < 20 && - isl_format_supports_ccs_e(isl_dev->info, dst_surf->format)) { - *dst_view_format = get_ccs_compatible_copy_format(dst_fmtl); - if (isl_format_supports_ccs_e(isl_dev->info, src_surf->format)) { - *src_view_format = get_ccs_compatible_copy_format(src_fmtl); - } else if (src_fmtl->bpb == dst_fmtl->bpb) { - *src_view_format = *dst_view_format; - } else { - *src_view_format = get_copy_format_for_bpb(isl_dev, src_fmtl->bpb); - } - } else if (ISL_GFX_VER(isl_dev) < 20 && - isl_format_supports_ccs_e(isl_dev->info, src_surf->format)) { - *src_view_format = get_ccs_compatible_copy_format(src_fmtl); - if (src_fmtl->bpb == dst_fmtl->bpb) { - *dst_view_format = *src_view_format; - } else { - *dst_view_format = get_copy_format_for_bpb(isl_dev, dst_fmtl->bpb); - } } else { - *dst_view_format = get_copy_format_for_bpb(isl_dev, dst_fmtl->bpb); - *src_view_format = get_copy_format_for_bpb(isl_dev, src_fmtl->bpb); + *src_view_format = + blorp_copy_get_color_format(isl_dev, src_surf->format); + *dst_view_format = + blorp_copy_get_color_format(isl_dev, dst_surf->format); } }