From 303acdef07d23f0ce49e3e027938b96bacf3e890 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 26 Oct 2023 20:54:52 +0200 Subject: [PATCH] panfrost: Add a helper to expose the maximum effective tile size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On all previous GPUs, the effective tile size was limited to 16x16, but it got increased on v10. Add an helper to query this maximum effective tile size. Signed-off-by: Boris Brezillon Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Louis-Francis Ratté-Boulianne Acked-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/panfrost/pan_csf.c | 4 ++++ src/panfrost/lib/pan_desc.c | 12 ++++++------ src/panfrost/lib/pan_props.h | 9 +++++++++ src/panfrost/vulkan/panvk_cmd_draw.h | 4 ++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_csf.c b/src/gallium/drivers/panfrost/pan_csf.c index cedd54d9e25..7c4053038b5 100644 --- a/src/gallium/drivers/panfrost/pan_csf.c +++ b/src/gallium/drivers/panfrost/pan_csf.c @@ -650,6 +650,10 @@ csf_emit_tiler_desc(struct panfrost_batch *batch, const struct pan_fb_info *fb) if (MAX2(batch->key.width, batch->key.height) >= 4096) tiler.hierarchy_mask &= ~1; + /* For effective tile size larger than 16x16, disable first level */ + if (fb->tile_size > 16 * 16) + tiler.hierarchy_mask &= ~1; + tiler.fb_width = batch->key.width; tiler.fb_height = batch->key.height; tiler.heap = batch->ctx->csf.heap.desc_bo->ptr.gpu; diff --git a/src/panfrost/lib/pan_desc.c b/src/panfrost/lib/pan_desc.c index 455f2db99e5..fd7c3bb5eca 100644 --- a/src/panfrost/lib/pan_desc.c +++ b/src/panfrost/lib/pan_desc.c @@ -31,6 +31,7 @@ #include "pan_desc.h" #include "pan_encoder.h" +#include "pan_props.h" #include "pan_texture.h" static unsigned @@ -93,10 +94,8 @@ GENX(pan_select_crc_rt)(const struct pan_fb_info *fb, unsigned tile_size) * CRCs are more expensive at smaller tile sizes, reducing the benefit. * Restricting CRC to 16x16 should work in practice. */ - if (tile_size != 16 * 16) { - assert(tile_size < 16 * 16); + if (tile_size < 16 * 16) return -1; - } #if PAN_ARCH <= 6 if (fb->rt_count == 1 && fb->rts[0].view && !fb->rts[0].discard && @@ -371,7 +370,8 @@ GENX(pan_select_tile_size)(struct pan_fb_info *fb) fb->tile_size = fb->tile_buf_budget >> util_logbase2_ceil(bytes_per_pixel); /* Clamp tile size to hardware limits */ - fb->tile_size = MIN2(fb->tile_size, 16 * 16); + fb->tile_size = + MIN2(fb->tile_size, panfrost_max_effective_tile_size(PAN_ARCH)); assert(fb->tile_size >= 4 * 4); /* Colour buffer allocations must be 1K aligned. */ @@ -695,7 +695,7 @@ pan_force_clean_write_rt(const struct pan_image_view *rt, unsigned tile_size) unsigned superblock = panfrost_afbc_superblock_width(image->layout.modifier); assert(superblock >= 16); - assert(tile_size <= 16 * 16); + assert(tile_size <= panfrost_max_effective_tile_size(PAN_ARCH)); /* Tile size and superblock differ unless they are both 16x16 */ return !(superblock == 16 && tile_size == 16 * 16); @@ -705,7 +705,7 @@ static bool pan_force_clean_write(const struct pan_fb_info *fb, unsigned tile_size) { /* Maximum tile size */ - assert(tile_size <= 16 * 16); + assert(tile_size <= panfrost_max_effective_tile_size(PAN_ARCH)); for (unsigned i = 0; i < fb->rt_count; ++i) { if (fb->rts[i].view && !fb->rts[i].discard && diff --git a/src/panfrost/lib/pan_props.h b/src/panfrost/lib/pan_props.h index 00d0a861c9c..220872e2cc8 100644 --- a/src/panfrost/lib/pan_props.h +++ b/src/panfrost/lib/pan_props.h @@ -128,4 +128,13 @@ pan_arch(unsigned gpu_id) } } +static inline unsigned +panfrost_max_effective_tile_size(unsigned arch) +{ + if (arch >= 10) + return 32 * 32; + + return 16 * 16; +} + #endif diff --git a/src/panfrost/vulkan/panvk_cmd_draw.h b/src/panfrost/vulkan/panvk_cmd_draw.h index ca260a80b5e..1b792098073 100644 --- a/src/panfrost/vulkan/panvk_cmd_draw.h +++ b/src/panfrost/vulkan/panvk_cmd_draw.h @@ -186,6 +186,10 @@ panvk_select_tiler_hierarchy_mask(const struct panvk_physical_device *phys_dev, if (last_hierarchy_bit > tiler_features.max_levels) hierarchy_mask <<= last_hierarchy_bit - tiler_features.max_levels; + /* For effective tile size larger than 16x16, disable first level */ + if (state->render.fb.info.tile_size > 16 * 16) + hierarchy_mask &= ~1; + return hierarchy_mask; }