util: Move fetch_rgba to a separate function table.

Only llvmpipe and translate_generic use it, and only in fallbacks, so if
you're not building that then let's not bloat our binaries with it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6305>
This commit is contained in:
Eric Anholt
2020-08-13 09:37:32 -07:00
committed by Marge Bot
parent 9cc84369b7
commit 5b8d67cb64
7 changed files with 61 additions and 34 deletions
+10 -8
View File
@@ -345,14 +345,6 @@ struct util_format_unpack_description {
const uint8_t *src, unsigned src_stride,
unsigned width, unsigned height);
/**
* Fetch a single pixel (i, j) from a block.
*
* Only defined for non-depth-stencil and non-integer formats.
*/
void
(*fetch_rgba)(void *dst, const uint8_t *src, unsigned i, unsigned j);
/**
* Unpack pixels to Z32_UNORM.
* Note: strides are in bytes.
@@ -387,6 +379,9 @@ struct util_format_unpack_description {
unsigned width, unsigned height);
};
typedef void (*util_format_fetch_rgba_func_ptr)(void *dst, const uint8_t *src,
unsigned i, unsigned j);
const struct util_format_description *
util_format_description(enum pipe_format format) ATTRIBUTE_CONST;
@@ -396,6 +391,13 @@ util_format_pack_description(enum pipe_format format) ATTRIBUTE_CONST;
const struct util_format_unpack_description *
util_format_unpack_description(enum pipe_format format) ATTRIBUTE_CONST;
/**
* Returns a function to fetch a single pixel (i, j) from a block.
*
* Only defined for non-depth-stencil and non-integer formats.
*/
util_format_fetch_rgba_func_ptr
util_format_fetch_rgba_func(enum pipe_format format) ATTRIBUTE_CONST;
/*
* Format query functions.
+25 -2
View File
@@ -174,6 +174,17 @@ def write_format_table(formats):
print("}")
print()
def generate_function_getter(func):
print("util_format_%s_func_ptr" % func)
print("util_format_%s_func(enum pipe_format format)" % (func))
print("{")
print(" if (format >= ARRAY_SIZE(util_format_%s_table))" % (func))
print(" return NULL;")
print()
print(" return util_format_%s_table[format];" % (func))
print("}")
print()
print('static const struct util_format_description')
print('util_format_descriptions[] = {')
for format in formats:
@@ -240,8 +251,6 @@ def write_format_table(formats):
continue
print(" [%s] = {" % (format.name,))
if format.colorspace != ZS:
print(" .fetch_rgba = &util_format_%s_fetch_rgba," % sn)
if format.colorspace != ZS and not format.is_pure_color():
print(" .unpack_rgba_8unorm = &util_format_%s_unpack_rgba_8unorm," % sn)
@@ -266,6 +275,20 @@ def write_format_table(formats):
generate_table_getter("unpack_")
print('static const util_format_fetch_rgba_func_ptr util_format_fetch_rgba_table[] = {')
for format in formats:
sn = format.short_name()
if format.colorspace != ZS and has_access(format):
print(" [%s] = &util_format_%s_fetch_rgba," % (format.name, sn))
else:
print(" [%s] = NULL," % format.name)
print("};")
print()
generate_function_getter("fetch_rgba")
def main():
formats = []