mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-05 22:00:11 +01:00
pan/genxml: Switch unpack to use uint32_t
Makes this match pack. Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32962>
This commit is contained in:
parent
ab1cd917ad
commit
95435a788d
2 changed files with 12 additions and 11 deletions
|
|
@ -654,7 +654,7 @@ class Parser(object):
|
|||
|
||||
def emit_unpack_function(self, name, group):
|
||||
print("static inline void")
|
||||
print("%s_unpack(const uint8_t * restrict cl,\n%sstruct %s * restrict values)\n{" %
|
||||
print("%s_unpack(const uint32_t * restrict cl,\n%sstruct %s * restrict values)\n{" %
|
||||
(name.upper(), ' ' * (len(name) + 8), name))
|
||||
|
||||
group.emit_unpack_function()
|
||||
|
|
|
|||
|
|
@ -30,21 +30,22 @@ __gen_padded(uint32_t v, uint32_t start, uint32_t end)
|
|||
}
|
||||
|
||||
static inline uint64_t
|
||||
__gen_unpack_uint(const uint8_t *restrict cl, uint32_t start, uint32_t end)
|
||||
__gen_unpack_uint(const uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
uint64_t val = 0;
|
||||
const int width = end - start + 1;
|
||||
const uint64_t mask = (width == 64 ? ~0 : (1ull << width) - 1);
|
||||
const uint64_t mask =
|
||||
(width == 64) ? ~((uint64_t)0) : ((uint64_t)1 << width) - 1;
|
||||
|
||||
for (uint32_t byte = start / 8; byte <= end / 8; byte++) {
|
||||
val |= ((uint64_t)cl[byte]) << ((byte - start / 8) * 8);
|
||||
for (unsigned word = start / 32; word < (end / 32) + 1; word++) {
|
||||
val |= ((uint64_t)cl[word]) << ((word - start / 32) * 32);
|
||||
}
|
||||
|
||||
return (val >> (start % 8)) & mask;
|
||||
return (val >> (start % 32)) & mask;
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
__gen_unpack_sint(const uint8_t *restrict cl, uint32_t start, uint32_t end)
|
||||
__gen_unpack_sint(const uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
int size = end - start + 1;
|
||||
int64_t val = __gen_unpack_uint(cl, start, end);
|
||||
|
|
@ -53,7 +54,7 @@ __gen_unpack_sint(const uint8_t *restrict cl, uint32_t start, uint32_t end)
|
|||
}
|
||||
|
||||
static inline float
|
||||
__gen_unpack_ulod(const uint8_t *restrict cl, uint32_t start, uint32_t end)
|
||||
__gen_unpack_ulod(const uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
uint32_t u = __gen_unpack_uint(cl, start, end);
|
||||
|
||||
|
|
@ -61,7 +62,7 @@ __gen_unpack_ulod(const uint8_t *restrict cl, uint32_t start, uint32_t end)
|
|||
}
|
||||
|
||||
static inline float
|
||||
__gen_unpack_slod(const uint8_t *restrict cl, uint32_t start, uint32_t end)
|
||||
__gen_unpack_slod(const uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
int32_t u = __gen_unpack_sint(cl, start, end);
|
||||
|
||||
|
|
@ -69,7 +70,7 @@ __gen_unpack_slod(const uint8_t *restrict cl, uint32_t start, uint32_t end)
|
|||
}
|
||||
|
||||
static inline uint64_t
|
||||
__gen_unpack_padded(const uint8_t *restrict cl, uint32_t start, uint32_t end)
|
||||
__gen_unpack_padded(const uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
unsigned val = __gen_unpack_uint(cl, start, end);
|
||||
unsigned shift = val & 0b11111;
|
||||
|
|
@ -99,7 +100,7 @@ __gen_unpack_padded(const uint8_t *restrict cl, uint32_t start, uint32_t end)
|
|||
|
||||
#define pan_unpack(src, T, name) \
|
||||
struct PREFIX1(T) name; \
|
||||
PREFIX2(T, unpack)((uint8_t *)(src), &name)
|
||||
PREFIX2(T, unpack)((uint32_t *)(src), &name)
|
||||
|
||||
#define pan_print(fp, T, var, indent) PREFIX2(T, print)(fp, &(var), indent)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue