Skip to content

Commit 73ec3fa

Browse files
committed
start implementation
1 parent f137c3d commit 73ec3fa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

clang/lib/Headers/hlsl/hlsl_detail.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ template <typename T> struct is_arithmetic {
4545
static const bool Value = __is_arithmetic(T);
4646
};
4747

48+
template <typename T, int N>
49+
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
50+
fmod_vec_impl(vector<T, N> X, vector<T, N> Y) {
51+
#if !defined(__DirectX__)
52+
return __builtin_elementwise_fmod(X, Y);
53+
#else
54+
vector<T, N> div = X / Y;
55+
vector<T, N> result = __builtin_hlsl_elementwise_frac(__builtin_elementwise_abs(div)) * Y;
56+
vector<bool, N> condition = (div >= -div);
57+
vector<T, N> realResult = __builtin_hlsl_select(condition, result, -result);
58+
return realResult;
59+
#endif
60+
}
61+
4862
template <typename T, int N>
4963
using HLSL_FIXED_VECTOR =
5064
vector<__detail::enable_if_t<(N > 1 && N <= 4), T>, N>;

0 commit comments

Comments
 (0)