From 20bf27f2a85adbcd58d862a4a29256e53ebea6da Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Fri, 27 Feb 2026 08:24:39 -0500 Subject: [PATCH] intel/blorp: Make blorp_copy() format queries aux-dependent blorp_copy() will soon start changing the format in a way which drivers cannot rely on to do things like manage the texture cache (see iris). Narrow down the scope of blorp_copy_get_formats() and blorp_copy_get_color_format() such that the returned value can only be trusted if compression would be enabled on each image. By doing this (and adapting iris to reflect this), we'll get the required flushes on the platforms which need WaSamplerCacheFlushBetweenRedescribedSurfaceReads: * On the platforms which need the workaround for all formats, blorp_copy() will stick with the queried format on compressed surfaces. * On the platforms which need the workaround when switching from ASTC and non-ASTC formats, blorp_copy() may actually change the queried format on compressed surfaces. This is not a problem, because surfaces which may be read with ASTC formats are not compressible. Prevents gfx9 from failing tests under: * KHR-GL46.copy_image.functional_src_target_texture_2d_array_src_format_r3_g3_b2* * KHR-GL46.copy_image.functional_src_target_texture_2d_array_src_format_rgb5* * KHR-GL46.copy_image.functional_src_target_texture_2d_array_src_format_rgba2* * KHR-GL46.copy_image.functional_src_target_texture_2d_array_src_format_rgba4* Reviewed-by: Lionel Landwerlin Part-of: --- src/gallium/drivers/iris/iris_blit.c | 12 +++++++++--- src/intel/blorp/blorp.h | 6 ++++++ src/intel/blorp/blorp_blit.c | 4 ++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/iris/iris_blit.c b/src/gallium/drivers/iris/iris_blit.c index 475e2b63c3a..32a5e8e38df 100644 --- a/src/gallium/drivers/iris/iris_blit.c +++ b/src/gallium/drivers/iris/iris_blit.c @@ -262,7 +262,8 @@ iris_blorp_surf_for_resource(struct iris_batch *batch, static bool is_astc(enum isl_format format) { - return isl_format_get_layout(format)->txc == ISL_TXC_ASTC; + return format != ISL_FORMAT_UNSUPPORTED && + isl_format_get_layout(format)->txc == ISL_TXC_ASTC; } static void @@ -686,8 +687,13 @@ iris_copy_region(struct blorp_context *blorp, enum isl_aux_usage dst_aux_usage = copy_region_aux_usage(ice, batch, dst_res, dst_fmt, dst_level, true); - if (iris_batch_references(batch, src_res->bo)) - tex_cache_flush_hack(batch, src_fmt, src_res->surf.format); + if (iris_batch_references(batch, src_res->bo)) { + /* blorp_copy_get_formats() is only valid for compressed surfaces. */ + tex_cache_flush_hack(batch, + src_aux_usage == ISL_AUX_USAGE_NONE ? + ISL_FORMAT_UNSUPPORTED : src_fmt, + src_res->surf.format); + } if (dst->target == PIPE_BUFFER) util_range_add(&dst_res->base.b, &dst_res->valid_buffer_range, dstx, dstx + src_box->width); diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h index 3c29100d383..0ec501a80d4 100644 --- a/src/intel/blorp/blorp.h +++ b/src/intel/blorp/blorp.h @@ -255,10 +255,16 @@ blorp_blit(struct blorp_batch *batch, enum blorp_filter filter, bool mirror_x, bool mirror_y); +/* Returns the format the blorp_copy() call can be assumed to use if it + * receives a blorp surface which enables lossless compression. + */ enum isl_format blorp_copy_get_color_format(const struct isl_device *isl_dev, enum isl_format surf_format); +/* Returns the format the blorp_copy() call can be assumed to use if it + * receives a blorp surface which enables lossless compression. + */ 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 db8a607a926..0c353509692 100644 --- a/src/intel/blorp/blorp_blit.c +++ b/src/intel/blorp/blorp_blit.c @@ -3007,6 +3007,10 @@ blorp_copy(struct blorp_batch *batch, params.src.aux_usage == ISL_AUX_USAGE_FCV_CCS_E || params.src.aux_usage == ISL_AUX_USAGE_STC_CCS); + /* The public interface states that the value returned by the format query + * is valid for losslessly compressed surfaces. Internally, we're free to + * use it as a starting point for all surfaces. + */ blorp_copy_get_formats(isl_dev, ¶ms.src.surf, ¶ms.dst.surf, ¶ms.src.view.format, ¶ms.dst.view.format);