From 2b5082b30d72dcf79409fa7850a5b0873dfa8815 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Tue, 31 Dec 2024 22:54:55 +1000 Subject: [PATCH] shader_recompiler: Use FPRecip in FSWZADD implementation Simplifies the negative reciprocal calculation in FSWZADD by using the dedicated FPRecip operation instead of manually constructing a division. This change: - Replaces FPDiv(Imm32(f32(1.0f)), src_b) with FPRecip(src_b) - Results in more efficient code for calculating 1.0/x - Fixes build errors from undefined IR emitter methods --- .../maxwell/translate/impl/floating_point_swizzled_add.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_swizzled_add.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_swizzled_add.cpp index cb8971551..c89d53ea3 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_swizzled_add.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_swizzled_add.cpp @@ -34,7 +34,7 @@ void TranslatorVisitor::FSWZADD(u64 insn) { IR::F32 result; if (fswzadd.ndv != 0) { - const IR::F32 neg_recip = ir.FPNeg(ir.FPDiv(ir.Imm32(ir.f32(1.0f)), src_b)); + const IR::F32 neg_recip = ir.FPNeg(ir.FPRecip(src_b)); result = ir.FSwizzleAdd(src_a, neg_recip, swizzle, fp_control); } else { result = ir.FSwizzleAdd(src_a, src_b, swizzle, fp_control);