[Mesa-dev] [PATCH v2 17/25] radeonsi: only export from GS copy shader for vertex stream 0

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


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

When running the copy shader for vertex streams != 0, the SX does not need
any data from us (there is no rasterization for the higher vertex streams,
only streamout).
---
 src/gallium/drivers/radeonsi/si_shader.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index f5b4041..5b1acc6 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -6287,40 +6287,47 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
 			outputs[i].values[chan] =
 				LLVMBuildBitCast(gallivm->builder,
 						 lp_build_intrinsic(gallivm->builder,
 								 "llvm.SI.buffer.load.dword.i32.i32",
 								 ctx.i32, args, 9,
 								 LP_FUNC_ATTR_READONLY),
 						 ctx.f32, "");
 		}
 	}
 
-	if (gs_selector->so.num_outputs) {
-		for (int stream = 0; stream < 4; stream++) {
-			struct lp_build_if_state if_ctx_stream;
+	for (int stream = 0; stream < 4; stream++) {
+		struct lp_build_if_state if_ctx_stream;
 
-			if (!gsinfo->num_stream_output_components[stream])
-				continue;
+		if (!gsinfo->num_stream_output_components[stream])
+			continue;
+
+		if (stream > 0 && !gs_selector->so.num_outputs)
+			continue;
 
-			LLVMValueRef is_stream =
-				LLVMBuildICmp(builder, LLVMIntEQ,
-					      stream_id,
-					      lp_build_const_int32(gallivm, stream), "");
+		LLVMValueRef is_stream =
+			LLVMBuildICmp(builder, LLVMIntEQ,
+				      stream_id,
+				      lp_build_const_int32(gallivm, stream), "");
 
-			lp_build_if(&if_ctx_stream, gallivm, is_stream);
+		lp_build_if(&if_ctx_stream, gallivm, is_stream);
+
+		if (gs_selector->so.num_outputs) {
 			si_llvm_emit_streamout(&ctx, outputs,
 					       gsinfo->num_outputs,
 					       stream);
-			lp_build_endif(&if_ctx_stream);
 		}
+
+		if (stream == 0)
+			si_llvm_export_vs(bld_base, outputs, gsinfo->num_outputs);
+
+		lp_build_endif(&if_ctx_stream);
 	}
-	si_llvm_export_vs(bld_base, outputs, gsinfo->num_outputs);
 
 	LLVMBuildRetVoid(gallivm->builder);
 
 	/* Dump LLVM IR before any optimization passes */
 	if (sscreen->b.debug_flags & DBG_PREOPT_IR &&
 	    r600_can_dump_shader(&sscreen->b, PIPE_SHADER_GEOMETRY))
 		LLVMDumpModule(bld_base->base.gallivm->module);
 
 	si_llvm_finalize_module(&ctx,
 		r600_extra_shader_checks(&sscreen->b, PIPE_SHADER_GEOMETRY));
-- 
2.7.4



More information about the mesa-dev mailing list