feat(shader): translate signed and unsigned 24-bit high products

This commit is contained in:
SamG-Coder
2026-09-29 22:34:21 +10:00
parent c7fb2575a3
commit 70cb9e2eaf
6 changed files with 14 additions and 3 deletions
@@ -591,6 +591,8 @@ enum class RdnaOpcode : std::uint16_t {
SClause,
SCbranchCdbg,
Exp,
VMulHiI32I24,
VMulHiU32U24,
Count
};
@@ -232,6 +232,8 @@ bool IsVectorAluOpcode(RdnaOpcode opcode) {
case RdnaOpcode::VFmaakF16:
case RdnaOpcode::VMulI32I24:
case RdnaOpcode::VMulU32U24:
case RdnaOpcode::VMulHiI32I24:
case RdnaOpcode::VMulHiU32U24:
case RdnaOpcode::VMulLoI32:
case RdnaOpcode::VMulHiI32:
case RdnaOpcode::VCvtPkrtzF16F32:
@@ -53,7 +53,9 @@ constexpr Vop2OpcodeInfo vop2Opcodes[] = {
{0x05u, RdnaOpcode::VSubrevF32},
{0x08u, RdnaOpcode::VMulF32, Vop2SdwaProfile::Float32},
{0x09u, RdnaOpcode::VMulI32I24, Vop2SdwaProfile::IntegerFullDestination},
{0x0au, RdnaOpcode::VMulHiI32I24, Vop2SdwaProfile::IntegerFullDestination},
{0x0bu, RdnaOpcode::VMulU32U24, Vop2SdwaProfile::IntegerFullDestination},
{0x0cu, RdnaOpcode::VMulHiU32U24, Vop2SdwaProfile::IntegerFullDestination},
{0x0fu, RdnaOpcode::VMinF32},
{0x10u, RdnaOpcode::VMaxF32},
{0x11u, RdnaOpcode::VMinI32},
@@ -167,7 +167,7 @@ private:
bool sFf1I32B64(const RdnaInstruction& inst);
bool vFfbh32(const RdnaInstruction& inst, bool sign);
bool sFlbitI32B64(const RdnaInstruction& inst);
bool integer24(const RdnaInstruction& inst, bool sign, bool addend);
bool integer24(const RdnaInstruction& inst, bool sign, bool addend, bool high = false);
bool vMadU64U32(const RdnaInstruction& inst);
bool vSadU32(const RdnaInstruction& inst);
bool vAdd3U32(const RdnaInstruction& inst);
@@ -252,13 +252,14 @@ bool TranslationContext::sFlbitI32B64(const RdnaInstruction& inst) {
return true;
}
bool TranslationContext::integer24(const RdnaInstruction& inst, bool sign, bool addend) {
bool TranslationContext::integer24(const RdnaInstruction& inst, bool sign, bool addend, bool high) {
const IrOpcode extractOpcode = sign ? IrOpcode::BitFieldSExtract : IrOpcode::BitFieldUExtract;
const IrU32 lhsSource = readU32(sourceAt(inst, 0u));
const IrU32 rhsSource = readU32(sourceAt(inst, 1u));
const IrU32 lhs(ir.Emit(extractOpcode, IrType::U32, {&lhsSource.Value(), &ir.Constant(0u), &ir.Constant(24u)}));
const IrU32 rhs(ir.Emit(extractOpcode, IrType::U32, {&rhsSource.Value(), &ir.Constant(0u), &ir.Constant(24u)}));
IrU32 result(ir.IMul(lhs.Value(), rhs.Value()));
const IrOpcode multiplyOpcode = high ? (sign ? IrOpcode::SMulHi : IrOpcode::UMulHi) : IrOpcode::IMul32;
IrU32 result(ir.Emit(multiplyOpcode, IrType::U32, {&lhs.Value(), &rhs.Value()}));
if (addend) {
result = IrU32(ir.IAdd(result.Value(), readU32(sourceAt(inst, 2u)).Value()));
}
@@ -671,6 +671,10 @@ bool TranslationContext::emitVector(const RdnaInstruction& inst) {
return integer24(inst, true, false);
case RdnaOpcode::VMulU32U24:
return integer24(inst, false, false);
case RdnaOpcode::VMulHiI32I24:
return integer24(inst, true, false, true);
case RdnaOpcode::VMulHiU32U24:
return integer24(inst, false, false, true);
case RdnaOpcode::VMadI32I24:
return integer24(inst, true, true);
case RdnaOpcode::VMadU32U24: