From 2cac70558d1e357271e13052bfdecf788bbd06fa Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Thu, 29 May 2025 22:10:32 +0200 Subject: [PATCH] v3d,v3dv: set max supertiles to 256 So far the driver was configuring the supertiles to be less than 256. But actually, there can be up to 256, not strictly less than 256. There is one restriction though: the frame width or height in supertiles must be less than 256. It also moves this limit to the limits file, which is shared by v3d and v3dv. Signed-off-by: Juan A. Suarez Romero Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/common/v3d_limits.h | 2 ++ src/broadcom/vulkan/v3dv_cmd_buffer.c | 11 +++++++++-- src/gallium/drivers/v3d/v3dx_rcl.c | 13 ++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/broadcom/common/v3d_limits.h b/src/broadcom/common/v3d_limits.h index b58aef7f28b..357e51bc675 100644 --- a/src/broadcom/common/v3d_limits.h +++ b/src/broadcom/common/v3d_limits.h @@ -48,6 +48,8 @@ #define V3D_MAX_BUFFER_RANGE (1 << 30) +#define V3D_MAX_SUPERTILES 256 + /* Sub-pixel precision bits in the rasterizer */ #define V3D_COORD_SHIFT 6 diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index 449544662d6..3682360cc79 100644 --- a/src/broadcom/vulkan/v3dv_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c @@ -412,7 +412,6 @@ job_compute_frame_tiling(struct v3dv_job *job, tiling->draw_tiles_y = DIV_ROUND_UP(height, tiling->tile_height); /* Size up our supertiles until we get under the limit */ - const uint32_t max_supertiles = 256; tiling->supertile_width = 1; tiling->supertile_height = 1; for (;;) { @@ -422,8 +421,16 @@ job_compute_frame_tiling(struct v3dv_job *job, DIV_ROUND_UP(tiling->draw_tiles_y, tiling->supertile_height); const uint32_t num_supertiles = tiling->frame_width_in_supertiles * tiling->frame_height_in_supertiles; - if (num_supertiles < max_supertiles) + + /* While the hardware allows up to V3D_MAX_SUPERTILES, it doesn't allow + * 1xV3D_MAX_SUPERTILES or V3D_MAX_SUPERTILESx1 frame configurations; in + * these cases we need to increase the supertile size. + */ + if (tiling->frame_width_in_supertiles < V3D_MAX_SUPERTILES && + tiling->frame_height_in_supertiles < V3D_MAX_SUPERTILES && + num_supertiles <= V3D_MAX_SUPERTILES) { break; + } if (tiling->supertile_width < tiling->supertile_height) tiling->supertile_width++; diff --git a/src/gallium/drivers/v3d/v3dx_rcl.c b/src/gallium/drivers/v3d/v3dx_rcl.c index 257c93b582c..cb251f82355 100644 --- a/src/gallium/drivers/v3d/v3dx_rcl.c +++ b/src/gallium/drivers/v3d/v3dx_rcl.c @@ -512,7 +512,6 @@ emit_render_layer(struct v3d_job *job, uint32_t layer) cl_emit(&job->rcl, MULTICORE_RENDERING_SUPERTILE_CFG, config) { uint32_t frame_w_in_supertiles, frame_h_in_supertiles; - const uint32_t max_supertiles = 256; /* Size up our supertiles until we get under the limit. */ for (;;) { @@ -520,8 +519,16 @@ emit_render_layer(struct v3d_job *job, uint32_t layer) supertile_w); frame_h_in_supertiles = DIV_ROUND_UP(job->tile_desc.draw_y, supertile_h); - if (frame_w_in_supertiles * - frame_h_in_supertiles < max_supertiles) { + uint32_t num_supertiles = frame_w_in_supertiles * + frame_h_in_supertiles; + /* While the hardware allows up to V3D_MAX_SUPERTILES, + * it doesn't allow 1xV3D_MAX_SUPERTILES or + * V3D_MAX_SUPERTILESx1 frame configurations; in these + * cases we need to increase the supertile size. + */ + if (frame_w_in_supertiles < V3D_MAX_SUPERTILES && + frame_h_in_supertiles < V3D_MAX_SUPERTILES && + num_supertiles <= V3D_MAX_SUPERTILES) { break; }