Skip to content

Commit b8945c9

Browse files
committed
Saving work
1 parent b38ebe3 commit b8945c9

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <boost/preprocessor/punctuation/comma_if.hpp>
1717
#include <boost/preprocessor/seq/for_each_i.hpp>
1818

19+
1920
namespace nbl
2021
{
2122
namespace 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

0 commit comments

Comments
 (0)