From b55a4bb087d79c165f5cc9adefc1611c95491af4 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Wed, 8 Jan 2014 16:40:31 -0600 Subject: [PATCH] Slight optimization in the pixel shader. We are using pow(2.0, X) in place of exp2(X). This can be faster in places that don't optimize a pow to a exp2 in this case. Notice this from here: http://cgit.freedesktop.org/mesa/mesa/commit/?id=847bc36a38d42967ad6bf0492fe90a4892d9d799 Intel Haswell GPU is 24 cycles for POW and 14 cycles for EXP2. Maybe other GPUs don't optimize this either. Just be safe. --- Source/Core/VideoCommon/PixelShaderGen.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index db8c8bdd6b..79d3a38835 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -1128,10 +1128,10 @@ static const char *tevFogFuncsTable[] = "", // ? "", // Linear "", // ? - "\tfog = 1.0 - pow(2.0, -8.0 * fog);\n", // exp - "\tfog = 1.0 - pow(2.0, -8.0 * fog * fog);\n", // exp2 - "\tfog = pow(2.0, -8.0 * (1.0 - fog));\n", // backward exp - "\tfog = 1.0 - fog;\n fog = pow(2.0, -8.0 * fog * fog);\n" // backward exp2 + "\tfog = 1.0 - exp2(-8.0 * fog);\n", // exp + "\tfog = 1.0 - exp2(-8.0 * fog * fog);\n", // exp2 + "\tfog = exp2(-8.0 * (1.0 - fog));\n", // backward exp + "\tfog = 1.0 - fog;\n fog = exp2(-8.0 * fog * fog);\n" // backward exp2 }; template