[Mesa-dev] [PATCH 11/13] radeonsi: set correct num_input_sgprs for VS prolog in merged shaders

Marek Olšák maraeo at gmail.com
Sat Feb 17 19:43:26 UTC 2018


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

We need to take num_input_sgprs from VS, not the second shader.
No apps suffered from this.
---
 src/gallium/drivers/radeonsi/si_shader.c | 48 ++++++++++++++++----------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 6d0c81d..445d994 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -6733,47 +6733,47 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 			/* TCS main part */
 			parts[2] = ctx.main_fn;
 
 			/* TCS epilog */
 			union si_shader_part_key tcs_epilog_key;
 			memset(&tcs_epilog_key, 0, sizeof(tcs_epilog_key));
 			tcs_epilog_key.tcs_epilog.states = shader->key.part.tcs.epilog;
 			si_build_tcs_epilog_function(&ctx, &tcs_epilog_key);
 			parts[3] = ctx.main_fn;
 
-			/* VS prolog */
-			if (vs_needs_prolog) {
-				union si_shader_part_key vs_prolog_key;
-				si_get_vs_prolog_key(&ls->info,
-						     shader->info.num_input_sgprs,
-						     &shader->key.part.tcs.ls_prolog,
-						     shader, &vs_prolog_key);
-				vs_prolog_key.vs_prolog.is_monolithic = true;
-				si_build_vs_prolog_function(&ctx, &vs_prolog_key);
-				parts[0] = ctx.main_fn;
-			}
-
 			/* VS as LS main part */
 			struct si_shader shader_ls = {};
 			shader_ls.selector = ls;
 			shader_ls.key.as_ls = 1;
 			shader_ls.key.mono = shader->key.mono;
 			shader_ls.key.opt = shader->key.opt;
 			si_llvm_context_set_tgsi(&ctx, &shader_ls);
 
 			if (!si_compile_tgsi_main(&ctx, true)) {
 				si_llvm_dispose(&ctx);
 				return -1;
 			}
 			shader->info.uses_instanceid |= ls->info.uses_instanceid;
 			parts[1] = ctx.main_fn;
 
+			/* LS prolog */
+			if (vs_needs_prolog) {
+				union si_shader_part_key vs_prolog_key;
+				si_get_vs_prolog_key(&ls->info,
+						     shader_ls.info.num_input_sgprs,
+						     &shader->key.part.tcs.ls_prolog,
+						     shader, &vs_prolog_key);
+				vs_prolog_key.vs_prolog.is_monolithic = true;
+				si_build_vs_prolog_function(&ctx, &vs_prolog_key);
+				parts[0] = ctx.main_fn;
+			}
+
 			/* Reset the shader context. */
 			ctx.shader = shader;
 			ctx.type = PIPE_SHADER_TESS_CTRL;
 
 			si_build_wrapper_function(&ctx,
 						  parts + !vs_needs_prolog,
 						  4 - !vs_needs_prolog, 0,
 						  vs_needs_prolog ? 2 : 1);
 		} else {
 			LLVMValueRef parts[2];
@@ -6797,47 +6797,47 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 			LLVMValueRef gs_main = ctx.main_fn;
 
 			/* GS prolog */
 			union si_shader_part_key gs_prolog_key;
 			memset(&gs_prolog_key, 0, sizeof(gs_prolog_key));
 			gs_prolog_key.gs_prolog.states = shader->key.part.gs.prolog;
 			gs_prolog_key.gs_prolog.is_monolithic = true;
 			si_build_gs_prolog_function(&ctx, &gs_prolog_key);
 			gs_prolog = ctx.main_fn;
 
-			/* ES prolog */
-			if (es->vs_needs_prolog) {
-				union si_shader_part_key vs_prolog_key;
-				si_get_vs_prolog_key(&es->info,
-						     shader->info.num_input_sgprs,
-						     &shader->key.part.gs.vs_prolog,
-						     shader, &vs_prolog_key);
-				vs_prolog_key.vs_prolog.is_monolithic = true;
-				si_build_vs_prolog_function(&ctx, &vs_prolog_key);
-				es_prolog = ctx.main_fn;
-			}
-
 			/* ES main part */
 			struct si_shader shader_es = {};
 			shader_es.selector = es;
 			shader_es.key.as_es = 1;
 			shader_es.key.mono = shader->key.mono;
 			shader_es.key.opt = shader->key.opt;
 			si_llvm_context_set_tgsi(&ctx, &shader_es);
 
 			if (!si_compile_tgsi_main(&ctx, true)) {
 				si_llvm_dispose(&ctx);
 				return -1;
 			}
 			shader->info.uses_instanceid |= es->info.uses_instanceid;
 			es_main = ctx.main_fn;
 
+			/* ES prolog */
+			if (es->vs_needs_prolog) {
+				union si_shader_part_key vs_prolog_key;
+				si_get_vs_prolog_key(&es->info,
+						     shader_es.info.num_input_sgprs,
+						     &shader->key.part.gs.vs_prolog,
+						     shader, &vs_prolog_key);
+				vs_prolog_key.vs_prolog.is_monolithic = true;
+				si_build_vs_prolog_function(&ctx, &vs_prolog_key);
+				es_prolog = ctx.main_fn;
+			}
+
 			/* Reset the shader context. */
 			ctx.shader = shader;
 			ctx.type = PIPE_SHADER_GEOMETRY;
 
 			/* Prepare the array of shader parts. */
 			LLVMValueRef parts[4];
 			unsigned num_parts = 0, main_part, next_first_part;
 
 			if (es_prolog)
 				parts[num_parts++] = es_prolog;
-- 
2.7.4



More information about the mesa-dev mailing list