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 calcColor…
…Transform() Turn on FTZ/DAZ inside calcColorTransform()
- Loading branch information
1 parent
467e12c
commit c540046
Showing
5 changed files
with
63 additions
and
7 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,48 @@ | ||
#pragma once | ||
|
||
#ifdef __x86__ | ||
#include <xmmintrin.h> | ||
#define SET_FAST_MATH_FLAGS FlagSwitcher switcher{}; | ||
|
||
struct FlagSwitcher { | ||
unsigned int m_csr; | ||
FlagSwitcher() : m_csr{_mm_getcsr()} { | ||
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); | ||
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); | ||
} | ||
~FlagSwitcher() { | ||
_mm_setcsr(m_csr); | ||
} | ||
}; | ||
#elif __aarch64__ | ||
#define SET_FAST_MATH_FLAGS FlagSwitcher switcher{}; | ||
|
||
static constexpr unsigned long long fz_bit = 0x1000000; | ||
//based on this stuff: https://github.com/DLTcollab/sse2neon/blob/706d3b58025364c2371cafcf9b16e32ff7e630ed/sse2neon.h#L2433 | ||
struct FlagSwitcher { | ||
unsigned long long m_csr; | ||
FlagSwitcher() : m_csr{__builtin_aarch64_get_fpcr64()} { | ||
__builtin_aarch64_set_fpcr64(m_csr | fz_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