[Mesa-dev] [PATCH 4/9] radv/ac: move needs_push_constants to shader info.

Dave Airlie airlied at gmail.com
Tue Apr 18 03:57:07 UTC 2017


From: Dave Airlie <airlied at redhat.com>

First step to optimising push constants.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/amd/common/ac_nir_to_llvm.c | 12 ++----------
 src/amd/common/ac_shader_info.c |  8 ++++++++
 src/amd/common/ac_shader_info.h |  1 +
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 7d19a78..a24f203 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -565,7 +565,6 @@ static void create_function(struct nir_to_llvm_context *ctx)
 	unsigned i;
 	unsigned num_sets = ctx->options->layout ? ctx->options->layout->num_sets : 0;
 	unsigned user_sgpr_idx;
-	bool need_push_constants;
 	bool need_ring_offsets = false;
 
 	/* until we sort out scratch/global buffers always assign ring offsets for gs/vs/es */
@@ -577,13 +576,6 @@ static void create_function(struct nir_to_llvm_context *ctx)
 	    ctx->is_gs_copy_shader)
 		need_ring_offsets = true;
 
-	need_push_constants = true;
-	if (!ctx->options->layout)
-		need_push_constants = false;
-	else if (!ctx->options->layout->push_constant_size &&
-		 !ctx->options->layout->dynamic_offset_count)
-		need_push_constants = false;
-
 	if (need_ring_offsets && !ctx->options->supports_spill) {
 		arg_types[arg_idx++] = const_array(ctx->v16i8, 16); /* address of rings */
 	}
@@ -596,7 +588,7 @@ static void create_function(struct nir_to_llvm_context *ctx)
 		}
 	}
 
-	if (need_push_constants) {
+	if (ctx->shader_info->info.needs_push_constants) {
 		/* 1 for push constants and dynamic descriptors */
 		array_params_mask |= (1 << arg_idx);
 		arg_types[arg_idx++] = const_array(ctx->i8, 1024 * 1024);
@@ -758,7 +750,7 @@ static void create_function(struct nir_to_llvm_context *ctx)
 			ctx->descriptor_sets[i] = NULL;
 	}
 
-	if (need_push_constants) {
+	if (ctx->shader_info->info.needs_push_constants) {
 		ctx->push_constants = LLVMGetParam(ctx->main_function, arg_idx++);
 		set_userdata_location_shader(ctx, AC_UD_PUSH_CONSTANTS, user_sgpr_idx, 2);
 		user_sgpr_idx += 2;
diff --git a/src/amd/common/ac_shader_info.c b/src/amd/common/ac_shader_info.c
index 6be66a9..b319bb1 100644
--- a/src/amd/common/ac_shader_info.c
+++ b/src/amd/common/ac_shader_info.c
@@ -81,6 +81,14 @@ ac_nir_shader_info_pass(struct nir_shader *nir,
 			struct ac_shader_info *info)
 {
 	struct nir_function *func = (struct nir_function *)exec_list_get_head(&nir->functions);
+
+	info->needs_push_constants = true;
+	if (!options->layout)
+		info->needs_push_constants = false;
+	else if (!options->layout->push_constant_size &&
+		 !options->layout->dynamic_offset_count)
+		info->needs_push_constants = false;
+
 	nir_foreach_variable(variable, &nir->inputs)
 		gather_info_input_decl(nir, options, variable, info);
 
diff --git a/src/amd/common/ac_shader_info.h b/src/amd/common/ac_shader_info.h
index 5acfb21..3d644ab 100644
--- a/src/amd/common/ac_shader_info.h
+++ b/src/amd/common/ac_shader_info.h
@@ -28,6 +28,7 @@ struct ac_nir_compiler_options;
 /* a NIR pass to gather all the info needed to optimise the alloction patterns for the RADV user sgprs */
 
 struct ac_shader_info {
+	bool needs_push_constants;
 	struct {
 		bool has_vertex_buffers; /* needs vertex buffers and base/start */
 		bool needs_base_vertex_start_instance;
-- 
2.9.3



More information about the mesa-dev mailing list