mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-05 17:16:04 +00:00
LibGfx: Use AK's rsqrt and cast to floats earlier
This commit is contained in:
parent
5ba5a6615d
commit
d03a6cc6c6
Notes:
sideshowbarker
2024-07-18 01:43:16 +09:00
Author: https://github.com/Hendiadyoin1
Commit: d03a6cc6c6
Pull-request: https://github.com/SerenityOS/serenity/pull/13405
2 changed files with 17 additions and 16 deletions
|
@ -14,6 +14,7 @@
|
|||
#endif
|
||||
|
||||
#include <AK/SIMD.h>
|
||||
#include <AK/SIMDMath.h>
|
||||
|
||||
#define GAMMA 2.2
|
||||
|
||||
|
@ -59,8 +60,8 @@ inline f32x4 linear_to_gamma4(f32x4 x)
|
|||
// Source for approximation: https://mimosa-pudica.net/fast-gamma/
|
||||
constexpr float a = 0.00279491f;
|
||||
constexpr float b = 1.15907984f;
|
||||
float c = (b / AK::sqrt(1.0f + a)) - 1;
|
||||
return ((b * __builtin_ia32_rsqrtps(x + a)) - c) * x;
|
||||
float c = (b * AK::rsqrt(1.0f + a)) - 1;
|
||||
return ((b * AK::SIMD::rsqrt(x + a)) - c) * x;
|
||||
}
|
||||
|
||||
// Linearize v1 and v2, lerp them by mix factor, then convert back.
|
||||
|
@ -86,8 +87,8 @@ inline float linear_to_gamma(float x)
|
|||
// Source for approximation: https://mimosa-pudica.net/fast-gamma/
|
||||
constexpr float a = 0.00279491;
|
||||
constexpr float b = 1.15907984;
|
||||
float c = (b / AK::sqrt(1 + a)) - 1;
|
||||
return ((b / AK::sqrt(x + a)) - c) * x;
|
||||
float c = (b * AK::rsqrt(1 + a)) - 1;
|
||||
return ((b * AK::rsqrt(x + a)) - c) * x;
|
||||
}
|
||||
|
||||
// Linearize v1 and v2, lerp them by mix factor, then convert back.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue