panvk/v13: Support HSR Prepass

Add an option to enable HSR Prepass.

It is currently disabled by default as it might cause performance
regressions for content that:

- Has very simple fragment work.
- Already does a ZS prepass.

Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39615>
This commit is contained in:
Lars-Ivar Hesselberg Simonsen 2026-01-08 11:32:57 +01:00 committed by Marge Bot
parent 3d6c7cf8b7
commit 2d9be41706
5 changed files with 22 additions and 0 deletions

View file

@ -1225,6 +1225,22 @@ GENX(pan_emit_fbd)(const struct pan_fb_info *fb, unsigned layer_idx,
cfg.internal_layer_index = layer_idx - tiler_ctx->valhall.layer_offset;
cfg.frame_argument = layer_idx;
#endif
#if PAN_ARCH >= 13
unsigned zs_bytes_per_pixel = pan_zsbuf_bytes_per_pixel(fb);
/* We can interleave HSR if we have space for two ZS tiles in the tile
* buffer. */
unsigned max_zs_tile_size_interleave =
fb->z_tile_buf_budget >> util_logbase2_ceil(zs_bytes_per_pixel);
bool hsr_can_interleave = fb->tile_size <= max_zs_tile_size_interleave;
/* Enabling prepass without interleave is generally not good for
* performance, so disable HSR in that case. */
cfg.hsr_prepass_enable = fb->allow_hsr_prepass && hsr_can_interleave;
cfg.hsr_prepass_interleaving_enable = hsr_can_interleave;
cfg.hsr_prepass_filter_enable = true;
cfg.hsr_hierarchical_optimizations_enable = true;
#endif
}
#if PAN_ARCH >= 6

View file

@ -149,6 +149,7 @@ struct pan_fb_info {
/* Only used on Valhall */
bool sprite_coord_origin;
bool first_provoking_vertex;
bool allow_hsr_prepass;
/* indicates whether pixel local storage is enabled */
bool pls_enabled;

View file

@ -50,6 +50,7 @@ static const struct debug_control panvk_debug_options[] = {
{"no_user_mmap_sync", PANVK_DEBUG_NO_USER_MMAP_SYNC},
{"coherent_before_cached", PANVK_DEBUG_COHERENT_BEFORE_CACHED},
{"no_extended_va_range", PANVK_DEBUG_NO_EXTENDED_VA_RANGE},
{"hsr_prepass", PANVK_DEBUG_HSR_PREPASS},
{NULL, 0},
};

View file

@ -34,6 +34,7 @@ enum panvk_debug_flags {
PANVK_DEBUG_NO_USER_MMAP_SYNC = 1 << 15,
PANVK_DEBUG_COHERENT_BEFORE_CACHED = 1 << 16,
PANVK_DEBUG_NO_EXTENDED_VA_RANGE = 1 << 17,
PANVK_DEBUG_HSR_PREPASS = 1 << 17,
};
extern uint64_t panvk_debug;

View file

@ -394,6 +394,9 @@ panvk_per_arch(cmd_init_render_state)(struct panvk_cmd_buffer *cmdbuf,
.z_tile_buf_budget = pan_query_optimal_z_tib_size(PAN_ARCH, phys_dev->model),
.nr_samples = 0,
.rt_count = pRenderingInfo->colorAttachmentCount,
#if PAN_ARCH >= 13
.allow_hsr_prepass = PANVK_DEBUG(HSR_PREPASS),
#endif
};
/* In case ms2ss is enabled, use the provided sample count.
* All attachments need to have sample count == 1 or the provided value.