forked from ValveSoftware/steamos-compositor
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove global -ffast-math flag, but apply fast math to just color_hel…
…pers.h/color_helpers.cpp Turn on FTZ/DAZ inside create_color_mgmt_luts()
- Loading branch information
1 parent
467e12c
commit 43e87da
Showing
7 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#if defined(__x86__) || defined(__x86_64__) | ||
#include <xmmintrin.h> | ||
#include <pmmintrin.h> | ||
#define SET_FAST_MATH_FLAGS FlagSwitcher switcher{}; | ||
#define SET_FLUSH_AND_ZERO_TO_ON _mm_setcsr( _mm_getcsr() | (_MM_DENORMALS_ZERO_ON | _MM_FLUSH_ZERO_ON) ); | ||
struct FlagSwitcher { | ||
unsigned int m_csr; | ||
FlagSwitcher() : m_csr{_mm_getcsr()} { | ||
SET_FLUSH_AND_ZERO_TO_ON | ||
} | ||
~FlagSwitcher() { | ||
_mm_setcsr(m_csr); | ||
} | ||
}; | ||
#elif defined(__aarch64__) && __has_builtin(__builtin_aarch64_get_fpcr64) && __has_builtin(__builtin_aarch64_set_fpcr64) | ||
#define SET_FAST_MATH_FLAGS FlagSwitcher switcher{}; | ||
|
||
static constexpr unsigned long long fz_bit = 0x1'00'00'00; | ||
//based on this stuff: https://github.com/DLTcollab/sse2neon/blob/706d3b58025364c2371cafcf9b16e32ff7e630ed/sse2neon.h#L2433 | ||
//and this: https://stackoverflow.com/a/59001820 | ||
static constexpr unsigned long long dz_bit = 0x8'00'00; | ||
struct FlagSwitcher { | ||
unsigned long long m_csr; | ||
FlagSwitcher() : m_csr{__builtin_aarch64_get_fpcr64()} { | ||
__builtin_aarch64_set_fpcr64(m_csr | fz_bit | dz_bit); | ||
} | ||
~FlagSwitcher() { | ||
__builtin_aarch64_set_fpcr64(m_csr); | ||
} | ||
}; | ||
|
||
#else | ||
#define SET_FAST_MATH_FLAGS | ||
|
||
#endif | ||
|
||
#ifdef __clang__ | ||
#define FAST_MATH_ON _Pragma("float_control(push)"); \ | ||
_Pragma("float_control(precise, off)") //https://clang.llvm.org/docs/LanguageExtensions.html#extensions-to-specify-floating-point-flags | ||
#define FAST_MATH_OFF _Pragma("float_control(pop)") | ||
#elif defined(__GNUC__) | ||
#define FAST_MATH_ON _Pragma("GCC push_options"); \ | ||
_Pragma("GCC optimize(\"-ffast-math\")") | ||
#define FAST_MATH_OFF _Pragma("GCC pop_options") | ||
#else | ||
#define FAST_MATH_ON | ||
#define FAST_MATH_OFF | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters