[Mesa-dev] [PATCH 13/21] etnaviv: nir: add a nop intrinsic to empty shaders
Philipp Zabel
p.zabel at pengutronix.de
Tue Jun 5 14:38:37 UTC 2018
The Vivante instruction set does not allow empty shaders.
If the shader is empty, add a nop to allow execution.
Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
---
src/gallium/drivers/etnaviv/etnaviv_nir.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 752e87248e31..1a71459c3a20 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -888,6 +888,21 @@ etna_remove_io_intrinsics(nir_shader *shader)
}
}
+static void
+etna_add_nop_if_empty(nir_shader *shader)
+{
+ /* TODO: add nop label if needed as jump target at the end of a function */
+ nir_foreach_function(function, shader) {
+ if (nir_index_instrs(function->impl) == 0) {
+ nir_intrinsic_instr *nop;
+
+ nop = nir_intrinsic_instr_create(shader, nir_intrinsic_nop);
+ nir_instr_insert_after_block(nir_start_block(function->impl),
+ &nop->instr);
+ }
+ }
+}
+
struct nir_shader *
etna_optimize_nir(struct etna_shader *shader,
struct nir_shader *s,
@@ -912,6 +927,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, etna_remove_io_intrinsics);
NIR_PASS_V(s, nir_opt_dce);
+ NIR_PASS_V(s, etna_add_nop_if_empty);
/* Do this after register assignment to avoid creating temporary registers
* that cause suboptimal register assignment.
--
2.17.1
More information about the mesa-dev
mailing list