From ef16da4479d9d2034f3b6072410b488d7568ce88 Mon Sep 17 00:00:00 2001 From: kmpeng Date: Tue, 25 Feb 2025 14:50:09 -0800 Subject: [PATCH] start implementation --- clang/lib/Headers/hlsl/hlsl_detail.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/clang/lib/Headers/hlsl/hlsl_detail.h b/clang/lib/Headers/hlsl/hlsl_detail.h index c691d85283de4..c6dd5494f149f 100644 --- a/clang/lib/Headers/hlsl/hlsl_detail.h +++ b/clang/lib/Headers/hlsl/hlsl_detail.h @@ -45,6 +45,20 @@ template struct is_arithmetic { static const bool Value = __is_arithmetic(T); }; +template +constexpr enable_if_t::value || is_same::value, T> +fmod_vec_impl(vector X, vector Y) { +#if !defined(__DirectX__) + return __builtin_elementwise_fmod(X, Y); +#else + vector div = X / Y; + vector result = __builtin_hlsl_elementwise_frac(__builtin_elementwise_abs(div)) * Y; + vector condition = (div >= -div); + vector realResult = __builtin_hlsl_select(condition, result, -result); + return realResult; +#endif +} + } // namespace __detail } // namespace hlsl #endif //_HLSL_HLSL_DETAILS_H_