[Base] saturate_signed NaN comment

This commit is contained in:
Triang3l 2021-06-05 15:04:06 +03:00
parent 3c20a83972
commit 866a29e153
1 changed files with 4 additions and 0 deletions

View File

@ -64,6 +64,10 @@ template <typename T>
constexpr T saturate_unsigned(T value) {
return std::min(static_cast<T>(1.0f), std::max(static_cast<T>(0.0f), value));
}
// This diverges from the GPU NaN rules for signed normalized formats (NaN
// should be converted to 0, not to -1), but this expectation is not needed most
// of time, and cannot be met for free (unlike for 0...1 clamping).
template <typename T>
constexpr T saturate_signed(T value) {
return std::min(static_cast<T>(1.0f), std::max(static_cast<T>(-1.0f), value));