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 <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39974>
This commit is contained in:
Nanley Chery 2026-02-27 08:24:39 -05:00 committed by Marge Bot
parent 7fffd67803
commit 20bf27f2a8
3 changed files with 19 additions and 3 deletions

View file

@ -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);

View file

@ -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,

View file

@ -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, &params.src.surf, &params.dst.surf,
&params.src.view.format, &params.dst.view.format);