pan/genxml: Switch __gen_unpack to macros
This switch all __gen_unpack functions to macros to keep address space information when working with OpenCL C. 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:

committed by
Marge Bot

parent
3f3bb741fb
commit
bacc5f4579
@@ -433,6 +433,7 @@ class Group(object):
|
||||
convert = None
|
||||
|
||||
args = []
|
||||
args.append('(__unpacked)->{}'.format(fieldref.path))
|
||||
args.append('&__tmp_packed.opaque[0]')
|
||||
args.append(str(fieldref.start))
|
||||
args.append(str(fieldref.end))
|
||||
@@ -440,7 +441,7 @@ class Group(object):
|
||||
if field.type in set(["uint", "hex", "uint/float", "address", "Pixel Format", "Component Swizzle"]):
|
||||
convert = "__gen_unpack_uint"
|
||||
elif field.type in self.parser.enums:
|
||||
convert = "(enum %s)__gen_unpack_uint" % enum_name(field.type)
|
||||
convert = "__gen_unpack_uint"
|
||||
elif field.type == "int":
|
||||
convert = "__gen_unpack_sint"
|
||||
elif field.type == "padded":
|
||||
@@ -466,9 +467,12 @@ class Group(object):
|
||||
if field.modifier[0] == "log2":
|
||||
prefix = "1U << "
|
||||
|
||||
decoded = '{}{}({}){}'.format(prefix, convert, ', '.join(args), suffix)
|
||||
print(' {}({}); \\'.format(convert, ', '.join(args)))
|
||||
|
||||
if len(prefix) != 0 or len(suffix) != 0:
|
||||
print(' (__unpacked)->{} = {}(__unpacked)->{}{}; \\'.format(fieldref.path, prefix, fieldref.path, suffix))
|
||||
|
||||
|
||||
print(' (__unpacked)->{} = {}; \\'.format(fieldref.path, decoded))
|
||||
if field.modifier and field.modifier[0] == "align":
|
||||
mask = hex(field.modifier[1] - 1)
|
||||
print(' assert(!((__unpacked)->{} & {})); \\'.format(fieldref.path, mask))
|
||||
|
@@ -11,8 +11,6 @@
|
||||
|
||||
#include "util/bitpack_helpers.h"
|
||||
|
||||
#define __gen_unpack_float(x, y, z) uif(__gen_unpack_uint(x, y, z))
|
||||
|
||||
static inline uint32_t
|
||||
__gen_padded(uint32_t v, uint32_t start, uint32_t end)
|
||||
{
|
||||
@@ -29,55 +27,56 @@ __gen_padded(uint32_t v, uint32_t start, uint32_t end)
|
||||
return util_bitpack_uint(shift | (odd << 5), start, end);
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
__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) ? ~((uint64_t)0) : ((uint64_t)1 << width) - 1;
|
||||
#define __gen_unpack_uint(out, cl, start, end) \
|
||||
do { \
|
||||
uint64_t __val = 0; \
|
||||
const int __width = (end) - (start) + 1; \
|
||||
const uint64_t __mask = \
|
||||
(__width == 64) ? ~((uint64_t)0) : ((uint64_t)1 << __width) - 1; \
|
||||
\
|
||||
for (unsigned __word = (start) / 32; __word < ((end) / 32) + 1; \
|
||||
__word++) { \
|
||||
__val |= ((uint64_t)(cl)[__word]) << ((__word - (start) / 32) * 32); \
|
||||
} \
|
||||
\
|
||||
(out) = (__val >> ((start) % 32)) & __mask; \
|
||||
} while (0)
|
||||
|
||||
for (unsigned word = start / 32; word < (end / 32) + 1; word++) {
|
||||
val |= ((uint64_t)cl[word]) << ((word - start / 32) * 32);
|
||||
}
|
||||
#define __gen_unpack_sint(out, cl, start, end) \
|
||||
do { \
|
||||
int size = (end) - (start) + 1; \
|
||||
int64_t __tmp_sint; \
|
||||
__gen_unpack_uint(__tmp_sint, cl, start, end); \
|
||||
(out) = util_sign_extend(__tmp_sint, size); \
|
||||
} while (0)
|
||||
|
||||
return (val >> (start % 32)) & mask;
|
||||
}
|
||||
#define __gen_unpack_ulod(out, cl, start, end) \
|
||||
do { \
|
||||
uint32_t __tmp_ulod; \
|
||||
__gen_unpack_uint(__tmp_ulod, cl, start, end); \
|
||||
(out) = ((float)__tmp_ulod) / 256.0; \
|
||||
} while (0)
|
||||
|
||||
static inline uint64_t
|
||||
__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);
|
||||
#define __gen_unpack_slod(out, cl, start, end) \
|
||||
do { \
|
||||
int32_t __tmp_slod; \
|
||||
__gen_unpack_sint(__tmp_slod, cl, start, end); \
|
||||
(out) = ((float)__tmp_slod) / 256.0; \
|
||||
} while (0)
|
||||
|
||||
return util_sign_extend(val, size);
|
||||
}
|
||||
#define __gen_unpack_float(out, cl, start, end) \
|
||||
do { \
|
||||
uint32_t __tmp_float; \
|
||||
__gen_unpack_uint(__tmp_float, cl, start, end); \
|
||||
(out) = uif(__tmp_float); \
|
||||
} while (0)
|
||||
|
||||
static inline float
|
||||
__gen_unpack_ulod(const uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
uint32_t u = __gen_unpack_uint(cl, start, end);
|
||||
|
||||
return ((float)u) / 256.0;
|
||||
}
|
||||
|
||||
static inline float
|
||||
__gen_unpack_slod(const uint32_t *restrict cl, uint32_t start, uint32_t end)
|
||||
{
|
||||
int32_t u = __gen_unpack_sint(cl, start, end);
|
||||
|
||||
return ((float)u) / 256.0;
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
__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;
|
||||
unsigned odd = val >> 5;
|
||||
|
||||
return (2 * odd + 1) << shift;
|
||||
}
|
||||
#define __gen_unpack_padded(out, cl, start, end) \
|
||||
do { \
|
||||
uint32_t __tmp_padded; \
|
||||
__gen_unpack_uint(__tmp_padded, cl, start, end); \
|
||||
(out) = (2 * (__tmp_padded >> 5) + 1) << (__tmp_padded & 0b11111); \
|
||||
} while (0)
|
||||
|
||||
#define PREFIX1(A) MALI_##A
|
||||
#define PREFIX2(A, B) MALI_##A##_##B
|
||||
|
Reference in New Issue
Block a user