LibGfx: Avoid float->double->float when converting from linear to gamma

Benchmark shows 5x speedup (from 644ms to 110ms).
This commit is contained in:
Oleg Sikorskiy 2021-04-04 16:19:47 +03:00 committed by Andreas Kling
parent c0eacf4cc1
commit b34f194168
Notes: sideshowbarker 2024-07-18 20:49:11 +09:00

View file

@ -106,7 +106,7 @@ inline float linear_to_gamma(float x)
constexpr float a = 0.00279491;
constexpr float b = 1.15907984;
float c = (b / sqrt(1 + a)) - 1;
return ((b / __builtin_sqrt(x + a)) - c) * x;
return ((b / __builtin_sqrtf(x + a)) - c) * x;
}
// Linearize v1 and v2, lerp them by mix factor, then convert back.