[Mesa-dev] [PATCH 2/2] radv: replace grid_components_used by uses_grid_size

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Dec 14 11:51:07 UTC 2017


Use a boolean instead because the number of needed SGPRs
is always 3.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/common/ac_nir_to_llvm.c | 7 ++++---
 src/amd/common/ac_shader_info.c | 2 +-
 src/amd/common/ac_shader_info.h | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index ce25e57eba..0e1d7e0082 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -576,7 +576,8 @@ static void allocate_user_sgprs(struct nir_to_llvm_context *ctx,
 
 	switch (ctx->stage) {
 	case MESA_SHADER_COMPUTE:
-		user_sgpr_info->sgpr_count += ctx->shader_info->info.cs.grid_components_used;
+		if (ctx->shader_info->info.cs.uses_grid_size)
+			user_sgpr_info->sgpr_count += 3;
 		break;
 	case MESA_SHADER_FRAGMENT:
 		user_sgpr_info->sgpr_count += ctx->shader_info->info.ps.needs_sample_positions;
@@ -745,7 +746,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
 	switch (stage) {
 	case MESA_SHADER_COMPUTE:
 		radv_define_common_user_sgprs_phase1(ctx, stage, has_previous_stage, previous_stage, &user_sgpr_info, &args, &desc_sets);
-		if (ctx->shader_info->info.cs.grid_components_used) {
+		if (ctx->shader_info->info.cs.uses_grid_size) {
 			add_user_sgpr_argument(&args, ctx->ac.v3i32,
 					       &ctx->num_work_groups);
 		}
@@ -951,7 +952,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
 
 	switch (stage) {
 	case MESA_SHADER_COMPUTE:
-		if (ctx->shader_info->info.cs.grid_components_used) {
+		if (ctx->shader_info->info.cs.uses_grid_size) {
 			set_userdata_location_shader(ctx, AC_UD_CS_GRID_SIZE,
 						     &user_sgpr_idx, 3);
 		}
diff --git a/src/amd/common/ac_shader_info.c b/src/amd/common/ac_shader_info.c
index 53e584065c..09dd4bbd55 100644
--- a/src/amd/common/ac_shader_info.c
+++ b/src/amd/common/ac_shader_info.c
@@ -43,7 +43,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, struct ac_shader_info *info)
 		info->vs.needs_instance_id = true;
 		break;
 	case nir_intrinsic_load_num_work_groups:
-		info->cs.grid_components_used = instr->num_components;
+		info->cs.uses_grid_size = true;
 		break;
 	case nir_intrinsic_load_sample_id:
 		info->ps.force_persample = true;
diff --git a/src/amd/common/ac_shader_info.h b/src/amd/common/ac_shader_info.h
index c1d36a667e..3c809cce13 100644
--- a/src/amd/common/ac_shader_info.h
+++ b/src/amd/common/ac_shader_info.h
@@ -42,7 +42,7 @@ struct ac_shader_info {
 		bool uses_input_attachments;
 	} ps;
 	struct {
-		uint8_t grid_components_used;
+		bool uses_grid_size;
 	} cs;
 };
 
-- 
2.15.1



More information about the mesa-dev mailing list