From cab0ad50f00837014cd910f7406eed9e6281360f Mon Sep 17 00:00:00 2001 From: GPUCode <47210458+GPUCode@users.noreply.github.com> Date: Thu, 31 Aug 2023 23:37:53 +0300 Subject: [PATCH] gl_shader_decompiler: Fix min/max NaN edge case (#6935) --- .../renderer_opengl/gl_shader_decompiler.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 06f6a1cd4..6c01bfc70 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -476,12 +476,22 @@ private: } case OpCode::Id::MAX: { - SetDest(swizzle, dest_reg, fmt::format("max({}, {})", src1, src2), 4, 4); + if (sanitize_mul) { + SetDest(swizzle, dest_reg, + fmt::format("mix({1}, {0}, greaterThan({0}, {1}))", src1, src2), 4, 4); + } else { + SetDest(swizzle, dest_reg, fmt::format("max({}, {})", src1, src2), 4, 4); + } break; } case OpCode::Id::MIN: { - SetDest(swizzle, dest_reg, fmt::format("min({}, {})", src1, src2), 4, 4); + if (sanitize_mul) { + SetDest(swizzle, dest_reg, + fmt::format("mix({1}, {0}, lessThan({0}, {1}))", src1, src2), 4, 4); + } else { + SetDest(swizzle, dest_reg, fmt::format("min({}, {})", src1, src2), 4, 4); + } break; }