From c958dd4b6bf9a7ee410a4f1851eaa0c99994ff66 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Tue, 29 Oct 2024 09:26:14 +0100 Subject: [PATCH] v3d: do tile state BO allocation later We don't need this until we are ready to emit the RCL for the job and we want to do this late because double-buffering will impact how big the allocations need to be. Reviewed-by: Jose Maria Casanova Crespo Part-of: --- src/gallium/drivers/v3d/v3d_job.c | 40 +++++++++++++++++++++++++++++ src/gallium/drivers/v3d/v3dx_draw.c | 32 ----------------------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/gallium/drivers/v3d/v3d_job.c b/src/gallium/drivers/v3d/v3d_job.c index 210fa91fd62..058bb761ba7 100644 --- a/src/gallium/drivers/v3d/v3d_job.c +++ b/src/gallium/drivers/v3d/v3d_job.c @@ -505,6 +505,44 @@ v3d_read_and_accumulate_primitive_counters(struct v3d_context *v3d) } } +static void +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; + + 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, + "TSDA"); +} + /** * Submits the job to the kernel and then reinitializes it. */ @@ -529,6 +567,8 @@ v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job) if (job->needs_primitives_generated) v3d_ensure_prim_counts_allocated(v3d); + alloc_tile_state(job); + v3d_X(devinfo, emit_rcl)(job); if (cl_offset(&job->bcl) > 0) diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index 4279d9a433b..90f7cfdd0aa 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -54,38 +54,6 @@ v3dX(start_binning)(struct v3d_context *v3d, struct v3d_job *job) job->submit.bcl_start = job->bcl.bo->offset; v3d_job_add_bo(job, job->bcl.bo); - /* 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; - - job->tile_alloc = v3d_bo_alloc(v3d->screen, tile_alloc_size, - "tile_alloc"); - uint32_t tsda_per_tile_size = 256; - job->tile_state = v3d_bo_alloc(v3d->screen, - MAX2(job->num_layers, 1) * - job->tile_desc.draw_y * - job->tile_desc.draw_x * - tsda_per_tile_size, - "TSDA"); - /* This must go before the binning mode configuration. It is * required for layered framebuffers to work. */