From a234e4c2009b08039d0698cbbcc8595a1f04a615 Mon Sep 17 00:00:00 2001 From: Huw Pascoe Date: Sun, 17 Sep 2017 15:42:45 +0100 Subject: Improved performance of FromAttributeBuffer Ternary operator is optimized by the compiler whereas std::min() is meant to return a value. I've noticed a 5%-10% emulation speed increase. --- src/video_core/shader/shader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index e9063e616..2857d2829 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -52,7 +52,8 @@ OutputVertex OutputVertex::FromAttributeBuffer(const RasterizerRegs& regs, // The hardware takes the absolute and saturates vertex colors like this, *before* doing // interpolation for (unsigned i = 0; i < 4; ++i) { - ret.color[i] = float24::FromFloat32(std::fmin(std::fabs(ret.color[i].ToFloat32()), 1.0f)); + float c = std::fabs(ret.color[i].ToFloat32()); + ret.color[i] = float24::FromFloat32(c < 1.0f ? c : 1.0f); } LOG_TRACE(HW_GPU, "Output vertex: pos(%.2f, %.2f, %.2f, %.2f), quat(%.2f, %.2f, %.2f, %.2f), " -- cgit v1.2.3