glsl: Simplify FCMP emission

This commit is contained in:
ameerj 2021-07-16 20:13:15 -04:00
parent 79d2684261
commit 56c30dd9e0

View File

@ -13,12 +13,10 @@ namespace Shader::Backend::GLSL {
namespace { namespace {
void Compare(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs, void Compare(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs,
std::string_view op, bool ordered) { std::string_view op, bool ordered) {
ctx.AddU1("{}={}{}{}", inst, lhs, op, rhs, lhs, rhs); const auto nan_op{ordered ? "&&!" : "||"};
if (ordered) { ctx.AddU1("{}={}{}{}"
ctx.Add("&&!isnan({})&&!isnan({});", lhs, rhs); "{}isnan({}){}isnan({});",
} else { inst, lhs, op, rhs, nan_op, lhs, nan_op, rhs);
ctx.Add("||isnan({})||isnan({});", lhs, rhs);
}
} }
bool IsPrecise(const IR::Inst& inst) { bool IsPrecise(const IR::Inst& inst) {