mesa: Reuse util_format's unpack functions for pure integer formats.
Drops 5k of compiled text from all GL drivers. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6297>
This commit is contained in:
@@ -43,9 +43,12 @@ extern void
|
||||
_mesa_unpack_ubyte_rgba_row(mesa_format format, uint32_t n,
|
||||
const void *src, uint8_t dst[][4]);
|
||||
|
||||
void
|
||||
static inline void
|
||||
_mesa_unpack_uint_rgba_row(mesa_format format, uint32_t n,
|
||||
const void *src, uint32_t dst[][4]);
|
||||
const void *src, uint32_t dst[][4])
|
||||
{
|
||||
util_format_unpack_rgba(format, dst, src, n);
|
||||
}
|
||||
|
||||
extern void
|
||||
_mesa_unpack_rgba_block(mesa_format format,
|
||||
|
||||
@@ -68,78 +68,6 @@ for f in formats:
|
||||
rgb_formats.append(f)
|
||||
%>
|
||||
|
||||
/* integer packing functions */
|
||||
|
||||
%for f in rgb_formats:
|
||||
%if not f.is_int():
|
||||
<% continue %>
|
||||
%elif f.is_normalized():
|
||||
<% continue %>
|
||||
%endif
|
||||
|
||||
static inline void
|
||||
unpack_int_${f.short_name()}(const void *void_src, uint32_t dst[4])
|
||||
{
|
||||
${f.datatype()} *src = (${f.datatype()} *)void_src;
|
||||
%if f.layout == parser.PACKED:
|
||||
%for c in f.channels:
|
||||
%if c.type != 'x':
|
||||
${c.datatype()} ${c.name} = UNPACK(*src, ${c.shift}, ${c.size});
|
||||
%endif
|
||||
%endfor
|
||||
%elif f.layout == parser.ARRAY:
|
||||
%for (i, c) in enumerate(f.channels):
|
||||
%if c.type != 'x':
|
||||
${c.datatype()} ${c.name} = src[${i}];
|
||||
%endif
|
||||
%endfor
|
||||
%else:
|
||||
<% assert False %>
|
||||
%endif
|
||||
|
||||
%for i in range(4):
|
||||
<% s = f.swizzle[i] %>
|
||||
%if 0 <= s and s <= parser.Swizzle.SWIZZLE_W:
|
||||
dst[${i}] = ${f.channels[s].name};
|
||||
%elif s == parser.Swizzle.SWIZZLE_ZERO:
|
||||
dst[${i}] = 0;
|
||||
%elif s == parser.Swizzle.SWIZZLE_ONE:
|
||||
dst[${i}] = 1;
|
||||
%else:
|
||||
<% assert False %>
|
||||
%endif
|
||||
%endfor
|
||||
}
|
||||
%endfor
|
||||
|
||||
|
||||
void
|
||||
_mesa_unpack_uint_rgba_row(mesa_format format, uint32_t n,
|
||||
const void *src, uint32_t dst[][4])
|
||||
{
|
||||
uint8_t *s = (uint8_t *)src;
|
||||
uint32_t i;
|
||||
|
||||
switch (format) {
|
||||
%for f in rgb_formats:
|
||||
%if not f.is_int():
|
||||
<% continue %>
|
||||
%elif f.is_normalized():
|
||||
<% continue %>
|
||||
%endif
|
||||
|
||||
case ${f.name}:
|
||||
for (i = 0; i < n; ++i) {
|
||||
unpack_int_${f.short_name()}(s, dst[i]);
|
||||
s += ${f.block_size() // 8};
|
||||
}
|
||||
break;
|
||||
%endfor
|
||||
default:
|
||||
unreachable("bad format");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
|
||||
struct z32f_x24s8
|
||||
|
||||
Reference in New Issue
Block a user