From 5fdcd571cd37a3996b6479e43a10eaecaa9b3295 Mon Sep 17 00:00:00 2001 From: Pacuka <69674426+Pacuka@users.noreply.github.com> Date: Sun, 27 Sep 2026 18:59:46 +0200 Subject: [PATCH] fix(recompiler): widen constants of 64-bit operands instead of repeating them readU32Pair read a literal or inline constant into both halves of a 64-bit source. A literal is now zero-extended, an integer inline constant sign-extended and a float inline constant becomes the matching double. Co-Authored-By: Claude Opus 5.5 --- .../src/TranslationContext/SubwordPacking.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/shader/recompiler/Translation/src/TranslationContext/SubwordPacking.cpp b/core/shader/recompiler/Translation/src/TranslationContext/SubwordPacking.cpp index e1ba9818f..d8b32b7e0 100644 --- a/core/shader/recompiler/Translation/src/TranslationContext/SubwordPacking.cpp +++ b/core/shader/recompiler/Translation/src/TranslationContext/SubwordPacking.cpp @@ -1,5 +1,7 @@ #include "Translation/TranslationContext.hpp" #include +#include +#include namespace ShaderRecompiler { @@ -8,7 +10,15 @@ IrU32 TranslationContext::readU32(const RdnaOperand& operand) { } std::array TranslationContext::readU32Pair(const RdnaOperand& operand) { - return {readU32(operand), readU32(offsetOperand(operand, 1u))}; + switch (operand.kind) { + case RdnaOperandKind::LiteralConstant: return {readU32(operand), IrU32(ir.Constant(0u))}; + case RdnaOperandKind::IntegerInlineConstant: return {readU32(operand), IrU32(ir.Constant(operand.signedVal < 0 ? 0xffffffffu : 0u))}; + case RdnaOperandKind::FloatInlineConstant: { + const auto bits = std::bit_cast(static_cast(std::bit_cast(operand.value))); + return {IrU32(ir.Constant(static_cast(bits))), IrU32(ir.Constant(static_cast(bits >> 32u)))}; + } + default: return {readU32(operand), readU32(offsetOperand(operand, 1u))}; + } } IrU64 TranslationContext::readU64(const RdnaOperand& operand) {