radv: reduce CPU overhead in radv_flush_descriptors()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 3 Jul 2018 10:43:40 +0000 (12:43 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 9 Jul 2018 11:56:58 +0000 (13:56 +0200)
The number of enabled descriptors for a given pipeline stage
can be computed at compile time.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_nir_to_llvm.c
src/amd/vulkan/radv_shader.h

index 1ea023a8116e4fcead3cc17d92792b1aff9207b4..4c4ad21288fc7d9457c94b16347bf16d0fdd8b98 100644 (file)
@@ -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;
index 15c1049302282d750f72b7be6b53114a5b153864..cc3ae006aaad6079182ff86b10a0056a4caf3ba3 100644 (file)
@@ -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 {
index ce7682e8bf7e3af7d9b7a856c930b080a38c723a..03760b689c33c71afaa6bbae5e6b762fb904afff 100644 (file)
@@ -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 {