[Mesa-dev] [PATCH v2 21/25] radeonsi: do not write non-existent components through the GSVS ring

Nicolai Hähnle nhaehnle at gmail.com
Tue Dec 6 10:48:32 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/gallium/drivers/radeonsi/si_shader.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index e360c31..cd109e1 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -5190,21 +5190,22 @@ static void si_llvm_emit_vertex(
 				   ctx->voidt, &kill, 1, 0);
 	} else {
 		lp_build_if(&if_state, gallivm, can_emit);
 	}
 
 	for (i = 0; i < info->num_outputs; i++) {
 		LLVMValueRef *out_ptr =
 			ctx->soa.outputs[i];
 
 		for (chan = 0; chan < 4; chan++) {
-			if (((info->output_streams[i] >> (2 * chan)) & 3) != stream)
+			if (!(info->output_usagemask[i] & (1 << chan)) ||
+			    ((info->output_streams[i] >> (2 * chan)) & 3) != stream)
 				continue;
 
 			LLVMValueRef out_val = LLVMBuildLoad(gallivm->builder, out_ptr[chan], "");
 			LLVMValueRef voffset =
 				lp_build_const_int32(gallivm, (i * 4 + chan) *
 						     shader->selector->gs_max_out_vertices);
 
 			voffset = lp_build_add(uint, voffset, gs_next_vertex);
 			voffset = lp_build_mul_imm(uint, voffset, 4);
 
@@ -6298,21 +6299,22 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
 		if (stream > 0 && !gs_selector->so.num_outputs)
 			continue;
 
 		bb = LLVMInsertBasicBlockInContext(gallivm->context, end_bb, "out");
 		LLVMAddCase(switch_inst, lp_build_const_int32(gallivm, stream), bb);
 		LLVMPositionBuilderAtEnd(builder, bb);
 
 		/* Fetch vertex data from GSVS ring */
 		for (i = 0; i < gsinfo->num_outputs; ++i) {
 			for (unsigned chan = 0; chan < 4; chan++) {
-				if (outputs[i].vertex_stream[chan] != stream) {
+				if (!(gsinfo->output_usagemask[i] & (1 << chan)) ||
+				    outputs[i].vertex_stream[chan] != stream) {
 					outputs[i].values[chan] = ctx.soa.bld_base.base.undef;
 					continue;
 				}
 
 				args[2] = lp_build_const_int32(
 					gallivm,
 					(i * 4 + chan) * gs_selector->gs_max_out_vertices * 16 * 4);
 
 				outputs[i].values[chan] =
 					LLVMBuildBitCast(gallivm->builder,
-- 
2.7.4



More information about the mesa-dev mailing list