summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno
diff options
context:
space:
mode:
authorVasily Khoruzhick <[email protected]>2019-08-29 21:14:54 -0700
committerVasily Khoruzhick <[email protected]>2019-09-06 01:51:28 +0000
commit9367d2ca37a3b8108ecb74e2875a600b5543c163 (patch)
tree01a8c4937a0ff41d3e7bfe4d27008649f46f522e /src/gallium/drivers/freedreno
parentf9f7cbc1aa36cce6caa42c0cf58c5cbefedc19fd (diff)
nir: allow specifying filter callback in lower_alu_to_scalar
Set of opcodes doesn't have enough flexibility in certain cases. E.g. Utgard PP has vector conditional select operation, but condition is always scalar. Lowering all the vector selects to scalar increases instruction number, so we need a way to filter only those ops that can't be handled in hardware. Reviewed-by: Qiang Yu <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Vasily Khoruzhick <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno')
-rw-r--r--src/gallium/drivers/freedreno/a2xx/ir2_nir.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
index 9d36f7092ef..6915194234d 100644
--- a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
+++ b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c
@@ -1062,6 +1062,29 @@ static void cleanup_binning(struct ir2_context *ctx)
ir2_optimize_nir(ctx->nir, false);
}
+static bool
+ir2_alu_to_scalar_filter_cb(const nir_instr *instr, const void *data)
+{
+ if (instr->type != nir_instr_type_alu)
+ return false;
+
+ nir_alu_instr *alu = nir_instr_as_alu(instr);
+ switch (alu->op) {
+ case nir_op_frsq:
+ case nir_op_frcp:
+ case nir_op_flog2:
+ case nir_op_fexp2:
+ case nir_op_fsqrt:
+ case nir_op_fcos:
+ case nir_op_fsin:
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
void
ir2_nir_compile(struct ir2_context *ctx, bool binning)
{
@@ -1085,17 +1108,7 @@ ir2_nir_compile(struct ir2_context *ctx, bool binning)
OPT_V(ctx->nir, nir_lower_bool_to_float);
OPT_V(ctx->nir, nir_lower_to_source_mods, nir_lower_all_source_mods);
- /* TODO: static bitset ? */
- BITSET_DECLARE(scalar_ops, nir_num_opcodes);
- BITSET_ZERO(scalar_ops);
- BITSET_SET(scalar_ops, nir_op_frsq);
- BITSET_SET(scalar_ops, nir_op_frcp);
- BITSET_SET(scalar_ops, nir_op_flog2);
- BITSET_SET(scalar_ops, nir_op_fexp2);
- BITSET_SET(scalar_ops, nir_op_fsqrt);
- BITSET_SET(scalar_ops, nir_op_fcos);
- BITSET_SET(scalar_ops, nir_op_fsin);
- OPT_V(ctx->nir, nir_lower_alu_to_scalar, scalar_ops);
+ OPT_V(ctx->nir, nir_lower_alu_to_scalar, ir2_alu_to_scalar_filter_cb, NULL);
OPT_V(ctx->nir, nir_lower_locals_to_regs);