From 866a29e1532bca11098f0f0f74cdd29a0418b151 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sat, 5 Jun 2021 15:04:06 +0300 Subject: [PATCH] [Base] saturate_signed NaN comment --- src/xenia/base/math.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xenia/base/math.h b/src/xenia/base/math.h index 291e23a27..ac3ef8056 100644 --- a/src/xenia/base/math.h +++ b/src/xenia/base/math.h @@ -64,6 +64,10 @@ template constexpr T saturate_unsigned(T value) { return std::min(static_cast(1.0f), std::max(static_cast(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 constexpr T saturate_signed(T value) { return std::min(static_cast(1.0f), std::max(static_cast(-1.0f), value));