diff --git a/src/panfrost/lib/pan_desc.c b/src/panfrost/lib/pan_desc.c index b9cc92c14eb..2044cf0f13c 100644 --- a/src/panfrost/lib/pan_desc.c +++ b/src/panfrost/lib/pan_desc.c @@ -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 diff --git a/src/panfrost/lib/pan_desc.h b/src/panfrost/lib/pan_desc.h index 2acf033117e..642ef3299a1 100644 --- a/src/panfrost/lib/pan_desc.h +++ b/src/panfrost/lib/pan_desc.h @@ -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; diff --git a/src/panfrost/vulkan/panvk_instance.c b/src/panfrost/vulkan/panvk_instance.c index 6953ead7543..e2d61d11b7b 100644 --- a/src/panfrost/vulkan/panvk_instance.c +++ b/src/panfrost/vulkan/panvk_instance.c @@ -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}, }; diff --git a/src/panfrost/vulkan/panvk_instance.h b/src/panfrost/vulkan/panvk_instance.h index c2aa6fc078f..80cea67c79b 100644 --- a/src/panfrost/vulkan/panvk_instance.h +++ b/src/panfrost/vulkan/panvk_instance.h @@ -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; diff --git a/src/panfrost/vulkan/panvk_vX_cmd_draw.c b/src/panfrost/vulkan/panvk_vX_cmd_draw.c index 7d7738bcf7e..10951c710de 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_draw.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_draw.c @@ -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.