From: Samuel Pitoiset Date: Tue, 3 Jul 2018 10:43:40 +0000 (+0200) Subject: radv: reduce CPU overhead in radv_flush_descriptors() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5e5a28d52a8068419ec795843777048236b36bcf;p=mesa.git radv: reduce CPU overhead in radv_flush_descriptors() The number of enabled descriptors for a given pipeline stage can be computed at compile time. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 1ea023a8116..4c4ad21288f 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -593,16 +593,9 @@ radv_emit_descriptor_pointers(struct radv_cmd_buffer *cmd_buffer, uint32_t sh_base = pipeline->user_data_0[stage]; struct radv_userdata_locations *locs = &pipeline->shaders[stage]->info.user_sgprs_locs; - unsigned mask; + unsigned mask = locs->descriptor_sets_enabled; - mask = descriptors_state->dirty & descriptors_state->valid; - - for (int i = 0; i < MAX_SETS; i++) { - struct radv_userdata_info *loc = &locs->descriptor_sets[i]; - if (loc->sgpr_idx != -1 && !loc->indirect) - continue; - mask &= ~(1 << i); - } + mask &= descriptors_state->dirty & descriptors_state->valid; while (mask) { int start, count; diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 15c10493022..cc3ae006aaa 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -578,11 +578,14 @@ static void set_loc_desc(struct radv_shader_context *ctx, int idx, uint8_t *sgpr_idx, uint32_t indirect_offset) { - struct radv_userdata_info *ud_info = - &ctx->shader_info->user_sgprs_locs.descriptor_sets[idx]; + struct radv_userdata_locations *locs = + &ctx->shader_info->user_sgprs_locs; + struct radv_userdata_info *ud_info = &locs->descriptor_sets[idx]; assert(ud_info); set_loc(ud_info, sgpr_idx, HAVE_32BIT_POINTERS ? 1 : 2, indirect_offset); + if (indirect_offset == 0) + locs->descriptor_sets_enabled |= 1 << idx; } struct user_sgpr_info { diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index ce7682e8bf7..03760b689c3 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -197,6 +197,7 @@ struct radv_userdata_info { struct radv_userdata_locations { struct radv_userdata_info descriptor_sets[RADV_UD_MAX_SETS]; struct radv_userdata_info shader_data[AC_UD_MAX_UD]; + uint32_t descriptor_sets_enabled; }; struct radv_vs_output_info {