summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-05-09 04:56:50 -0300
committerGravatar ReinUsesLisp2020-05-10 02:59:33 -0300
commit8b329ddcc9b39353b9545289b3bd653a77db0103 (patch)
tree6789cbf1016daecc6bdc373b4d8b79b92463d538 /src
parentshader_ir: Separate float-point comparisons in ordered and unordered (diff)
downloadyuzu-8b329ddcc9b39353b9545289b3bd653a77db0103.tar.gz
yuzu-8b329ddcc9b39353b9545289b3bd653a77db0103.tar.xz
yuzu-8b329ddcc9b39353b9545289b3bd653a77db0103.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index d071abd84..960ebf1a1 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -1845,6 +1845,15 @@ private:
1845 static_assert(!unordered || type == Type::Float); 1845 static_assert(!unordered || type == Type::Float);
1846 1846
1847 const Expression expr = GenerateBinaryInfix(operation, op, Type::Bool, type, type); 1847 const Expression expr = GenerateBinaryInfix(operation, op, Type::Bool, type, type);
1848
1849 if constexpr (op.compare("!=") == 0 && type == Type::Float && !unordered) {
1850 // GLSL's operator!=(float, float) doesn't seem be ordered. This happens on both AMD's
1851 // and Nvidia's proprietary stacks. Manually force an ordered comparison.
1852 return {fmt::format("({} && !isnan({}) && !isnan({}))", expr.AsBool(),
1853 VisitOperand(operation, 0).AsFloat(),
1854 VisitOperand(operation, 1).AsFloat()),
1855 Type::Bool};
1856 }
1848 if constexpr (!unordered) { 1857 if constexpr (!unordered) {
1849 return expr; 1858 return expr;
1850 } 1859 }