[Mesa-dev] [PATCH 17/31] radeonsi: use VS prolog and epilog for monolithic shaders

Nicolai Hähnle nhaehnle at gmail.com
Mon Oct 31 22:11:04 UTC 2016


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

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

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 226c335..7272313 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -64,20 +64,24 @@ static void si_init_shader_ctx(struct si_shader_context *ctx,
 			       struct si_shader *shader,
 			       LLVMTargetMachineRef tm);
 
 static void si_llvm_emit_barrier(const struct lp_build_tgsi_action *action,
 				 struct lp_build_tgsi_context *bld_base,
 				 struct lp_build_emit_data *emit_data);
 
 static void si_dump_shader_key(unsigned shader, union si_shader_key *key,
 			       FILE *f);
 
+static void si_build_vs_prolog_function(struct si_shader_context *ctx,
+					union si_shader_part_key *key);
+static void si_build_vs_epilog_function(struct si_shader_context *ctx,
+					union si_shader_part_key *key);
 static void si_build_ps_prolog_function(struct si_shader_context *ctx,
 					union si_shader_part_key *key);
 static void si_build_ps_epilog_function(struct si_shader_context *ctx,
 					union si_shader_part_key *key);
 
 /* Ideally pass the sample mask input to the PS epilog as v13, which
  * is its usual location, so that the shader doesn't have to add v_mov.
  */
 #define PS_EPILOG_SAMPLEMASK_MIN_LOC 13
 
@@ -7167,39 +7171,66 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 	    !(sscreen->b.debug_flags & DBG_NO_TGSI)) {
 		tgsi_dump(sel->tokens, 0);
 		si_dump_streamout(&sel->so);
 	}
 
 	si_init_shader_ctx(&ctx, sscreen, shader, tm);
 	ctx.no_prolog = is_monolithic;
 	ctx.no_epilog = is_monolithic;
 	ctx.separate_prolog = !is_monolithic;
 
-	if (ctx.type == PIPE_SHADER_FRAGMENT) {
+	if (ctx.type == PIPE_SHADER_VERTEX ||
+	    ctx.type == PIPE_SHADER_FRAGMENT) {
 		ctx.no_prolog = false;
 		ctx.no_epilog = false;
 	}
 
 	memset(shader->info.vs_output_param_offset, 0xff,
 	       sizeof(shader->info.vs_output_param_offset));
 
 	shader->info.uses_instanceid = sel->info.uses_instanceid;
 
 	bld_base = &ctx.soa.bld_base;
 	ctx.load_system_value = declare_system_value;
 
 	if (!si_compile_tgsi_main(&ctx, shader)) {
 		si_llvm_dispose(&ctx);
 		return -1;
 	}
 
-	if (is_monolithic && ctx.type == PIPE_SHADER_FRAGMENT) {
+	if (is_monolithic && ctx.type == PIPE_SHADER_VERTEX) {
+		LLVMValueRef parts[3];
+		bool need_prolog;
+		bool need_epilog;
+
+		need_prolog = sel->info.num_inputs;
+		need_epilog = !shader->key.vs.as_es && !shader->key.vs.as_ls;
+
+		parts[need_prolog ? 1 : 0] = ctx.main_fn;
+
+		if (need_prolog) {
+			union si_shader_part_key prolog_key;
+			si_get_vs_prolog_key(shader, &prolog_key);
+			si_build_vs_prolog_function(&ctx, &prolog_key);
+			parts[0] = ctx.main_fn;
+		}
+
+		if (need_epilog) {
+			union si_shader_part_key epilog_key;
+			si_get_vs_epilog_key(shader, &shader->key.vs.epilog, &epilog_key);
+			si_build_vs_epilog_function(&ctx, &epilog_key);
+			parts[need_prolog ? 2 : 1] = ctx.main_fn;
+		}
+
+		si_build_wrapper_function(&ctx, parts, 1 + need_prolog + need_epilog,
+					  need_prolog ? 1 : 0);
+	} else if (is_monolithic && ctx.type == PIPE_SHADER_FRAGMENT) {
 		LLVMValueRef parts[3];
 		union si_shader_part_key prolog_key;
 		union si_shader_part_key epilog_key;
 		bool need_prolog;
 
 		si_get_ps_prolog_key(shader, &prolog_key, false);
 		need_prolog = si_need_ps_prolog(&prolog_key);
 
 		parts[need_prolog ? 1 : 0] = ctx.main_fn;
 
-- 
2.7.4



More information about the mesa-dev mailing list