2 * Copyright
(c) 2014,2015 Advanced Micro Devices
, Inc.
4 * Permission is hereby granted
, free of charge
, to any person obtaining a copy
5 * of this software and associated documentation files
(the "Software"), to deal
6 * in the Software without restriction
, including without limitation the rights
7 * to use
, copy
, modify
, merge
, publish
, distribute
, sublicense
, and
/or sell
8 * copies of the Software
, and to permit persons to whom the Software is
9 * furnished to do so
, subject to the following conditions
:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED
"AS IS", WITHOUT WARRANTY OF ANY KIND
, EXPRESS OR
15 * IMPLIED
, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM
, DAMAGES OR OTHER
18 * LIABILITY
, WHETHER IN AN ACTION OF CONTRACT
, TORT OR OTHERWISE
, ARISING FROM
,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #include
"../clcmacro.h"
27 _CLC_OVERLOAD _CLC_DEF float smoothstep
(float edge0
, float edge1
, float x
) {
28 float t
= clamp
((x - edge0
) / (edge1 - edge0
), 0.0f
, 1.0f
);
29 return t
* t
* (3.0f -
2.0f
* t
);
32 _CLC_TERNARY_VECTORIZE
(_CLC_OVERLOAD _CLC_DEF
, float
, smoothstep
, float
, float
, float
);
34 _CLC_V_S_S_V_VECTORIZE
(_CLC_OVERLOAD _CLC_DEF
, float
, smoothstep
, float
, float
, float
);
37 #pragma OPENCL EXTENSION cl_khr_fp64
: enable
39 #define SMOOTH_STEP_DEF
(edge_type, x_type
, impl
) \
40 _CLC_OVERLOAD _CLC_DEF x_type smoothstep
(edge_type edge0
, edge_type edge1
, x_type x
) { \
41 double t
= clamp
((x - edge0
) / (edge1 - edge0
), 0.0, 1.0); \
42 return t
* t
* (3.0 -
2.0 * t
); \
45 SMOOTH_STEP_DEF
(double, double
, SMOOTH_STEP_IMPL_D
);
47 _CLC_TERNARY_VECTORIZE
(_CLC_OVERLOAD _CLC_DEF
, double
, smoothstep
, double
, double
, double
);
49 #if
!defined
(CLC_SPIRV) && !defined
(CLC_SPIRV64)
50 SMOOTH_STEP_DEF
(float, double
, SMOOTH_STEP_IMPL_D
);
51 SMOOTH_STEP_DEF
(double, float
, SMOOTH_STEP_IMPL_D
);
53 _CLC_V_S_S_V_VECTORIZE
(_CLC_OVERLOAD _CLC_DEF
, double
, smoothstep
, float
, float
, double
);
54 _CLC_V_S_S_V_VECTORIZE
(_CLC_OVERLOAD _CLC_DEF
, float
, smoothstep
, double
, double
, float
);