Skip to content

Commit a1938a7

Browse files
author
Alexander Johnston
committed
Change hlsl ddx/y_coarse intrinsic to alias
1 parent 202b09c commit a1938a7

File tree

3 files changed

+68
-92
lines changed

3 files changed

+68
-92
lines changed

clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,5 +2840,73 @@ float4 radians(float4);
28402840
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_group_memory_barrier_with_group_sync)
28412841
__attribute__((convergent)) void GroupMemoryBarrierWithGroupSync(void);
28422842

2843+
//===----------------------------------------------------------------------===//
2844+
// ddx_coarse builtin
2845+
//===----------------------------------------------------------------------===//
2846+
2847+
/// \fn T ddx_coarse(T value)
2848+
/// \brief Computes a low precision partial derivative with respect to the
2849+
/// screen-space x-coordinate.
2850+
/// \param value The input value.
2851+
///
2852+
/// The return value is a floating point scalar or vector containing the low
2853+
/// prevision partial derivative of the input value.
2854+
2855+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2856+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
2857+
half ddx_coarse(half);
2858+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2859+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
2860+
half2 ddx_coarse(half2);
2861+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2862+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
2863+
half3 ddx_coarse(half3);
2864+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2865+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
2866+
half4 ddx_coarse(half4);
2867+
2868+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
2869+
float ddx_coarse(float);
2870+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
2871+
float2 ddx_coarse(float2);
2872+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
2873+
float3 ddx_coarse(float3);
2874+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddx_coarse)
2875+
float4 ddx_coarse(float4);
2876+
2877+
//===----------------------------------------------------------------------===//
2878+
// ddy_coarse builtin
2879+
//===----------------------------------------------------------------------===//
2880+
2881+
/// \fn T ddy_coarse(T value)
2882+
/// \brief Computes a low precision partial derivative with respect to the
2883+
/// screen-space y-coordinate.
2884+
/// \param value The input value.
2885+
///
2886+
/// The return value is a floating point scalar or vector containing the low
2887+
/// prevision partial derivative of the input value.
2888+
2889+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2890+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
2891+
half ddy_coarse(half);
2892+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2893+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
2894+
half2 ddy_coarse(half2);
2895+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2896+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
2897+
half3 ddy_coarse(half3);
2898+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2899+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
2900+
half4 ddy_coarse(half4);
2901+
2902+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
2903+
float ddy_coarse(float);
2904+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
2905+
float2 ddy_coarse(float2);
2906+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
2907+
float3 ddy_coarse(float3);
2908+
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_ddy_coarse)
2909+
float4 ddy_coarse(float4);
2910+
28432911
} // namespace hlsl
28442912
#endif //_HLSL_HLSL_ALIAS_INTRINSICS_H_

clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,6 @@ template <typename T> constexpr T ldexp_impl(T X, T Exp) {
148148
return exp2(Exp) * X;
149149
}
150150

151-
template <typename T> constexpr T ddx_coarse_impl(T value) {
152-
#if (__has_builtin(__builtin_spirv_ddx_coarse))
153-
return __builtin_spirv_ddx_coarse(value);
154-
#else
155-
return __builtin_hlsl_elementwise_ddx_coarse(value);
156-
#endif
157-
}
158-
159-
template <typename T> constexpr T ddy_coarse_impl(T value) {
160-
#if (__has_builtin(__builtin_spirv_ddy_coarse))
161-
return __builtin_spirv_ddy_coarse(value);
162-
#else
163-
return __builtin_hlsl_elementwise_ddy_coarse(value);
164-
#endif
165-
}
166-
167151
} // namespace __detail
168152
} // namespace hlsl
169153

clang/lib/Headers/hlsl/hlsl_intrinsics.h

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -605,81 +605,5 @@ smoothstep(__detail::HLSL_FIXED_VECTOR<float, N> Min,
605605
return __detail::smoothstep_vec_impl(Min, Max, X);
606606
}
607607

608-
//===----------------------------------------------------------------------===//
609-
// ddx_coarse builtin
610-
//===----------------------------------------------------------------------===//
611-
612-
/// \fn T ddx_coarse(T value)
613-
/// \brief Computes a low precision partial derivative with respect to the
614-
/// screen-space x-coordinate.
615-
/// \param value The input value.
616-
///
617-
/// The return value is a floating point scalar or vector containing the low
618-
/// prevision partial derivative of the input value.
619-
620-
template <typename T>
621-
const inline __detail::enable_if_t<
622-
__detail::is_arithmetic<T>::Value && __detail::is_same<half, T>::value, T>
623-
ddx_coarse(T value) {
624-
return __detail::ddx_coarse_impl(value);
625-
}
626-
627-
template <typename T>
628-
const inline __detail::enable_if_t<
629-
__detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
630-
ddx_coarse(T value) {
631-
return __detail::ddx_coarse_impl(value);
632-
}
633-
634-
template <int L>
635-
const inline __detail::HLSL_FIXED_VECTOR<half, L>
636-
ddx_coarse(__detail::HLSL_FIXED_VECTOR<half, L> value) {
637-
return __detail::ddx_coarse_impl(value);
638-
}
639-
640-
template <int L>
641-
const inline __detail::HLSL_FIXED_VECTOR<float, L>
642-
ddx_coarse(__detail::HLSL_FIXED_VECTOR<float, L> value) {
643-
return __detail::ddx_coarse_impl(value);
644-
}
645-
646-
//===----------------------------------------------------------------------===//
647-
// ddy_coarse builtin
648-
//===----------------------------------------------------------------------===//
649-
650-
/// \fn T ddy_coarse(T value)
651-
/// \brief Computes a low precision partial derivative with respect to the
652-
/// screen-space y-coordinate.
653-
/// \param value The input value.
654-
///
655-
/// The return value is a floating point scalar or vector containing the low
656-
/// prevision partial derivative of the input value.
657-
658-
template <typename T>
659-
const inline __detail::enable_if_t<
660-
__detail::is_arithmetic<T>::Value && __detail::is_same<half, T>::value, T>
661-
ddy_coarse(T value) {
662-
return __detail::ddy_coarse_impl(value);
663-
}
664-
665-
template <typename T>
666-
const inline __detail::enable_if_t<
667-
__detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
668-
ddy_coarse(T value) {
669-
return __detail::ddy_coarse_impl(value);
670-
}
671-
672-
template <int L>
673-
const inline __detail::HLSL_FIXED_VECTOR<half, L>
674-
ddy_coarse(__detail::HLSL_FIXED_VECTOR<half, L> value) {
675-
return __detail::ddy_coarse_impl(value);
676-
}
677-
678-
template <int L>
679-
const inline __detail::HLSL_FIXED_VECTOR<float, L>
680-
ddy_coarse(__detail::HLSL_FIXED_VECTOR<float, L> value) {
681-
return __detail::ddy_coarse_impl(value);
682-
}
683-
684608
} // namespace hlsl
685609
#endif //_HLSL_HLSL_INTRINSICS_H_

0 commit comments

Comments
 (0)