[Mesa-dev] [PATCH 1/2] radv: reduce CPU overhead in radv_flush_descriptors()

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Jul 3 10:43:40 UTC 2018


The number of enabled descriptors for a given pipeline stage
can be computed at compile time.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_cmd_buffer.c  | 11 ++---------
 src/amd/vulkan/radv_nir_to_llvm.c |  7 +++++--
 src/amd/vulkan/radv_shader.h      |  1 +
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index e020153c29..26d9fef314 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 ce6d5e1547..7ea674e2c3 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 ce7682e8bf..03760b689c 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 {
-- 
2.18.0



More information about the mesa-dev mailing list