v3d: use shared v3d_tile_alloc_sizes() and 128B initial blocks

Replace the inline tile_alloc/TSDA sizing in alloc_tile_state() with a
call to the new v3d_tile_alloc_sizes() helper. This switches from 64B
to 128B initial tile alloc blocks (avoiding overflow for simple draws)
and from a flat 512KB headroom to a draw-proportional formula.

Set tile_allocation_initial_block_size and tile_allocation_block_size
in all TILE_BINNING_MODE_CFG emissions and update the
TILE_LIST_INITIAL_BLOCK_SIZE packet to match.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40554>
This commit is contained in:
Jose Maria Casanova Crespo 2026-03-19 10:39:35 +01:00 committed by Marge Bot
parent 47fa229605
commit 35efce437e
4 changed files with 26 additions and 29 deletions

View file

@ -554,36 +554,18 @@ alloc_tile_state(struct v3d_job *job)
{
assert(!job->tile_alloc && !job->tile_state);
/* The PTB will request the tile alloc initial size per tile at start
* of tile binning.
*/
uint32_t tile_alloc_size =
MAX2(job->num_layers, 1) * job->tile_desc.draw_x *
job->tile_desc.draw_y * 64;
/* The PTB allocates in aligned 4k chunks after the initial setup. */
tile_alloc_size = align(tile_alloc_size, 4096);
/* Include the first two chunk allocations that the PTB does so that
* we definitely clear the OOM condition before triggering one (the HW
* won't trigger OOM during the first allocations).
*/
tile_alloc_size += 8192;
/* For performance, allocate some extra initial memory after the PTB's
* minimal allocations, so that we hopefully don't have to block the
* GPU on the kernel handling an OOM signal.
*/
tile_alloc_size += 512 * 1024;
uint32_t tile_alloc_size, tile_state_size;
v3d_tile_alloc_sizes(MAX2(job->num_layers, 1),
job->tile_desc.draw_x,
job->tile_desc.draw_y,
job->draw_calls_queued,
job->v3d->screen->devinfo.page_size,
&tile_alloc_size,
&tile_state_size);
job->tile_alloc = v3d_bo_alloc(job->v3d->screen, tile_alloc_size,
"tile_alloc");
uint32_t tsda_per_tile_size = 256;
job->tile_state = v3d_bo_alloc(job->v3d->screen,
MAX2(job->num_layers, 1) *
job->tile_desc.draw_y *
job->tile_desc.draw_x *
tsda_per_tile_size,
job->tile_state = v3d_bo_alloc(job->v3d->screen, tile_state_size,
"TSDA");
}

View file

@ -74,6 +74,11 @@ v3dX(start_binning)(struct v3d_context *v3d, struct v3d_job *job)
config.log2_tile_width = log2_tile_size(job->tile_desc.width);
config.log2_tile_height = log2_tile_size(job->tile_desc.height);
config.tile_allocation_initial_block_size =
V3D_TILE_ALLOC_INITIAL_BLOCK_SIZE_ENUM;
config.tile_allocation_block_size =
V3D_TILE_ALLOC_OVERFLOW_BLOCK_SIZE_ENUM;
}
#endif
@ -88,6 +93,11 @@ v3dX(start_binning)(struct v3d_context *v3d, struct v3d_job *job)
config.double_buffer_in_non_ms_mode = job->double_buffer;
config.maximum_bpp_of_all_render_targets = job->internal_bpp;
config.tile_allocation_initial_block_size =
V3D_TILE_ALLOC_INITIAL_BLOCK_SIZE_ENUM;
config.tile_allocation_block_size =
V3D_TILE_ALLOC_OVERFLOW_BLOCK_SIZE_ENUM;
}
#endif

View file

@ -80,6 +80,10 @@ v3dX(job_emit_enable_double_buffer)(struct v3d_job *job)
config.width_in_pixels = job->draw_width;
config.height_in_pixels = job->draw_height;
config.tile_allocation_initial_block_size =
V3D_TILE_ALLOC_INITIAL_BLOCK_SIZE_ENUM;
config.tile_allocation_block_size =
V3D_TILE_ALLOC_OVERFLOW_BLOCK_SIZE_ENUM;
#if V3D_VERSION == 42
config.number_of_render_targets = MAX2(job->nr_cbufs, 1);
config.multisample_mode_4x = job->msaa;

View file

@ -571,7 +571,8 @@ emit_render_layer(struct v3d_job *job, uint32_t layer)
* core's tile list here.
*/
uint32_t tile_alloc_offset =
layer * job->tile_desc.draw_x * job->tile_desc.draw_y * 64;
layer * job->tile_desc.draw_x * job->tile_desc.draw_y *
V3D_TILE_ALLOC_INITIAL_BLOCK_SIZE;
cl_emit(&job->rcl, MULTICORE_RENDERING_TILE_LIST_SET_BASE, list) {
list.address = cl_address(job->tile_alloc, tile_alloc_offset);
}
@ -927,7 +928,7 @@ v3dX(emit_rcl)(struct v3d_job *job)
cl_emit(&job->rcl, TILE_LIST_INITIAL_BLOCK_SIZE, init) {
init.use_auto_chained_tile_lists = true;
init.size_of_first_block_in_chained_tile_lists =
TILE_ALLOCATION_BLOCK_SIZE_64B;
V3D_TILE_ALLOC_INITIAL_BLOCK_SIZE_ENUM;
}
/* ARB_framebuffer_no_attachments allows rendering to happen even when