[Mesa-dev] [PATCH 1/5] radeonsi: use SI_MAX_IO_GENERIC instead of magic values

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


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

---
 src/gallium/drivers/radeonsi/si_shader.c        | 2 +-
 src/gallium/drivers/radeonsi/si_shader.h        | 5 +++++
 src/gallium/drivers/radeonsi/si_state_shaders.c | 4 ++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index b969376..bdc9cc1 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -135,21 +135,21 @@ unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index)
 {
 	switch (semantic_name) {
 	case TGSI_SEMANTIC_POSITION:
 		return 0;
 	case TGSI_SEMANTIC_PSIZE:
 		return 1;
 	case TGSI_SEMANTIC_CLIPDIST:
 		assert(index <= 1);
 		return 2 + index;
 	case TGSI_SEMANTIC_GENERIC:
-		if (index <= 63-4)
+		if (index < SI_MAX_IO_GENERIC)
 			return 4 + index;
 
 		assert(!"invalid generic index");
 		return 0;
 
 	default:
 		assert(!"invalid semantic name");
 		return 0;
 	}
 }
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index b49dca4..cf97a71 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -138,20 +138,25 @@
 #include <llvm-c/Core.h> /* LLVMModuleRef */
 #include <llvm-c/TargetMachine.h>
 #include "tgsi/tgsi_scan.h"
 #include "util/u_queue.h"
 #include "si_state.h"
 
 struct ac_shader_binary;
 
 #define SI_MAX_VS_OUTPUTS	40
 
+/* Shader IO unique indices are supported for TGSI_SEMANTIC_GENERIC with an
+ * index smaller than this.
+ */
+#define SI_MAX_IO_GENERIC       60
+
 /* SGPR user data indices */
 enum {
 	/* GFX9 merged shaders have RW_BUFFERS among the first 8 system SGPRs,
 	 * and these two are used for other purposes.
 	 */
 	SI_SGPR_RW_BUFFERS,  /* rings (& stream-out, VS only) */
 	SI_SGPR_RW_BUFFERS_HI,
 	SI_SGPR_CONST_BUFFERS,
 	SI_SGPR_CONST_BUFFERS_HI,
 	SI_SGPR_SAMPLERS,  /* images & sampler states interleaved */
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 11e3dab..8193fe0 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1836,21 +1836,21 @@ void si_init_shader_selector_async(void *job, int thread_index)
 				if (offset <= AC_EXP_PARAM_OFFSET_31)
 					continue;
 
 				unsigned name = sel->info.output_semantic_name[i];
 				unsigned index = sel->info.output_semantic_index[i];
 				unsigned id;
 
 				switch (name) {
 				case TGSI_SEMANTIC_GENERIC:
 					/* don't process indices the function can't handle */
-					if (index >= 60)
+					if (index >= SI_MAX_IO_GENERIC)
 						break;
 					/* fall through */
 				case TGSI_SEMANTIC_CLIPDIST:
 					id = si_shader_io_get_unique_index(name, index);
 					sel->outputs_written &= ~(1ull << id);
 					break;
 				case TGSI_SEMANTIC_POSITION: /* ignore these */
 				case TGSI_SEMANTIC_PSIZE:
 				case TGSI_SEMANTIC_CLIPVERTEX:
 				case TGSI_SEMANTIC_EDGEFLAG:
@@ -1993,21 +1993,21 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
 			switch (name) {
 			case TGSI_SEMANTIC_TESSINNER:
 			case TGSI_SEMANTIC_TESSOUTER:
 			case TGSI_SEMANTIC_PATCH:
 				sel->patch_outputs_written |=
 					1llu << si_shader_io_get_unique_index_patch(name, index);
 				break;
 
 			case TGSI_SEMANTIC_GENERIC:
 				/* don't process indices the function can't handle */
-				if (index >= 60)
+				if (index >= SI_MAX_IO_GENERIC)
 					break;
 				/* fall through */
 			case TGSI_SEMANTIC_POSITION:
 			case TGSI_SEMANTIC_PSIZE:
 			case TGSI_SEMANTIC_CLIPDIST:
 				sel->outputs_written |=
 					1llu << si_shader_io_get_unique_index(name, index);
 				break;
 			case TGSI_SEMANTIC_CLIPVERTEX: /* ignore these */
 			case TGSI_SEMANTIC_EDGEFLAG:
-- 
2.9.3



More information about the mesa-dev mailing list