[Mesa-dev] [PATCH 09/14] radv/tess: remove last chunk of tess sgprs

Dave Airlie airlied at gmail.com
Wed Feb 21 01:35:37 UTC 2018


From: Dave Airlie <airlied at redhat.com>

This removes the last TES-specifc user sgpr.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/amd/common/ac_nir_to_llvm.c | 51 +++++++++++++----------------------------
 src/amd/common/ac_nir_to_llvm.h |  4 ++--
 src/amd/vulkan/radv_pipeline.c  | 18 ++-------------
 3 files changed, 20 insertions(+), 53 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 981c5d542a4..d43c0ab7fe9 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -81,7 +81,6 @@ struct radv_shader_context {
 	LLVMValueRef vs_prim_id;
 	LLVMValueRef es2gs_offset;
 
-	LLVMValueRef tcs_offchip_layout;
 	LLVMValueRef oc_lds;
 	LLVMValueRef merged_wave_info;
 	LLVMValueRef tess_factor_offset;
@@ -601,14 +600,11 @@ static void allocate_user_sgprs(struct radv_shader_context *ctx,
 		}
 		break;
 	case MESA_SHADER_TESS_EVAL:
-		user_sgpr_info->sgpr_count += 1;
 		break;
 	case MESA_SHADER_GEOMETRY:
 		if (has_previous_stage) {
 			if (previous_stage == MESA_SHADER_VERTEX) {
 				user_sgpr_info->sgpr_count += count_vs_user_sgprs(ctx);
-			} else {
-				user_sgpr_info->sgpr_count++;
 			}
 		}
 		user_sgpr_info->sgpr_count += 2;
@@ -900,7 +896,6 @@ static void create_function(struct radv_shader_context *ctx,
 					   previous_stage, &user_sgpr_info,
 					   &args, &desc_sets);
 
-		add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->tcs_offchip_layout);
 		if (needs_view_index)
 			add_arg(&args, ARG_SGPR, ctx->ac.i32,
 				&ctx->abi.view_index);
@@ -935,10 +930,7 @@ static void create_function(struct radv_shader_context *ctx,
 						   &user_sgpr_info, &args,
 						   &desc_sets);
 
-			if (previous_stage == MESA_SHADER_TESS_EVAL) {
-				add_arg(&args, ARG_SGPR, ctx->ac.i32,
-					&ctx->tcs_offchip_layout);
-			} else {
+			if (previous_stage != MESA_SHADER_TESS_EVAL) {
 				declare_vs_specific_input_sgprs(ctx, stage,
 								has_previous_stage,
 								previous_stage,
@@ -1094,7 +1086,6 @@ static void create_function(struct radv_shader_context *ctx,
 			set_loc_shader(ctx, AC_UD_VIEW_INDEX, &user_sgpr_idx, 1);
 		break;
 	case MESA_SHADER_TESS_EVAL:
-		set_loc_shader(ctx, AC_UD_TES_OFFCHIP_LAYOUT, &user_sgpr_idx, 1);
 		if (ctx->abi.view_index)
 			set_loc_shader(ctx, AC_UD_VIEW_INDEX, &user_sgpr_idx, 1);
 		break;
@@ -1105,9 +1096,6 @@ static void create_function(struct radv_shader_context *ctx,
 							   has_previous_stage,
 							   previous_stage,
 							   &user_sgpr_idx);
-			else
-				set_loc_shader(ctx, AC_UD_TES_OFFCHIP_LAYOUT,
-					       &user_sgpr_idx, 1);
 		}
 		set_loc_shader(ctx, AC_UD_GS_VS_RING_STRIDE_ENTRIES,
 			       &user_sgpr_idx, 2);
@@ -2783,35 +2771,28 @@ out:
  */
 static LLVMValueRef get_non_vertex_index_offset(struct radv_shader_context *ctx)
 {
-	if (ctx->stage == MESA_SHADER_TESS_CTRL) {
-		uint32_t num_tcs_outputs = util_last_bit64(ctx->shader_info->info.tcs.outputs_written);
-		uint32_t output_vertex_size = num_tcs_outputs * 16;
-		uint32_t pervertex_output_patch_size = ctx->tcs_vertices_per_patch * output_vertex_size;
-		uint32_t num_patches = ctx->tcs_num_patches;
+	uint32_t num_patches = ctx->tcs_num_patches;
+	uint32_t num_tcs_outputs;
 
-		return LLVMConstInt(ctx->ac.i32, pervertex_output_patch_size * num_patches, false);
-	} else
-		return unpack_param(&ctx->ac, ctx->tcs_offchip_layout, 16, 16);
+	if (ctx->stage == MESA_SHADER_TESS_CTRL)
+		num_tcs_outputs = util_last_bit64(ctx->shader_info->info.tcs.outputs_written);
+	else
+		num_tcs_outputs = ctx->options->key.tes.tcs_num_outputs;
+
+	uint32_t output_vertex_size = num_tcs_outputs * 16;
+	uint32_t pervertex_output_patch_size = ctx->tcs_vertices_per_patch * output_vertex_size;
+
+	return LLVMConstInt(ctx->ac.i32, pervertex_output_patch_size * num_patches, false);
 }
 
 static LLVMValueRef calc_param_stride(struct radv_shader_context *ctx,
 				      LLVMValueRef vertex_index)
 {
 	LLVMValueRef param_stride;
-	if (ctx->stage == MESA_SHADER_TESS_CTRL) {
-		if (vertex_index)
-			param_stride = LLVMConstInt(ctx->ac.i32, ctx->tcs_vertices_per_patch * ctx->tcs_num_patches, false);
-		else
-			param_stride = LLVMConstInt(ctx->ac.i32, ctx->tcs_num_patches, false);
-	} else {
-		LLVMValueRef num_patches = LLVMConstInt(ctx->ac.i32, ctx->tcs_num_patches, false);
-		LLVMValueRef vertices_per_patch = LLVMConstInt(ctx->ac.i32, ctx->tcs_vertices_per_patch, false);
-		if (vertex_index)
-			param_stride = LLVMBuildMul(ctx->ac.builder, vertices_per_patch,
-						    num_patches, "");
-		else
-			param_stride = num_patches;
-	}
+	if (vertex_index)
+		param_stride = LLVMConstInt(ctx->ac.i32, ctx->tcs_vertices_per_patch * ctx->tcs_num_patches, false);
+	else
+		param_stride = LLVMConstInt(ctx->ac.i32, ctx->tcs_num_patches, false);
 	return param_stride;
 
 }
diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h
index f1348c849b2..48a4a5b2049 100644
--- a/src/amd/common/ac_nir_to_llvm.h
+++ b/src/amd/common/ac_nir_to_llvm.h
@@ -49,7 +49,8 @@ struct ac_vs_variant_key {
 struct ac_tes_variant_key {
 	uint32_t as_es:1;
 	uint32_t export_prim_id:1;
-	uint32_t num_patches;
+	uint8_t num_patches;
+	uint8_t tcs_num_outputs;
 };
 
 struct ac_tcs_variant_key {
@@ -114,7 +115,6 @@ enum ac_ud_index {
 	AC_UD_GS_VS_RING_STRIDE_ENTRIES = AC_UD_VS_MAX_UD,
 	AC_UD_GS_MAX_UD,
 	AC_UD_TCS_MAX_UD,
-	AC_UD_TES_OFFCHIP_LAYOUT = AC_UD_SHADER_START,
 	AC_UD_TES_MAX_UD,
 	AC_UD_MAX_UD = AC_UD_TCS_MAX_UD,
 };
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 92a8d8c7051..5fdbce093d0 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -62,7 +62,6 @@ struct radv_blend_state {
 
 struct radv_tessellation_state {
 	uint32_t ls_hs_config;
-	uint32_t offchip_layout;
 	unsigned num_patches;
 	unsigned lds_size;
 	uint32_t tf_param;
@@ -1379,9 +1378,6 @@ calculate_tess_state(struct radv_pipeline *pipeline,
 
 	tess.lds_size = lds_size;
 
-	tess.offchip_layout = (pervertex_output_patch_size * num_patches << 16) |
-		num_patches;
-
 	tess.ls_hs_config = S_028B58_NUM_PATCHES(num_patches) |
 		S_028B58_HS_NUM_INPUT_CP(num_tcs_input_cp) |
 		S_028B58_HS_NUM_OUTPUT_CP(num_tcs_output_cp);
@@ -1787,6 +1783,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
 		}
 		modules[MESA_SHADER_VERTEX] = NULL;
 		keys[MESA_SHADER_TESS_EVAL].tes.num_patches = pipeline->shaders[MESA_SHADER_TESS_CTRL]->info.tcs.num_patches;
+		keys[MESA_SHADER_TESS_EVAL].tes.tcs_num_outputs = util_last_bit64(pipeline->shaders[MESA_SHADER_TESS_CTRL]->info.info.tcs.outputs_written);
 	}
 
 	if (device->physical_device->rad_info.chip_class >= GFX9 && modules[MESA_SHADER_GEOMETRY]) {
@@ -1808,6 +1805,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
 			}
 			if (i == MESA_SHADER_TESS_EVAL) {
 				keys[MESA_SHADER_TESS_EVAL].tes.num_patches = pipeline->shaders[MESA_SHADER_TESS_CTRL]->info.tcs.num_patches;
+				keys[MESA_SHADER_TESS_EVAL].tes.tcs_num_outputs = util_last_bit64(pipeline->shaders[MESA_SHADER_TESS_CTRL]->info.info.tcs.outputs_written);
 			}
 			pipeline->shaders[i] = radv_shader_variant_create(device, modules[i], &nir[i], 1,
 									  pipeline->layout,
@@ -2606,18 +2604,6 @@ radv_pipeline_generate_tess_shaders(struct radeon_winsys_cs *cs,
 	else
 		radeon_set_context_reg(cs, R_028B58_VGT_LS_HS_CONFIG,
 				       tess->ls_hs_config);
-
-	struct ac_userdata_info *loc;
-
-	loc = radv_lookup_user_sgpr(pipeline, MESA_SHADER_TESS_EVAL, AC_UD_TES_OFFCHIP_LAYOUT);
-	if (loc->sgpr_idx != -1) {
-		uint32_t base_reg = pipeline->user_data_0[MESA_SHADER_TESS_EVAL];
-		assert(loc->num_sgprs == 1);
-		assert(!loc->indirect);
-
-		radeon_set_sh_reg(cs, base_reg + loc->sgpr_idx * 4,
-				  tess->offchip_layout);
-	}
 }
 
 static void
-- 
2.14.3



More information about the mesa-dev mailing list