mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(shader): lower f16 NLE comparisons through swapped unordered less-than
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Translation/TranslationContext.hpp"
|
||||
#include <array>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user