diff --git a/src/compiler/libcl/libcl.h b/src/compiler/libcl/libcl.h index a20d6e6fbb5..265c863c278 100644 --- a/src/compiler/libcl/libcl.h +++ b/src/compiler/libcl/libcl.h @@ -210,6 +210,19 @@ uif(uint32_t ui) return as_float(ui); } +#define CL_FLT_EPSILON 1.1920928955078125e-7f + +/* OpenCL C lacks roundf and llroundf, we can emulate it */ +static inline float roundf(float x) +{ + return trunc(x + copysign(0.5f - 0.25f * CL_FLT_EPSILON, x)); +} + +static inline long long llroundf(float x) +{ + return roundf(x); +} + static inline uint16_t _mesa_float_to_half(float f) { diff --git a/src/util/bitpack_helpers.h b/src/util/bitpack_helpers.h index 25f3045ab49..bb1a094da47 100644 --- a/src/util/bitpack_helpers.h +++ b/src/util/bitpack_helpers.h @@ -119,7 +119,6 @@ util_bitpack_float_nonzero(float v) return util_bitpack_float(v); } -#ifndef __OPENCL_VERSION__ ALWAYS_INLINE static uint64_t util_bitpack_sfixed(float v, uint32_t start, uint32_t end, uint32_t fract_bits) @@ -211,6 +210,5 @@ util_bitpack_ufixed_nonzero(float v, uint32_t start, uint32_t end, assert(v != 0.0f); return util_bitpack_ufixed(v, start, end, fract_bits); } -#endif #endif /* UTIL_BITPACK_HELPERS_H */