freedreno/ir3: Move pvtmem per-fiber size alignment to the compiler.

Instead of having tu and each fd backend do it.  This will help me make
some shared code on freedreno for pre-6xx pvtmem support.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24358>
This commit is contained in:
Emma Anholt 2023-07-27 10:52:17 -07:00 committed by Marge Bot
parent a297624182
commit e3274e9e1b
6 changed files with 11 additions and 3 deletions

View file

@ -215,7 +215,7 @@ cs_program_emit(struct fd_ringbuffer *ring, struct kernel *kernel)
OUT_RELOC(ring, v->bo, 0, 0, 0);
if (v->pvtmem_size > 0) {
uint32_t per_fiber_size = ALIGN(v->pvtmem_size, 512);
uint32_t per_fiber_size = v->pvtmem_size;
uint32_t per_sp_size =
ALIGN(per_fiber_size * a6xx_backend->info->a6xx.fibers_per_sp, 1 << 12);
uint32_t total_size = per_sp_size * a6xx_backend->info->num_sp_cores;

View file

@ -217,6 +217,9 @@ ir3_compiler_create(struct fd_device *dev, const struct fd_dev_id *dev_id,
compiler->max_const_safe = 256;
}
/* This is just a guess for a4xx. */
compiler->pvtmem_per_fiber_align = compiler->gen >= 4 ? 512 : 128;
if (compiler->gen >= 6) {
compiler->reg_size_vec4 = dev_info->a6xx.reg_size_vec4;
} else if (compiler->gen >= 4) {

View file

@ -191,6 +191,9 @@ struct ir3_compiler {
/* The number of total branch stack entries, divided by wave_granularity. */
uint32_t branchstack_size;
/* The byte increment of MEMSIZEPERITEM, the private memory per-fiber allocation. */
uint32_t pvtmem_per_fiber_align;
/* Whether clip+cull distances are supported */
bool has_clip_cull;

View file

@ -4990,6 +4990,8 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
so->branchstack = ctx->max_stack;
so->pvtmem_size = ALIGN(so->pvtmem_size, compiler->pvtmem_per_fiber_align);
/* Note that max_bary counts inputs that are not bary.f'd for FS: */
if (so->type == MESA_SHADER_FRAGMENT)
so->total_in = max_bary + 1;

View file

@ -573,7 +573,7 @@ struct ir3_shader_variant {
*/
unsigned constlen;
/* The private memory size in bytes */
/* The private memory size in bytes per fiber */
unsigned pvtmem_size;
/* Whether we should use the new per-wave layout rather than per-fiber. */
bool pvtmem_per_wave;

View file

@ -107,7 +107,7 @@ fd6_emit_shader(struct fd_context *ctx, struct fd_ringbuffer *ring,
uint32_t fibers_per_sp = ctx->screen->info->a6xx.fibers_per_sp;
uint32_t num_sp_cores = ctx->screen->info->num_sp_cores;
uint32_t per_fiber_size = ALIGN(so->pvtmem_size, 512);
uint32_t per_fiber_size = so->pvtmem_size;
if (per_fiber_size > ctx->pvtmem[so->pvtmem_per_wave].per_fiber_size) {
if (ctx->pvtmem[so->pvtmem_per_wave].bo)
fd_bo_del(ctx->pvtmem[so->pvtmem_per_wave].bo);