[Mesa-dev] [PATCH 19/21] etnaviv: nir: add extra mov for uniforms used as output
Philipp Zabel
p.zabel at pengutronix.de
Tue Jun 5 14:38:43 UTC 2018
From: Michael Tretter <m.tretter at pengutronix.de>
If a uniform is source to an output store operation, we have to emit an
actual mov instruction that copies from the uniform register into the
temporary register that is used as a shader output.
Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
---
src/gallium/drivers/etnaviv/etnaviv_nir.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index d8bd282eaeca..988b4bd62b6e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -920,6 +920,28 @@ etna_assign_registers(nir_shader *shader)
ralloc_free(regs);
}
+/* Uniforms cannot directly be used as output. Add a move to register for
+ * uniforms that are used as output. */
+static void
+etna_add_mov_for_uniform_output(nir_shader *shader)
+{
+ nir_foreach_function(function, shader) {
+ nir_foreach_block(block, function->impl) {
+ nir_foreach_instr_safe(instr, block) {
+ if (instr->type != nir_instr_type_intrinsic)
+ continue;
+
+ nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
+ if (intr->intrinsic != nir_intrinsic_store_output ||
+ !nir_src_is_dynamically_uniform(intr->src[0]))
+ continue;
+ insert_mov(&intr->instr, &intr->src[0], shader);
+ }
+ }
+ nir_metadata_preserve(function->impl, nir_metadata_block_index);
+ }
+}
+
/* Remove input_load and output_store intrinsics after global register
* allocation. After the SSA destinations are replaced, these contain no useful
* information anymore.
@@ -1002,6 +1024,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, nir_convert_from_ssa, true);
NIR_PASS_V(s, etna_fixup_tex);
+ NIR_PASS_V(s, etna_add_mov_for_uniform_output);
NIR_PASS_V(s, etna_assign_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
--
2.17.1
More information about the mesa-dev
mailing list