[Mesa-dev] [PATCH 12/21] etnaviv: compiler: generate instructions for log2
Philipp Zabel
p.zabel at pengutronix.de
Tue Jun 5 14:38:36 UTC 2018
From: Michael Tretter <m.tretter at pengutronix.de>
flog2 is implemented as 2 instructions in the Vivante machine code. The
log calculates x and y, which have to be multiplied to get the actual
log result.
We need to allocate a temporary register for this, which will fail if to
many flog2 instructions are used (e.g. in the glmark2 ideas benchmark).
TODO: move this up into NIR as a lowering step.
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_compiler.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 129c9115e783..66553199fe19 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2101,6 +2101,24 @@ etna_emit_alu(struct etna_compile *c, nir_alu_instr *instr)
.src[2] = src[0],
});
break;
+ case nir_op_flog2:
+ {
+ struct etna_native_reg temp = etna_compile_get_inner_temp(c); /* only using .xy */
+ emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_LOG,
+ .sat = 0,
+ .dst = etna_native_to_dst(temp, INST_COMPS_X | INST_COMPS_Y),
+ .src[2] = src[0],
+ .tex = { .amode=1 }, /* Unknown bit needs to be set */
+ });
+ emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MUL,
+ .dst = dst,
+ .src[0] = etna_native_to_src(temp, SWIZZLE(X, X, X, X)),
+ .src[1] = etna_native_to_src(temp, SWIZZLE(Y, Y, Y, Y)),
+ });
+ }
+ break;
case nir_op_fexp2:
emit_inst(c, &(struct etna_inst) {
.opcode = INST_OPCODE_EXP,
--
2.17.1
More information about the mesa-dev
mailing list