panfrost: Use util/bitpack_helpers.h
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18062>
This commit is contained in:

committed by
Marge Bot

parent
4fab5ae8ba
commit
2917e849b0
@@ -42,45 +42,12 @@ pack_header = """
|
||||
#define PAN_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"
|
||||
|
||||
#include "util/bitpack_helpers.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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
__gen_padded(uint32_t v, uint32_t start, uint32_t end)
|
||||
{
|
||||
@@ -94,7 +61,7 @@ __gen_padded(uint32_t v, uint32_t start, uint32_t end)
|
||||
assert((end - start + 1) == 8);
|
||||
#endif
|
||||
|
||||
return __gen_uint(shift | (odd << 5), start, end);
|
||||
return util_bitpack_uint(shift | (odd << 5), start, end);
|
||||
}
|
||||
|
||||
|
||||
@@ -536,23 +503,23 @@ class Group(object):
|
||||
value = "util_logbase2({})".format(value)
|
||||
|
||||
if field.type in ["uint", "hex", "uint/float", "address", "Pixel Format"]:
|
||||
s = "__gen_uint(%s, %d, %d)" % \
|
||||
s = "util_bitpack_uint(%s, %d, %d)" % \
|
||||
(value, start, end)
|
||||
elif field.type == "padded":
|
||||
s = "__gen_padded(%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)
|
||||
else:
|
||||
s = "#error unhandled field {}, type {}".format(contributor.path, field.type)
|
||||
|
||||
|
Reference in New Issue
Block a user