gl_shader_decompiler: Properly emulate NaN behaviour on NE
"Not equal" operators on GLSL seem to behave as unordered when we expect an ordered comparison. Manually emulate this checking for LGE values (numbers, not-NaNs).
This commit is contained in:
parent
4e57f9d5cf
commit
8b329ddcc9
1 changed files with 9 additions and 0 deletions
|
@ -1845,6 +1845,15 @@ private:
|
||||||
static_assert(!unordered || type == Type::Float);
|
static_assert(!unordered || type == Type::Float);
|
||||||
|
|
||||||
const Expression expr = GenerateBinaryInfix(operation, op, Type::Bool, type, type);
|
const Expression expr = GenerateBinaryInfix(operation, op, Type::Bool, type, type);
|
||||||
|
|
||||||
|
if constexpr (op.compare("!=") == 0 && type == Type::Float && !unordered) {
|
||||||
|
// GLSL's operator!=(float, float) doesn't seem be ordered. This happens on both AMD's
|
||||||
|
// and Nvidia's proprietary stacks. Manually force an ordered comparison.
|
||||||
|
return {fmt::format("({} && !isnan({}) && !isnan({}))", expr.AsBool(),
|
||||||
|
VisitOperand(operation, 0).AsFloat(),
|
||||||
|
VisitOperand(operation, 1).AsFloat()),
|
||||||
|
Type::Bool};
|
||||||
|
}
|
||||||
if constexpr (!unordered) {
|
if constexpr (!unordered) {
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue