[Mesa-dev] [PATCH 23/61] radeonsi/gfx9: merged shaders have scratch offset at the beginning

Marek Olšák maraeo at gmail.com
Mon Apr 24 08:45:20 UTC 2017


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

also, screen wasn't initialized for compute shaders
---
 src/gallium/drivers/radeonsi/si_compute.c |  1 +
 src/gallium/drivers/radeonsi/si_shader.c  | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c
index 33ebe2e..2b2efae 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -106,20 +106,21 @@ static void si_create_compute_state_async(void *job, int thread_index)
 		assert(thread_index < ARRAY_SIZE(program->screen->tm));
 		tm = program->screen->tm[thread_index];
 		if (!debug->async)
 			debug = NULL;
 	} else {
 		tm = program->compiler_ctx_state.tm;
 	}
 
 	memset(&sel, 0, sizeof(sel));
 
+	sel.screen = program->screen;
 	tgsi_scan_shader(program->tokens, &sel.info);
 	sel.tokens = program->tokens;
 	sel.type = PIPE_SHADER_COMPUTE;
 	sel.local_size = program->local_size;
 
 	program->shader.selector = &sel;
 	program->shader.is_monolithic = true;
 
 	if (si_shader_create(program->screen, tm, &program->shader, debug)) {
 		program->shader.compilation_failed = true;
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 8b21ff7..dab95e2 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -92,20 +92,31 @@ static void si_build_ps_epilog_function(struct si_shader_context *ctx,
 /* The VS location of the PrimitiveID input is the same in the epilog,
  * so that the main shader part doesn't have to move it.
  */
 #define VS_EPILOG_PRIMID_LOC 2
 
 enum {
 	CONST_ADDR_SPACE = 2,
 	LOCAL_ADDR_SPACE = 3,
 };
 
+static bool is_merged_shader(struct si_shader *shader)
+{
+	if (shader->selector->screen->b.chip_class <= VI)
+		return false;
+
+	return shader->key.as_ls ||
+	       shader->key.as_es ||
+	       shader->selector->type == PIPE_SHADER_TESS_CTRL ||
+	       shader->selector->type == PIPE_SHADER_GEOMETRY;
+}
+
 /**
  * Returns a unique index for a semantic name and index. The index must be
  * less than 64, so that a 64-bit bitmask of used inputs or outputs can be
  * calculated.
  */
 unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index)
 {
 	switch (semantic_name) {
 	case TGSI_SEMANTIC_POSITION:
 		return 0;
@@ -7818,21 +7829,21 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 			/* Just terminate the process, because dependent
 			 * shaders can hang due to bad input data, but use
 			 * the env var to allow shader-db to work.
 			 */
 			if (!debug_get_bool_option("SI_PASS_BAD_SHADERS", false))
 				abort();
 		}
 	}
 
 	/* Add the scratch offset to input SGPRs. */
-	if (shader->config.scratch_bytes_per_wave)
+	if (shader->config.scratch_bytes_per_wave && !is_merged_shader(shader))
 		shader->info.num_input_sgprs += 1; /* scratch byte offset */
 
 	/* Calculate the number of fragment input VGPRs. */
 	if (ctx.type == PIPE_SHADER_FRAGMENT) {
 		shader->info.num_input_vgprs = 0;
 		shader->info.face_vgpr_index = -1;
 
 		if (G_0286CC_PERSP_SAMPLE_ENA(shader->config.spi_ps_input_addr))
 			shader->info.num_input_vgprs += 2;
 		if (G_0286CC_PERSP_CENTER_ENA(shader->config.spi_ps_input_addr))
-- 
2.7.4



More information about the mesa-dev mailing list