From: Brian Paul Date: Fri, 22 Aug 2008 21:14:36 +0000 (-0600) Subject: mesa: glsl: implement exp() functions in terms of EXP asm instruction, not pow X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=47d4b958cfaac080a97bf0ba21d78b3ce37b62a9;p=mesa.git mesa: glsl: implement exp() functions in terms of EXP asm instruction, not pow --- diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc index e908e6c9401..561e94f6bab 100644 --- a/src/mesa/shader/slang/library/slang_common_builtin.gc +++ b/src/mesa/shader/slang/library/slang_common_builtin.gc @@ -473,32 +473,33 @@ vec4 pow(const vec4 a, const vec4 b) float exp(const float a) { - const float e = 2.71828; - __asm float_power __retVal, e, a; + // NOTE: log2(e) = 1.44269502 + float t = a * 1.44269502; + __asm float_exp2 __retVal, t; } vec2 exp(const vec2 a) { - const float e = 2.71828; - __asm float_power __retVal.x, e, a.x; - __asm float_power __retVal.y, e, a.y; + vec2 t = a * 1.44269502; + __asm float_exp2 __retVal.x, t.x; + __asm float_exp2 __retVal.y, t.y; } vec3 exp(const vec3 a) { - const float e = 2.71828; - __asm float_power __retVal.x, e, a.x; - __asm float_power __retVal.y, e, a.y; - __asm float_power __retVal.z, e, a.z; + vec3 t = a * 1.44269502; + __asm float_exp2 __retVal.x, t.x; + __asm float_exp2 __retVal.y, t.y; + __asm float_exp2 __retVal.z, t.z; } vec4 exp(const vec4 a) { - const float e = 2.71828; - __asm float_power __retVal.x, e, a.x; - __asm float_power __retVal.y, e, a.y; - __asm float_power __retVal.z, e, a.z; - __asm float_power __retVal.w, e, a.w; + vec4 t = a * 1.44269502; + __asm float_exp2 __retVal.x, t.x; + __asm float_exp2 __retVal.y, t.y; + __asm float_exp2 __retVal.z, t.z; + __asm float_exp2 __retVal.w, t.w; }