From f3daf7ce4023a54f666ae3d1fef40487c6e29da3 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 27 May 2022 13:51:39 +0200 Subject: [PATCH] radv: flush the NGG query state when the argument is declared MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When primitives generated query is used, the driver also needs to emulate counting for NGG VS/TES. Signed-off-by: Samuel Pitoiset Reviewed-by: Timur Kristóf Part-of: --- src/amd/vulkan/radv_cmd_buffer.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 68e6cf79f61..51c6bfdc1ec 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -3671,24 +3671,27 @@ static void radv_flush_ngg_query_state(struct radv_cmd_buffer *cmd_buffer) { struct radv_graphics_pipeline *pipeline = cmd_buffer->state.graphics_pipeline; + const unsigned stage = pipeline->last_vgt_api_stage; struct radv_userdata_info *loc; uint32_t ngg_query_state = 0; uint32_t base_reg; - if (!radv_pipeline_has_stage(pipeline, MESA_SHADER_GEOMETRY) || !pipeline->is_ngg) + loc = radv_lookup_user_sgpr(&pipeline->base, stage, AC_UD_NGG_QUERY_STATE); + if (loc->sgpr_idx == -1) return; - /* By default NGG GS queries are disabled but they are enabled if the - * command buffer has active GDS queries or if it's a secondary command - * buffer that inherits the number of generated primitives. + assert(pipeline->is_ngg); + + /* By default NGG queries are disabled but they are enabled if the command buffer has active GDS + * queries or if it's a secondary command buffer that inherits the number of generated + * primitives. */ if (cmd_buffer->state.active_pipeline_gds_queries || (cmd_buffer->state.inherited_pipeline_statistics & VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT)) ngg_query_state = 1; - loc = radv_lookup_user_sgpr(&pipeline->base, MESA_SHADER_GEOMETRY, AC_UD_NGG_QUERY_STATE); - base_reg = pipeline->base.user_data_0[MESA_SHADER_GEOMETRY]; + base_reg = pipeline->base.user_data_0[stage]; assert(loc->sgpr_idx != -1); radeon_set_sh_reg(cmd_buffer->cs, base_reg + loc->sgpr_idx * 4, ngg_query_state);