From 47f01e538ad575d3f2b02e747905e7ab9dd3a9bb Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 5 May 2016 17:14:39 -0700 Subject: ptn: Emit mul+add for MAD Unlike fma() in GLSL, MAD in ARB programs is 100% splittable. Just emit the split version and let the optimizer fuse them later. Shader-db results on Haswell: total instructions in shared programs: 7560379 -> 7560300 (-0.00%) instructions in affected programs: 143928 -> 143849 (-0.05%) helped: 443 HURT: 250 Reviewed-by: Kenneth Graunke --- src/mesa/program/prog_to_nir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c index b93355342af..9e01151a1c4 100644 --- a/src/mesa/program/prog_to_nir.c +++ b/src/mesa/program/prog_to_nir.c @@ -666,7 +666,7 @@ static const nir_op op_trans[MAX_OPCODE] = { [OPCODE_LIT] = 0, [OPCODE_LOG] = 0, [OPCODE_LRP] = 0, - [OPCODE_MAD] = nir_op_ffma, + [OPCODE_MAD] = 0, [OPCODE_MAX] = nir_op_fmax, [OPCODE_MIN] = nir_op_fmin, [OPCODE_MOV] = nir_op_fmov, @@ -757,6 +757,10 @@ ptn_emit_instruction(struct ptn_compile *c, struct prog_instruction *prog_inst) ptn_lrp(b, dest, src); break; + case OPCODE_MAD: + ptn_move_dest(b, dest, nir_fadd(b, nir_fmul(b, src[0], src[1]), src[2])); + break; + case OPCODE_DST: ptn_dst(b, dest, src); break; -- cgit v1.2.3