radv: compute the total LDS usage in gfx10_get_ngg_info()

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27722>
This commit is contained in:
Samuel Pitoiset 2024-02-21 15:28:49 +01:00 committed by Marge Bot
parent d85311b120
commit 4071c399a2
3 changed files with 10 additions and 18 deletions

View file

@ -770,23 +770,6 @@ radv_consider_culling(const struct radv_physical_device *pdevice, struct nir_sha
return true;
}
static void
setup_ngg_lds_layout(struct radv_device *device, nir_shader *nir, struct radv_shader_info *info)
{
if (info->stage == MESA_SHADER_MESH) {
/* not handled here */
return;
}
/* Get scratch LDS usage. */
unsigned scratch_lds_size =
ac_ngg_get_scratch_lds_size(info->stage, info->workgroup_size, info->wave_size,
device->physical_device->use_ngg_streamout, info->has_ngg_culling);
/* Get total LDS usage. */
nir->info.shared_size = info->ngg_info.scratch_lds_base + scratch_lds_size;
}
void
radv_lower_ngg(struct radv_device *device, struct radv_shader_stage *ngg_stage,
const struct radv_graphics_state_key *gfx_state)
@ -830,7 +813,8 @@ radv_lower_ngg(struct radv_device *device, struct radv_shader_stage *ngg_stage,
unreachable("NGG needs to be VS, TES or GS.");
}
setup_ngg_lds_layout(device, nir, &ngg_stage->info);
if (nir->info.stage != MESA_SHADER_MESH)
nir->info.shared_size = info->ngg_info.lds_size;
ac_nir_lower_ngg_options options = {0};
options.family = device->physical_device->rad_info.family;

View file

@ -322,6 +322,7 @@ struct gfx10_ngg_info {
uint32_t vgt_esgs_ring_itemsize;
uint32_t esgs_ring_size;
uint32_t scratch_lds_base;
uint32_t lds_size;
bool max_vert_out_per_gs_instance;
};

View file

@ -1609,6 +1609,13 @@ gfx10_get_ngg_info(const struct radv_device *device, struct radv_shader_info *es
out->scratch_lds_base = gfx10_get_ngg_scratch_lds_base(device, es_info, gs_info, out);
/* Get scratch LDS usage. */
const struct radv_shader_info *info = gs_info ? gs_info : es_info;
const unsigned scratch_lds_size =
ac_ngg_get_scratch_lds_size(info->stage, info->workgroup_size, info->wave_size,
device->physical_device->use_ngg_streamout, info->has_ngg_culling);
out->lds_size = out->scratch_lds_base + scratch_lds_size;
unsigned workgroup_size =
ac_compute_ngg_workgroup_size(max_esverts, max_gsprims * gs_num_invocations, max_out_vertices, prim_amp_factor);
if (gs_info) {