#define AGX_PACK_H
#include <stdio.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <assert.h>
-#include <math.h>
#include <inttypes.h>
-#include "util/macros.h"
-#include "util/u_math.h"
-#define __gen_unpack_float(x, y, z) uif(__gen_unpack_uint(x, y, z))
-
-static inline uint64_t
-__gen_uint(uint64_t v, uint32_t start, uint32_t end)
-{
-#ifndef NDEBUG
- const int width = end - start + 1;
- if (width < 64) {
- const uint64_t max = (1ull << width) - 1;
- assert(v <= max);
- }
-#endif
-
- return v << start;
-}
+#include "util/bitpack_helpers.h"
-static inline uint32_t
-__gen_sint(int32_t v, uint32_t start, uint32_t end)
-{
-#ifndef NDEBUG
- const int width = end - start + 1;
- if (width < 64) {
- const int64_t max = (1ll << (width - 1)) - 1;
- const int64_t min = -(1ll << (width - 1));
- assert(min <= v && v <= max);
- }
-#endif
-
- return (((uint32_t) v) << start) & ((2ll << end) - 1);
-}
+#define __gen_unpack_float(x, y, z) uif(__gen_unpack_uint(x, y, z))
static inline uint64_t
__gen_unpack_uint(const uint8_t *restrict cl, uint32_t start, uint32_t end)
* avoid undefined behaviour for out-of-bounds inputs like +/- infinity.
*/
static inline uint32_t
-__float_to_lod(float f)
+__gen_pack_lod(float f, uint32_t start, uint32_t end)
{
- return (uint32_t) CLAMP(f * (1 << 6), 0 /* 0.0 */, 0x380 /* 14.0 */);
+ uint32_t fixed = CLAMP(f * (1 << 6), 0 /* 0.0 */, 0x380 /* 14.0 */);
+ return util_bitpack_uint(fixed, start, end);
}
static inline float
value = "util_logbase2({})".format(value)
if field.type in ["uint", "hex", "Pixel Format", "address"]:
- s = "__gen_uint(%s, %d, %d)" % \
+ s = "util_bitpack_uint(%s, %d, %d)" % \
(value, start, end)
elif field.type in self.parser.enums:
- s = "__gen_uint(%s, %d, %d)" % \
+ s = "util_bitpack_uint(%s, %d, %d)" % \
(value, start, end)
elif field.type == "int":
- s = "__gen_sint(%s, %d, %d)" % \
+ s = "util_bitpack_sint(%s, %d, %d)" % \
(value, start, end)
elif field.type == "bool":
- s = "__gen_uint(%s, %d, %d)" % \
+ s = "util_bitpack_uint(%s, %d, %d)" % \
(value, start, end)
elif field.type == "float":
assert(start == 0 and end == 31)
- s = "__gen_uint(fui({}), 0, 32)".format(value)
+ s = "util_bitpack_float({})".format(value)
elif field.type == "lod":
assert(end - start + 1 == 10)
- s = "__gen_uint(__float_to_lod(%s), %d, %d)" % (value, start, end)
+ s = "__gen_pack_lod(%s, %d, %d)" % (value, start, end)
else:
s = "#error unhandled field {}, type {}".format(contributor.path, field.type)
idep_agx_pack = declare_dependency(
sources : [agx_pack],
+ dependencies : dep_valgrind,
include_directories : include_directories('.'),
)
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_asahi],
c_args : [no_override_init_args],
gnu_symbol_visibility : 'hidden',
- dependencies: [dep_libdrm, idep_nir, dep_iokit],
+ dependencies: [dep_libdrm, dep_valgrind, idep_nir, dep_iokit],
build_by_default : false,
)
'asahi_decode',
[libasahi_decode_files, agx_pack],
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_asahi],
- dependencies : idep_mesautil,
+ dependencies : [dep_valgrind, idep_mesautil],
c_args : [no_override_init_args],
gnu_symbol_visibility : 'hidden',
build_by_default : false,