11#if !defined(__KERNEL_GPU__) && defined(__KERNEL_SSE2__)
19#if defined(__KERNEL_METAL__)
30 *((
ccl_private int *)&f) = ((val.s & 0x8000) << 16) | (((val.s & 0x7c00) + 0x1C000) << 13) |
31 ((val.s & 0x03FF) << 13);
39# if !defined(__KERNEL_CUDA__) && !defined(__KERNEL_HIP__) && !defined(__KERNEL_ONEAPI__)
45 half(
const unsigned short &i) : v(i) {}
46 operator unsigned short()
73#if defined(__KERNEL_METAL__) || defined(__KERNEL_ONEAPI__)
75#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__)
80 uint sign_bit = u & 0x80000000;
83 uint exponent_bits = u & 0x7f800000;
85 uint value_bits = u & 0x7fffffff;
87 value_bits -= 0x1c000;
89 value_bits = (exponent_bits < 0x38800000) ? 0 : value_bits;
91 value_bits = (exponent_bits > 0x47000000) ? 0x7bff : value_bits;
93 value_bits = (exponent_bits == 0 ? 0 : value_bits);
95 return (value_bits | sign_bit);
101#if defined(__KERNEL_METAL__)
102 return half_to_float(h);
103#elif defined(__KERNEL_ONEAPI__)
105#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__)
108 const int x = ((h & 0x8000) << 16) | (((h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13);
119 __m128i x = _mm_castpd_si128(_mm_load_sd((
const double *)&h));
120 return float4(_mm_cvtph_ps(x));
138#if defined(__KERNEL_METAL__) || defined(__KERNEL_ONEAPI__)
140#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__)
143 const int x =
__float_as_int((f > 0.0f) ? ((f < 65504.0f) ? f : 65504.0f) : 0.0f);
144 const int absolute = x & 0x7FFFFFFF;
145 const int Z =
absolute + 0xC8000000;
146 const int result = (
absolute < 0x38800000) ? 0 :
Z;
147 const int rshift = (result >> 13);
148 return (rshift & 0x7FFF);
157# ifdef __KERNEL_AVX2__
158 int4 rpack =
int4(_mm_cvtps_ph(x, 0));
164 int4 rpack =
int4(_mm_packs_epi32(rshift, rshift));
167 _mm_storel_pi((__m64 *)&h, _mm_castsi128_ps(rpack));
btMatrix3x3 absolute() const
Return the matrix with all values non negative.
half & operator=(const unsigned short &i)
half(const unsigned short &i)
#define ccl_device_inline
ccl_device_forceinline float __half2float(const half h)
#define CCL_NAMESPACE_END
draw_view in_light_buf[] float
ccl_device_inline half float_to_half_display(const float f)
ccl_device_inline half float_to_half_image(float f)
ccl_device_inline float4 half4_to_float4_image(const half4 h)
ccl_device_inline float half_to_float_image(half h)
ccl_device_inline half4 float4_to_half4_display(const float4 f)
ccl_device_inline int4 cast(const float4 a)
float half_to_float(uint16_t v)