From 33bb1e04106279df1bedda2628173fcb9a06488b Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Thu, 28 Jul 2022 23:35:07 +0200 Subject: [PATCH] frontend/nine: Enforce legacy pow behaviour Gallium drivers used to implement the legacy behaviour. It's not the case of all recent drivers, so implement the legacy behaviour in nine. Acked-by: Mike Blumenkrantz Signed-off-by: Axel Davy Part-of: --- src/gallium/frontends/nine/nine_shader.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/nine/nine_shader.c b/src/gallium/frontends/nine/nine_shader.c index e9996a8..ba68488 100644 --- a/src/gallium/frontends/nine/nine_shader.c +++ b/src/gallium/frontends/nine/nine_shader.c @@ -2401,7 +2401,18 @@ DECL_SPECIAL(POW) tx_src_param(tx, &tx->insn.src[0]), tx_src_param(tx, &tx->insn.src[1]) }; - ureg_POW(tx->ureg, dst, ureg_abs(src[0]), src[1]); + /* Anything^0 is 1, including 0^0. + * Assume mul_zero_wins drivers already have + * this behaviour. Emulate for the others. */ + if (tx->mul_zero_wins) { + ureg_POW(tx->ureg, dst, ureg_abs(src[0]), src[1]); + } else { + struct ureg_dst tmp = tx_scratch_scalar(tx); + ureg_POW(tx->ureg, tmp, ureg_abs(src[0]), src[1]); + ureg_CMP(tx->ureg, dst, + ureg_negate(ureg_abs(ureg_scalar(src[1], TGSI_SWIZZLE_X))), + tx_src_scalar(tmp), ureg_imm1f(tx->ureg, 1.0f)); + } return D3D_OK; } -- 2.7.4