Skip to content

Commit bdb66b5

Browse files
committed
start implementation
1 parent a2b3daf commit bdb66b5

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
@@ -97,6 +97,20 @@ constexpr vector<T, L> reflect_vec_impl(vector<T, L> I, vector<T, L> N) {
9797
#endif
9898
}
9999

100+
template <typename T, int N>
101+
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
102+
fmod_vec_impl(vector<T, N> X, vector<T, N> Y) {
103+
#if !defined(__DirectX__)
104+
return __builtin_elementwise_fmod(X, Y);
105+
#else
106+
vector<T, N> div = X / Y;
107+
vector<T, N> result = __builtin_hlsl_elementwise_frac(__builtin_elementwise_abs(div)) * Y;
108+
vector<bool, N> condition = (div >= -div);
109+
vector<T, N> realResult = __builtin_hlsl_select(condition, result, -result);
110+
return realResult;
111+
#endif
112+
}
113+
100114
} // namespace __detail
101115
} // namespace hlsl
102116
#endif //_HLSL_HLSL_DETAILS_H_

0 commit comments

Comments
 (0)