summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2013-07-14 02:38:13 +0200
committerRoland Scheidegger <[email protected]>2013-07-14 02:39:33 +0200
commit796b73d1feeafa7ce128273f722409ad697bfdb4 (patch)
treee38a4b0f2549317679eca11631a86348e2b5194a /src/gallium/auxiliary/gallivm
parent62c546bbf87afe32e49c100e245e04bc35304481 (diff)
gallivm: (trivial) use constant instead of exp2f() function
Some lame compilers can't do exp2f() and as far as I can tell they can't do exp2() (with doubles) neither so instead of providing some workaround for that (wouldn't actually be too bad just replace with pow) and since it is used with a constant only just use the precalculated constant.
Diffstat (limited to 'src/gallium/auxiliary/gallivm')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_format_srgb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_srgb.c b/src/gallium/auxiliary/gallivm/lp_bld_format_srgb.c
index 217aaa99838..f949a8daff1 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_srgb.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_srgb.c
@@ -170,6 +170,8 @@ lp_build_linear_to_srgb(struct gallivm_state *gallivm,
*/
float exp_f = 2.0f / 3.0f;
+ /* some compilers can't do exp2f, so this is exp2f(127.0f/exp_f - 127.0f) */
+ float exp2f_c = 1.30438178253e+19f;
float coeff_f = 0.62996f;
LLVMValueRef pow_approx, coeff, x2, exponent, pow_1, pow_2;
struct lp_type int_type = lp_int_type(src_type);
@@ -179,8 +181,7 @@ lp_build_linear_to_srgb(struct gallivm_state *gallivm,
*/
exponent = lp_build_const_vec(gallivm, src_type, exp_f);
coeff = lp_build_const_vec(gallivm, src_type,
- exp2f(127.0f / exp_f - 127.0f) *
- powf(coeff_f, 1.0f / exp_f));
+ exp2f_c * powf(coeff_f, 1.0f / exp_f));
/* premultiply src */
tmp = lp_build_mul(&f32_bld, coeff, src);