util/bitpack_helpers: make partially CL safe

add enough preprocessor guards that we can include this from CL and get basic
implementations of things. FIXED packs are missing due to llroundf (probably
fixable).

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32529>
This commit is contained in:
Alyssa Rosenzweig 2024-12-04 08:58:51 -05:00 committed by Marge Bot
parent d64caf4161
commit 13a4186c96

View file

@ -24,6 +24,7 @@
#ifndef UTIL_BITPACK_HELPERS_H
#define UTIL_BITPACK_HELPERS_H
#ifndef __OPENCL_VERSION__
#include <math.h>
#include <stdbool.h>
@ -38,6 +39,9 @@
VALGRIND_CHECK_MEM_IS_DEFINED(&(x), sizeof(x))
#endif
#endif
#else
#include "compiler/libcl/libcl.h"
#endif
#ifndef util_bitpack_validate_value
#define util_bitpack_validate_value(x)
@ -115,6 +119,7 @@ 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)
@ -206,5 +211,6 @@ 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 */