diff options
author | Alyssa Rosenzweig <alyssa@rosenzweig.io> | 2021-04-14 15:28:13 -0400 |
---|---|---|
committer | Alyssa Rosenzweig <none> | 2021-05-02 17:41:14 -0400 |
commit | b5a3845f9a47db2faa5af0cf1c38153629b9efb2 (patch) | |
tree | 91b37f6f156b47fd800c3c0233cc667fc90b7ba8 | |
parent | 8648b2be0b306ed624353695ed61ccedc12407ec (diff) |
agx: Implement simple floating point ops
These are all direct translations of NIR->AIR.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10582>
-rw-r--r-- | src/asahi/compiler/agx_compile.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 32d5e1a184a..148fe891ab3 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -214,7 +214,49 @@ agx_emit_alu(agx_builder *b, nir_alu_instr *instr) agx_index s2 = srcs > 2 ? agx_alu_src_index(b, instr->src[2]) : agx_null(); agx_index s3 = srcs > 3 ? agx_alu_src_index(b, instr->src[3]) : agx_null(); +#define UNOP(nop, aop) \ + case nir_op_ ## nop: return agx_ ## aop ## _to(b, dst, s0); +#define BINOP(nop, aop) \ + case nir_op_ ## nop: return agx_ ## aop ## _to(b, dst, s0, s1); +#define TRIOP(nop, aop) \ + case nir_op_ ## nop: return agx_ ## aop ## _to(b, dst, s0, s1, s2); + switch (instr->op) { + BINOP(fadd, fadd); + BINOP(fmul, fmul); + TRIOP(ffma, fma); + + UNOP(f2f16, fmov); + UNOP(f2f32, fmov); + UNOP(fround_even, roundeven); + UNOP(ftrunc, trunc); + UNOP(ffloor, floor); + UNOP(fceil, ceil); + UNOP(frcp, rcp); + UNOP(frsq, rsqrt); + UNOP(flog2, log2); + UNOP(fexp2, exp2); + + UNOP(fddx, dfdx); + UNOP(fddx_coarse, dfdx); + UNOP(fddx_fine, dfdx); + + UNOP(fddy, dfdy); + UNOP(fddy_coarse, dfdy); + UNOP(fddy_fine, dfdy); + + case nir_op_fsqrt: return agx_fmul_to(b, dst, s0, agx_srsqrt(b, s0)); + case nir_op_fsub: return agx_fadd_to(b, dst, s0, agx_neg(s1)); + case nir_op_fabs: return agx_fmov_to(b, dst, agx_abs(s0)); + case nir_op_fneg: return agx_fmov_to(b, dst, agx_neg(s0)); + + case nir_op_fsat: + { + agx_instr *I = agx_fadd_to(b, dst, s0, agx_negzero()); + I->saturate = true; + return I; + } + case nir_op_vec2: case nir_op_vec3: case nir_op_vec4: |