diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/VopcCompare.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/VopcCompare.cpp index 79df28ea5..969945ef3 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/VopcCompare.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/VopcCompare.cpp @@ -228,6 +228,15 @@ int main() { FillInput(); Run(*device); Check(); + for (std::uint32_t pairBase = 0; pairBase < HalfEdges.size() * HalfEdges.size(); pairBase += Threads) { + for (std::uint32_t tid = 0; tid < Threads; ++tid) { + const auto pair = (pairBase + tid) % (HalfEdges.size() * HalfEdges.size()); + Input[tid * Inputs + 6u] = 0xabcd0000u | HalfEdges[pair / HalfEdges.size()]; + Input[tid * Inputs + 7u] = 0x12340000u | HalfEdges[pair % HalfEdges.size()]; + } + Run(*device); + Check(); + } std::puts("vopc compare tests passed"); return 0; } catch (const std::exception& error) { diff --git a/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp b/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp index 84096a2d8..a978fc566 100644 --- a/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp +++ b/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp @@ -116,7 +116,7 @@ private: void emitCompareConstant(const RdnaInstruction& inst, bool value, bool scalar, bool cmpx); void emitIntegerCompare(const RdnaInstruction& inst, IrOpcode opcode, IrType type, bool scalar, bool cmpx); void emitInteger16Compare(const RdnaInstruction& inst, IrOpcode opcode, bool signedValue, bool cmpx); - void emitFloatCompare(const RdnaInstruction& inst, IrOpcode opcode, bool half, bool cmpx); + void emitFloatCompare(const RdnaInstruction& inst, IrOpcode opcode, bool half, bool cmpx, bool swap = false); void emitInteger64Order(const RdnaInstruction& inst, bool signedValue, bool swap, bool negate, bool cmpx); void emitFloatOrderedCompare(const RdnaInstruction& inst, bool ordered, bool half, bool cmpx); void emitFloatClassCompare(const RdnaInstruction& inst, bool cmpx); diff --git a/core/shader/recompiler/Translation/src/CompareInstructions.cpp b/core/shader/recompiler/Translation/src/CompareInstructions.cpp index 5613f91ef..1c3e837b3 100644 --- a/core/shader/recompiler/Translation/src/CompareInstructions.cpp +++ b/core/shader/recompiler/Translation/src/CompareInstructions.cpp @@ -2,6 +2,7 @@ #include "Translation/TranslationContext.hpp" #include #include +#include namespace ShaderRecompiler { @@ -41,7 +42,7 @@ void TranslationContext::emitInteger16Compare(const RdnaInstruction& inst, IrOpc emitCompareResult(inst, IrU1(ir.Emit(opcode, IrType::U1, {&lhs.Value(), &rhs.Value()})), false, cmpx); } -void TranslationContext::emitFloatCompare(const RdnaInstruction& inst, IrOpcode opcode, bool half, bool cmpx) { +void TranslationContext::emitFloatCompare(const RdnaInstruction& inst, IrOpcode opcode, bool half, bool cmpx, bool swap) { IrValue* lhs = nullptr; IrValue* rhs = nullptr; if (half) { @@ -51,6 +52,7 @@ void TranslationContext::emitFloatCompare(const RdnaInstruction& inst, IrOpcode lhs = readOperand(sourceAt(inst, 0u), IrType::F32); rhs = readOperand(sourceAt(inst, 1u), IrType::F32); } + if (swap) std::swap(lhs, rhs); emitCompareResult(inst, IrU1(ir.Emit(opcode, IrType::U1, {lhs, rhs})), false, cmpx); } diff --git a/core/shader/recompiler/Translation/src/VectorInstructions.cpp b/core/shader/recompiler/Translation/src/VectorInstructions.cpp index 9b6710ea9..d9556fe35 100644 --- a/core/shader/recompiler/Translation/src/VectorInstructions.cpp +++ b/core/shader/recompiler/Translation/src/VectorInstructions.cpp @@ -263,7 +263,7 @@ bool TranslationContext::emitVector(const RdnaInstruction& inst) { emitFloatCompare(inst, IrOpcode::FPUnordLessThanEqual32, true, false); return true; case RdnaOpcode::VCmpNleF16: - emitFloatCompare(inst, IrOpcode::FPUnordGreaterThan32, true, false); + emitFloatCompare(inst, IrOpcode::FPUnordLessThan32, true, false, true); return true; case RdnaOpcode::VCmpNltF16: emitFloatCompare(inst, IrOpcode::FPUnordGreaterThanEqual32, true, false); @@ -290,7 +290,7 @@ bool TranslationContext::emitVector(const RdnaInstruction& inst) { emitFloatCompare(inst, IrOpcode::FPUnordEqual32, true, true); return true; case RdnaOpcode::VCmpxNleF16: - emitFloatCompare(inst, IrOpcode::FPUnordGreaterThan32, true, true); + emitFloatCompare(inst, IrOpcode::FPUnordLessThan32, true, true, true); return true; case RdnaOpcode::VCmpxTruF16: emitCompareConstant(inst, true, false, true);