[Mesa-dev] [PATCH 5/7] radeonsi: add si_shader_selector::vs_needs_prolog

Marek Olšák maraeo at gmail.com
Fri Apr 14 15:08:20 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

cleanup
---
 src/gallium/drivers/radeonsi/si_shader.c        | 12 +++++-------
 src/gallium/drivers/radeonsi/si_shader.h        |  1 +
 src/gallium/drivers/radeonsi/si_state_shaders.c |  4 ++++
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 0bda187..6242ec1 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -7512,21 +7512,21 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 	if (!si_compile_tgsi_main(&ctx, shader)) {
 		si_llvm_dispose(&ctx);
 		return -1;
 	}
 
 	if (is_monolithic && ctx.type == PIPE_SHADER_VERTEX) {
 		LLVMValueRef parts[3];
 		bool need_prolog;
 		bool need_epilog;
 
-		need_prolog = sel->info.num_inputs;
+		need_prolog = sel->vs_needs_prolog;
 		need_epilog = !shader->key.as_es && !shader->key.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;
 		}
@@ -7965,28 +7965,26 @@ static bool si_get_vs_epilog(struct si_screen *sscreen,
 }
 
 /**
  * Select and compile (or reuse) vertex shader parts (prolog & epilog).
  */
 static bool si_shader_select_vs_parts(struct si_screen *sscreen,
 				      LLVMTargetMachineRef tm,
 				      struct si_shader *shader,
 				      struct pipe_debug_callback *debug)
 {
-	struct tgsi_shader_info *info = &shader->selector->info;
-	union si_shader_part_key prolog_key;
+	if (shader->selector->vs_needs_prolog) {
+		union si_shader_part_key prolog_key;
 
-	/* Get the prolog. */
-	si_get_vs_prolog_key(shader, &prolog_key);
+		/* Get the prolog. */
+		si_get_vs_prolog_key(shader, &prolog_key);
 
-	/* The prolog is a no-op if there are no inputs. */
-	if (info->num_inputs) {
 		shader->prolog =
 			si_get_shader_part(sscreen, &sscreen->vs_prologs,
 					   PIPE_SHADER_VERTEX, true,
 					   &prolog_key, tm, debug,
 					   si_build_vs_prolog_function,
 					   "Vertex Shader Prolog");
 		if (!shader->prolog)
 			return false;
 	}
 
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index f145eab..cfa691b 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -291,20 +291,21 @@ struct si_shader_selector {
 	struct si_shader	*main_shader_part_es; /* as_es is set in the key */
 
 	struct si_shader	*gs_copy_shader;
 
 	struct tgsi_token       *tokens;
 	struct pipe_stream_output_info  so;
 	struct tgsi_shader_info		info;
 
 	/* PIPE_SHADER_[VERTEX|FRAGMENT|...] */
 	unsigned	type;
+	bool		vs_needs_prolog;
 
 	/* GS parameters. */
 	unsigned	esgs_itemsize;
 	unsigned	gs_input_verts_per_prim;
 	unsigned	gs_output_prim;
 	unsigned	gs_max_out_vertices;
 	unsigned	gs_num_invocations;
 	unsigned	max_gs_stream; /* count - 1 */
 	unsigned	gsvs_vertex_size;
 	unsigned	max_gsvs_emit_size;
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index b856fc9..075c9c5 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1602,20 +1602,24 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
 	if (!sel->tokens) {
 		FREE(sel);
 		return NULL;
 	}
 
 	sel->so = state->stream_output;
 	tgsi_scan_shader(state->tokens, &sel->info);
 	sel->type = sel->info.processor;
 	p_atomic_inc(&sscreen->b.num_shaders_created);
 
+	/* The prolog is a no-op if there are no inputs. */
+	sel->vs_needs_prolog = sel->type == PIPE_SHADER_VERTEX &&
+			       sel->info.num_inputs;
+
 	/* Set which opcode uses which (i,j) pair. */
 	if (sel->info.uses_persp_opcode_interp_centroid)
 		sel->info.uses_persp_centroid = true;
 
 	if (sel->info.uses_linear_opcode_interp_centroid)
 		sel->info.uses_linear_centroid = true;
 
 	if (sel->info.uses_persp_opcode_interp_offset ||
 	    sel->info.uses_persp_opcode_interp_sample)
 		sel->info.uses_persp_center = true;
-- 
2.7.4



More information about the mesa-dev mailing list