[Mesa-dev] [PATCH v2 64/73] radeonsi: tweak next-shader assumptions when streamout is used

Nicolai Hähnle nhaehnle at gmail.com
Wed Jul 5 10:48:48 UTC 2017


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

VS with streamout is always a HW VS.
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 00818a5..25a2748 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1733,40 +1733,42 @@ static int si_shader_select(struct pipe_context *ctx,
 {
 	struct si_context *sctx = (struct si_context *)ctx;
 	struct si_shader_key key;
 
 	si_shader_selector_key(ctx, state->cso, &key);
 	return si_shader_select_with_key(sctx->screen, state, compiler_state,
 					 &key, -1);
 }
 
 static void si_parse_next_shader_property(const struct tgsi_shader_info *info,
+					  bool streamout,
 					  struct si_shader_key *key)
 {
 	unsigned next_shader = info->properties[TGSI_PROPERTY_NEXT_SHADER];
 
 	switch (info->processor) {
 	case PIPE_SHADER_VERTEX:
 		switch (next_shader) {
 		case PIPE_SHADER_GEOMETRY:
 			key->as_es = 1;
 			break;
 		case PIPE_SHADER_TESS_CTRL:
 		case PIPE_SHADER_TESS_EVAL:
 			key->as_ls = 1;
 			break;
 		default:
-			/* If POSITION isn't written, it can't be a HW VS.
-			 * Assume that it's a HW LS. (the next shader is TCS)
+			/* If POSITION isn't written, it can only be a HW VS
+			 * if streamout is used. If streamout isn't used,
+			 * assume that it's a HW LS. (the next shader is TCS)
 			 * This heuristic is needed for separate shader objects.
 			 */
-			if (!info->writes_position)
+			if (!info->writes_position && !streamout)
 				key->as_ls = 1;
 		}
 		break;
 
 	case PIPE_SHADER_TESS_EVAL:
 		if (next_shader == PIPE_SHADER_GEOMETRY ||
 		    !info->writes_position)
 			key->as_es = 1;
 		break;
 	}
@@ -1801,21 +1803,23 @@ void si_init_shader_selector_async(void *job, int thread_index)
 	if (!sscreen->use_monolithic_shaders) {
 		struct si_shader *shader = CALLOC_STRUCT(si_shader);
 		void *tgsi_binary = NULL;
 
 		if (!shader) {
 			fprintf(stderr, "radeonsi: can't allocate a main shader part\n");
 			return;
 		}
 
 		shader->selector = sel;
-		si_parse_next_shader_property(&sel->info, &shader->key);
+		si_parse_next_shader_property(&sel->info,
+					      sel->so.num_outputs != 0,
+					      &shader->key);
 
 		if (sel->tokens)
 			tgsi_binary = si_get_tgsi_binary(sel);
 
 		/* Try to load the shader from the shader cache. */
 		mtx_lock(&sscreen->shader_cache_mutex);
 
 		if (tgsi_binary &&
 		    si_shader_cache_load_shader(sscreen, tgsi_binary, shader)) {
 			mtx_unlock(&sscreen->shader_cache_mutex);
@@ -1883,21 +1887,23 @@ void si_init_shader_selector_async(void *job, int thread_index)
 			}
 		}
 	}
 
 	/* Pre-compilation. */
 	if (sscreen->b.debug_flags & DBG_PRECOMPILE) {
 		struct si_shader_ctx_state state = {sel};
 		struct si_shader_key key;
 
 		memset(&key, 0, sizeof(key));
-		si_parse_next_shader_property(&sel->info, &key);
+		si_parse_next_shader_property(&sel->info,
+					      sel->so.num_outputs != 0,
+					      &key);
 
 		/* Set reasonable defaults, so that the shader key doesn't
 		 * cause any code to be eliminated.
 		 */
 		switch (sel->type) {
 		case PIPE_SHADER_TESS_CTRL:
 			key.part.tcs.epilog.prim_mode = PIPE_PRIM_TRIANGLES;
 			break;
 		case PIPE_SHADER_FRAGMENT:
 			key.part.ps.prolog.bc_optimize_for_persp =
-- 
2.9.3



More information about the mesa-dev mailing list