[Mesa-dev] [PATCH 2/3] radeonsi: replace ctx->soa.outputs by ctx->outputs

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Jan 12 13:07:48 UTC 2017


The plan is to replace si_shader_context::soa with its parent
structure (ie. bld_base).

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/gallium/drivers/radeonsi/si_shader.c           | 20 +++++++--------
 .../drivers/radeonsi/si_shader_tgsi_setup.c        | 29 +++++++++++++---------
 2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 030ff76ac9..962c2f206c 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2779,7 +2779,7 @@ static void si_llvm_emit_ls_epilogue(struct lp_build_tgsi_context *bld_base)
 	/* Write outputs to LDS. The next shader (TCS aka HS) will read
 	 * its inputs from it. */
 	for (i = 0; i < info->num_outputs; i++) {
-		LLVMValueRef *out_ptr = ctx->soa.outputs[i];
+		LLVMValueRef *out_ptr = ctx->outputs[i];
 		unsigned name = info->output_semantic_name[i];
 		unsigned index = info->output_semantic_index[i];
 		int param = si_shader_io_get_unique_index(name, index);
@@ -2805,8 +2805,7 @@ static void si_llvm_emit_es_epilogue(struct lp_build_tgsi_context *bld_base)
 	int i;
 
 	for (i = 0; i < info->num_outputs; i++) {
-		LLVMValueRef *out_ptr =
-			ctx->soa.outputs[i];
+		LLVMValueRef *out_ptr = ctx->outputs[i];
 		int param_index;
 
 		if (info->output_semantic_name[i] == TGSI_SEMANTIC_VIEWPORT_INDEX ||
@@ -2883,7 +2882,7 @@ static void si_llvm_emit_vs_epilogue(struct lp_build_tgsi_context *bld_base)
 			}
 
 			for (j = 0; j < 4; j++) {
-				addr = ctx->soa.outputs[i][j];
+				addr = ctx->outputs[i][j];
 				val = LLVMBuildLoad(gallivm->builder, addr, "");
 				val = si_llvm_saturate(bld_base, val);
 				LLVMBuildStore(gallivm->builder, val, addr);
@@ -2901,7 +2900,7 @@ static void si_llvm_emit_vs_epilogue(struct lp_build_tgsi_context *bld_base)
 		for (j = 0; j < 4; j++) {
 			outputs[i].values[j] =
 				LLVMBuildLoad(gallivm->builder,
-					      ctx->soa.outputs[i][j],
+					      ctx->outputs[i][j],
 					      "");
 			outputs[i].vertex_stream[j] =
 				(info->output_streams[i] >> (2 * j)) & 3;
@@ -3151,22 +3150,22 @@ static void si_llvm_return_fs_outputs(struct lp_build_tgsi_context *bld_base)
 		case TGSI_SEMANTIC_COLOR:
 			assert(semantic_index < 8);
 			for (j = 0; j < 4; j++) {
-				LLVMValueRef ptr = ctx->soa.outputs[i][j];
+				LLVMValueRef ptr = ctx->outputs[i][j];
 				LLVMValueRef result = LLVMBuildLoad(builder, ptr, "");
 				color[semantic_index][j] = result;
 			}
 			break;
 		case TGSI_SEMANTIC_POSITION:
 			depth = LLVMBuildLoad(builder,
-					      ctx->soa.outputs[i][2], "");
+					      ctx->outputs[i][2], "");
 			break;
 		case TGSI_SEMANTIC_STENCIL:
 			stencil = LLVMBuildLoad(builder,
-						ctx->soa.outputs[i][1], "");
+						ctx->outputs[i][1], "");
 			break;
 		case TGSI_SEMANTIC_SAMPLEMASK:
 			samplemask = LLVMBuildLoad(builder,
-						   ctx->soa.outputs[i][0], "");
+						   ctx->outputs[i][0], "");
 			break;
 		default:
 			fprintf(stderr, "Warning: SI unhandled fs output type:%d\n",
@@ -5310,8 +5309,7 @@ static void si_llvm_emit_vertex(
 
 	offset = 0;
 	for (i = 0; i < info->num_outputs; i++) {
-		LLVMValueRef *out_ptr =
-			ctx->soa.outputs[i];
+		LLVMValueRef *out_ptr = ctx->outputs[i];
 
 		for (chan = 0; chan < 4; chan++) {
 			if (!(info->output_usagemask[i] & (1 << chan)) ||
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index 8aebde9fe5..53b173e519 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -594,7 +594,6 @@ store_value_to_array(struct lp_build_tgsi_context *bld_base,
 		     const struct tgsi_ind_register *reg_indirect)
 {
 	struct si_shader_context *ctx = si_shader_context(bld_base);
-	struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base);
 	struct gallivm_state *gallivm = bld_base->base.gallivm;
 	LLVMBuilderRef builder = gallivm->builder;
 	LLVMValueRef ptr;
@@ -616,7 +615,7 @@ store_value_to_array(struct lp_build_tgsi_context *bld_base,
 		for (i = 0; i < size; ++i) {
 			switch(file) {
 			case TGSI_FILE_OUTPUT:
-				temp_ptr = bld->outputs[i + range.First][chan_index];
+				temp_ptr = ctx->outputs[i + range.First][chan_index];
 				break;
 
 			case TGSI_FILE_TEMPORARY:
@@ -644,13 +643,22 @@ static bool si_preload_fs_inputs(struct si_shader_context *ctx)
 	return ctx->shader->selector->info.uses_derivatives;
 }
 
+static LLVMValueRef
+get_output_ptr(struct lp_build_tgsi_context *bld_base, unsigned index,
+	       unsigned chan)
+{
+	struct si_shader_context *ctx = si_shader_context(bld_base);
+
+	assert(index <= ctx->bld_base.info->file_max[TGSI_FILE_OUTPUT]);
+	return ctx->outputs[index][chan];
+}
+
 LLVMValueRef si_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base,
 				const struct tgsi_full_src_register *reg,
 				enum tgsi_opcode_type type,
 				unsigned swizzle)
 {
 	struct si_shader_context *ctx = si_shader_context(bld_base);
-	struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base);
 	LLVMBuilderRef builder = bld_base->base.gallivm->builder;
 	LLVMValueRef result = NULL, ptr, ptr2;
 
@@ -726,9 +734,9 @@ LLVMValueRef si_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base,
 		break;
 
 	case TGSI_FILE_OUTPUT:
-		ptr = lp_get_output_ptr(bld, reg->Register.Index, swizzle);
+		ptr = get_output_ptr(bld_base, reg->Register.Index, swizzle);
 		if (tgsi_type_is_64bit(type)) {
-			ptr2 = lp_get_output_ptr(bld, reg->Register.Index, swizzle + 1);
+			ptr2 = get_output_ptr(bld_base, reg->Register.Index, swizzle + 1);
 			return si_llvm_emit_fetch_64bit(bld_base, type,
 							LLVMBuildLoad(builder, ptr, ""),
 							LLVMBuildLoad(builder, ptr2, ""));
@@ -915,14 +923,14 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
 		for (idx = decl->Range.First; idx <= decl->Range.Last; idx++) {
 			unsigned chan;
 			assert(idx < RADEON_LLVM_MAX_OUTPUTS);
-			if (ctx->soa.outputs[idx][0])
+			if (ctx->outputs[idx][0])
 				continue;
 			for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) {
 #ifdef DEBUG
 				snprintf(name, sizeof(name), "OUT%d.%c",
 					 idx, "xyzw"[chan % 4]);
 #endif
-				ctx->soa.outputs[idx][chan] = lp_build_alloca_undef(
+				ctx->outputs[idx][chan] = lp_build_alloca_undef(
 					&ctx->gallivm,
 					ctx->soa.bld_base.base.elem_type, name);
 			}
@@ -1010,9 +1018,9 @@ void si_llvm_emit_store(struct lp_build_tgsi_context *bld_base,
 		} else {
 			switch(reg->Register.File) {
 			case TGSI_FILE_OUTPUT:
-				temp_ptr = bld->outputs[reg->Register.Index][chan_index];
+				temp_ptr = ctx->outputs[reg->Register.Index][chan_index];
 				if (tgsi_type_is_64bit(dtype))
-					temp_ptr2 = bld->outputs[reg->Register.Index][chan_index + 1];
+					temp_ptr2 = ctx->outputs[reg->Register.Index][chan_index + 1];
 				break;
 
 			case TGSI_FILE_TEMPORARY:
@@ -1319,9 +1327,6 @@ void si_llvm_context_init(struct si_shader_context *ctx,
 	ctx->fpmath_md_2p5_ulp = LLVMMDNodeInContext(ctx->gallivm.context,
 						     &arg, 1);
 
-	/* Allocate outputs */
-	ctx->soa.outputs = ctx->outputs;
-
 	bld_base->op_actions[TGSI_OPCODE_BGNLOOP].emit = bgnloop_emit;
 	bld_base->op_actions[TGSI_OPCODE_BRK].emit = brk_emit;
 	bld_base->op_actions[TGSI_OPCODE_CONT].emit = cont_emit;
-- 
2.11.0



More information about the mesa-dev mailing list