File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
include/nbl/builtin/hlsl/cpp_compat/impl Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change 1616#include <boost/preprocessor/punctuation/comma_if.hpp>
1717#include <boost/preprocessor/seq/for_each_i.hpp>
1818
19+
1920namespace nbl
2021{
2122namespace hlsl
@@ -538,12 +539,8 @@ struct nMin_helper<T>
538539 using return_t = T;
539540 static inline return_t __call (const T a, const T b)
540541 {
541- if (std::isnan (a))
542- return b;
543- if (std::isnan (b))
544- return a;
545-
546- return std::min (a, b);
542+ // comparison involving any NaN always returns false
543+ return (b < a || std::isnan (a)) ? b : a;
547544 }
548545};
549546
@@ -554,12 +551,8 @@ struct nMax_helper<T>
554551 using return_t = T;
555552 static inline return_t __call (const T a, const T b)
556553 {
557- if (std::isnan (a))
558- return b;
559- if (std::isnan (b))
560- return a;
561-
562- return std::max (a, b);
554+ // comparison involving any NaN always returns false
555+ return (a < b || std::isnan (a)) ? b : a;
563556 }
564557};
565558
You can’t perform that action at this time.
0 commit comments