[Mesa-dev] [PATCH 2/5] radeonsi: skip generic out/in indices without a shader IO index

Nicolai Hähnle nhaehnle at gmail.com
Wed May 10 17:30:27 UTC 2017


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

OpenGL uses at most 32 generic outputs/inputs in any stage, and they always
have a shader IO index and therefore fit into the outputs_written/
inputs_read/kill_outputs fields.

However, Nine uses semantic indices more liberally. We support that
in VS-PS pipelines, except that the optimization of killing outputs
must be skipped.
---
 src/gallium/drivers/radeonsi/si_shader.c        | 4 ++++
 src/gallium/drivers/radeonsi/si_state_shaders.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index bdc9cc1..9829286 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2286,20 +2286,24 @@ static void si_llvm_export_vs(struct lp_build_tgsi_context *bld_base,
 		semantic_index = outputs[i].semantic_index;
 		bool export_param = true;
 
 		switch (semantic_name) {
 		case TGSI_SEMANTIC_POSITION: /* ignore these */
 		case TGSI_SEMANTIC_PSIZE:
 		case TGSI_SEMANTIC_CLIPVERTEX:
 		case TGSI_SEMANTIC_EDGEFLAG:
 			break;
 		case TGSI_SEMANTIC_GENERIC:
+			/* don't process indices the function can't handle */
+			if (semantic_index >= SI_MAX_IO_GENERIC)
+				break;
+			/* fall through */
 		case TGSI_SEMANTIC_CLIPDIST:
 			if (shader->key.opt.hw_vs.kill_outputs &
 			    (1ull << si_shader_io_get_unique_index(semantic_name, semantic_index)))
 				export_param = false;
 			break;
 		default:
 			if (shader->key.opt.hw_vs.kill_outputs2 &
 			    (1u << si_shader_io_get_unique_index2(semantic_name, semantic_index)))
 				export_param = false;
 			break;
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 8193fe0..6020bec 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -2025,22 +2025,26 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
 		if (sctx->b.chip_class >= GFX9)
 			sel->esgs_itemsize += 4;
 		break;
 
 	case PIPE_SHADER_FRAGMENT:
 		for (i = 0; i < sel->info.num_inputs; i++) {
 			unsigned name = sel->info.input_semantic_name[i];
 			unsigned index = sel->info.input_semantic_index[i];
 
 			switch (name) {
-			case TGSI_SEMANTIC_CLIPDIST:
 			case TGSI_SEMANTIC_GENERIC:
+				/* don't process indices the function can't handle */
+				if (index >= SI_MAX_IO_GENERIC)
+					break;
+				/* fall through */
+			case TGSI_SEMANTIC_CLIPDIST:
 				sel->inputs_read |=
 					1llu << si_shader_io_get_unique_index(name, index);
 				break;
 			case TGSI_SEMANTIC_PCOORD: /* ignore this */
 				break;
 			default:
 				sel->inputs_read2 |=
 					1u << si_shader_io_get_unique_index2(name, index);
 			}
 		}
-- 
2.9.3



More information about the mesa-dev mailing list