From 2ce78a30ffa259e87d1a20dda09dd8179476d60c Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 1 Oct 2021 09:49:43 +0200 Subject: [PATCH] move: move ngg lds bytes determination earlier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuel Pitoiset Reviewed-by: Timur Kristóf Part-of: --- src/amd/common/ac_nir.h | 1 - src/amd/common/ac_nir_lower_ngg.c | 4 ---- src/amd/vulkan/radv_pipeline.c | 12 ++++++++++++ src/amd/vulkan/radv_shader.c | 1 - 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/amd/common/ac_nir.h b/src/amd/common/ac_nir.h index d9eb77c6f5d..0bcfbc15682 100644 --- a/src/amd/common/ac_nir.h +++ b/src/amd/common/ac_nir.h @@ -93,7 +93,6 @@ ac_nir_lower_indirect_derefs(nir_shader *shader, typedef struct { - unsigned lds_bytes_if_culling_off; bool passthrough; uint64_t nggc_inputs_read_by_pos; uint64_t nggc_inputs_read_by_others; diff --git a/src/amd/common/ac_nir_lower_ngg.c b/src/amd/common/ac_nir_lower_ngg.c index 99f6ac422bf..ccf4de29afa 100644 --- a/src/amd/common/ac_nir_lower_ngg.c +++ b/src/amd/common/ac_nir_lower_ngg.c @@ -1301,9 +1301,6 @@ ac_nir_lower_ngg_nogs(nir_shader *shader, if (shader->info.stage == MESA_SHADER_VERTEX && export_prim_id) state.total_lds_bytes = max_num_es_vertices * 4u; - /* The shader only needs this much LDS when culling is turned off. */ - unsigned lds_bytes_if_culling_off = state.total_lds_bytes; - nir_builder builder; nir_builder *b = &builder; /* This is to avoid the & */ nir_builder_init(b, impl); @@ -1418,7 +1415,6 @@ ac_nir_lower_ngg_nogs(nir_shader *shader, shader->info.shared_size = state.total_lds_bytes; ac_nir_ngg_config ret = { - .lds_bytes_if_culling_off = lds_bytes_if_culling_off, .passthrough = passthrough, .nggc_inputs_read_by_pos = state.inputs_needed_by_pos, .nggc_inputs_read_by_others = state.inputs_needed_by_others, diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index f7c6697a867..3d5a800429e 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -2786,6 +2786,18 @@ radv_determine_ngg_settings(struct radv_pipeline *pipeline, nir_function_impl *impl = nir_shader_get_entrypoint(nir[es_stage]); infos[es_stage].has_ngg_early_prim_export = exec_list_is_singular(&impl->body); + + /* Invocations that process an input vertex */ + const struct gfx10_ngg_info *ngg_info = &infos[es_stage].ngg_info; + unsigned max_vtx_in = MIN2(256, ngg_info->enable_vertex_grouping ? ngg_info->hw_max_esverts : num_vertices_per_prim * ngg_info->max_gsprims); + + unsigned lds_bytes_if_culling_off = 0; + /* We need LDS space when VS needs to export the primitive ID. */ + if (es_stage == MESA_SHADER_VERTEX && infos[es_stage].vs.outinfo.export_prim_id) + lds_bytes_if_culling_off = max_vtx_in * 4u; + infos[es_stage].num_lds_blocks_when_not_culling = + DIV_ROUND_UP(lds_bytes_if_culling_off, + device->physical_device->rad_info.lds_encode_granularity); } } diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 99139ecae11..93b88f8f0cc 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -1015,7 +1015,6 @@ void radv_lower_ngg(struct radv_device *device, struct nir_shader *nir, false, pl_key->vs.instance_rate_inputs); - info->num_lds_blocks_when_not_culling = DIV_ROUND_UP(out_conf.lds_bytes_if_culling_off, device->physical_device->rad_info.lds_encode_granularity); info->is_ngg_passthrough = out_conf.passthrough; } else if (nir->info.stage == MESA_SHADER_GEOMETRY) { assert(info->is_ngg);