summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-06-24 17:30:16 +0200
committerNicolai Hähnle <[email protected]>2017-07-31 14:55:40 +0200
commitb49c2c9fa39f5a24d0c28863438d7e428aa564df (patch)
treef67da27eaf4ded727373cd3ce5806acbbc1486b1
parent9061dca8724846f88fffd2da67099c5c626f2c9f (diff)
radeonsi/nir: perform lowering of input/output driver locations
Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.h1
-rw-r--r--src/gallium/drivers/radeonsi/si_shader_nir.c26
-rw-r--r--src/gallium/drivers/radeonsi/si_state_shaders.c2
3 files changed, 29 insertions, 0 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index 339e156b168..e44d71c2614 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -635,6 +635,7 @@ const char *si_get_shader_name(const struct si_shader *shader, unsigned processo
/* si_shader_nir.c */
void si_nir_scan_shader(const struct nir_shader *nir,
struct tgsi_shader_info *info);
+void si_lower_nir(struct si_shader_selector *sel);
/* Inline helpers. */
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 076fce818a4..2c311d3865d 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -313,6 +313,32 @@ void si_nir_scan_shader(const struct nir_shader *nir,
}
}
+/**
+ * Perform "lowering" operations on the NIR that are run once when the shader
+ * selector is created.
+ */
+void
+si_lower_nir(struct si_shader_selector* sel)
+{
+ /* Adjust the driver location of inputs and outputs. The state tracker
+ * interprets them as slots, while the ac/nir backend interprets them
+ * as individual components.
+ */
+ nir_foreach_variable(variable, &sel->nir->inputs)
+ variable->data.driver_location *= 4;
+
+ nir_foreach_variable(variable, &sel->nir->outputs) {
+ variable->data.driver_location *= 4;
+
+ if (sel->nir->stage == MESA_SHADER_FRAGMENT) {
+ if (variable->data.location == FRAG_RESULT_DEPTH)
+ variable->data.driver_location += 2;
+ else if (variable->data.location == FRAG_RESULT_STENCIL)
+ variable->data.driver_location += 1;
+ }
+ }
+}
+
static void declare_nir_input_vs(struct si_shader_context *ctx,
struct nir_variable *variable, unsigned rel,
LLVMValueRef out[4])
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 5a0ead1313a..8a795c0faef 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1989,6 +1989,8 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
sel->nir = state->ir.nir;
si_nir_scan_shader(sel->nir, &sel->info);
+
+ si_lower_nir(sel);
}
sel->type = sel->info.processor;