Skip to content

Commit 214cb4a

Browse files
committed
updated fmod.hlsl test cases following feedback, move fmod hlsl_detail.h changes to hlsl_intrinsic_helpers.h
1 parent e3627c5 commit 214cb4a

File tree

3 files changed

+124
-123
lines changed

3 files changed

+124
-123
lines changed

clang/lib/Headers/hlsl/hlsl_detail.h

-25
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,6 @@ template <typename T> struct is_arithmetic {
4545
static const bool Value = __is_arithmetic(T);
4646
};
4747

48-
template <typename T>
49-
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
50-
fmod_impl(T X, T Y) {
51-
#if !defined(__DIRECTX__)
52-
return __builtin_elementwise_fmod(X, Y);
53-
#else
54-
T div = X / Y;
55-
bool ge = div >= -div;
56-
T frc = frac(abs(div));
57-
return select<T>(ge, frc, -frc) * Y;
58-
#endif
59-
}
60-
61-
template <typename T, int N>
62-
constexpr vector<T, N> fmod_vec_impl(vector<T, N> X, vector<T, N> Y) {
63-
#if !defined(__DIRECTX__)
64-
return __builtin_elementwise_fmod(X, Y);
65-
#else
66-
vector<T, N> div = X / Y;
67-
vector<bool, N> ge = div >= -div;
68-
vector<T, N> frc = frac(abs(div));
69-
return select<T>(ge, frc, -frc) * Y;
70-
#endif
71-
}
72-
7348
} // namespace __detail
7449
} // namespace hlsl
7550
#endif //_HLSL_HLSL_DETAILS_H_

clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h

+26
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ constexpr vector<T, L> reflect_vec_impl(vector<T, L> I, vector<T, L> N) {
6565
return I - 2 * N * dot(I, N);
6666
#endif
6767
}
68+
69+
template <typename T>
70+
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
71+
fmod_impl(T X, T Y) {
72+
#if !defined(__DIRECTX__)
73+
return __builtin_elementwise_fmod(X, Y);
74+
#else
75+
T div = X / Y;
76+
bool ge = div >= -div;
77+
T frc = frac(abs(div));
78+
return select<T>(ge, frc, -frc) * Y;
79+
#endif
80+
}
81+
82+
template <typename T, int N>
83+
constexpr vector<T, N> fmod_vec_impl(vector<T, N> X, vector<T, N> Y) {
84+
#if !defined(__DIRECTX__)
85+
return __builtin_elementwise_fmod(X, Y);
86+
#else
87+
vector<T, N> div = X / Y;
88+
vector<bool, N> ge = div >= -div;
89+
vector<T, N> frc = frac(abs(div));
90+
return select<T>(ge, frc, -frc) * Y;
91+
#endif
92+
}
93+
6894
} // namespace __detail
6995
} // namespace hlsl
7096

0 commit comments

Comments
 (0)