From 96bf4aff5bd674bba5d83ab32c46024a686c1a1d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 31 Mar 2010 15:30:14 +0100 Subject: [PATCH] util: Put the format pack/unpack functions in the description table. --- progs/gallium/unit/u_format_test.c | 45 +- src/gallium/auxiliary/Makefile | 6 +- src/gallium/auxiliary/SConscript | 7 - src/gallium/auxiliary/util/.gitignore | 1 - src/gallium/auxiliary/util/u_format.h | 17 + src/gallium/auxiliary/util/u_format_access.py | 2 +- src/gallium/auxiliary/util/u_format_pack.py | 389 ++++++++---------- src/gallium/auxiliary/util/u_format_table.py | 36 +- 8 files changed, 245 insertions(+), 258 deletions(-) diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c index 303f4fa4999..e96f0a9d12d 100644 --- a/progs/gallium/unit/u_format_test.c +++ b/progs/gallium/unit/u_format_test.c @@ -31,17 +31,17 @@ #include "util/u_format.h" #include "util/u_format_tests.h" -#include "util/u_format_pack.h" static boolean -test_format_unpack_4f(const struct util_format_test_case *test) +test_format_unpack_float(const struct util_format_description *format_desc, + const struct util_format_test_case *test) { float unpacked[4]; unsigned i; boolean success; - util_format_unpack_4f(test->format, unpacked, test->packed, 1); + format_desc->unpack_float(unpacked, test->packed, 1); success = TRUE; for (i = 0; i < 4; ++i) @@ -58,7 +58,8 @@ test_format_unpack_4f(const struct util_format_test_case *test) static boolean -test_format_pack_4f(const struct util_format_test_case *test) +test_format_pack_float(const struct util_format_description *format_desc, + const struct util_format_test_case *test) { float unpacked[4]; uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; @@ -70,7 +71,7 @@ test_format_pack_4f(const struct util_format_test_case *test) for (i = 0; i < 4; ++i) unpacked[i] = (float) test->unpacked[i]; - util_format_pack_4f(test->format, packed, unpacked, 1); + format_desc->pack_float(packed, unpacked, 1); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) @@ -96,7 +97,7 @@ test_format_pack_4f(const struct util_format_test_case *test) static boolean -convert_4f_to_4ub(uint8_t *dst, const double *src) +convert_float_to_8unorm(uint8_t *dst, const double *src) { unsigned i; boolean accurate = TRUE; @@ -120,16 +121,17 @@ convert_4f_to_4ub(uint8_t *dst, const double *src) static boolean -test_format_unpack_4ub(const struct util_format_test_case *test) +test_format_unpack_8unorm(const struct util_format_description *format_desc, + const struct util_format_test_case *test) { uint8_t unpacked[4]; uint8_t expected[4]; unsigned i; boolean success; - util_format_unpack_4ub(test->format, unpacked, test->packed, 1); + format_desc->unpack_8unorm(unpacked, test->packed, 1); - convert_4f_to_4ub(expected, test->unpacked); + convert_float_to_8unorm(expected, test->unpacked); success = TRUE; for (i = 0; i < 4; ++i) @@ -146,14 +148,15 @@ test_format_unpack_4ub(const struct util_format_test_case *test) static boolean -test_format_pack_4ub(const struct util_format_test_case *test) +test_format_pack_8unorm(const struct util_format_description *format_desc, + const struct util_format_test_case *test) { uint8_t unpacked[4]; uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; unsigned i; boolean success; - if (!convert_4f_to_4ub(unpacked, test->unpacked)) { + if (!convert_float_to_8unorm(unpacked, test->unpacked)) { /* * Skip test cases which cannot be represented by four unorm bytes. */ @@ -162,7 +165,7 @@ test_format_pack_4ub(const struct util_format_test_case *test) memset(packed, 0, sizeof packed); - util_format_pack_4ub(test->format, packed, unpacked, 1); + format_desc->pack_8unorm(packed, unpacked, 1); success = TRUE; for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) @@ -188,7 +191,8 @@ test_format_pack_4ub(const struct util_format_test_case *test) typedef boolean -(*test_func_t)(const struct util_format_test_case *test); +(*test_func_t)(const struct util_format_description *format_desc, + const struct util_format_test_case *test); static boolean @@ -200,14 +204,15 @@ test_one(test_func_t func, const char *suffix) for (i = 0; i < util_format_nr_test_cases; ++i) { const struct util_format_test_case *test = &util_format_test_cases[i]; + const struct util_format_description *format_desc; + format_desc = util_format_description(test->format); + if (test->format != last_format) { - const struct util_format_description *format_desc; - format_desc = util_format_description(test->format); printf("Testing util_format_%s_%s ...\n", format_desc->short_name, suffix); last_format = test->format; } - if (!func(&util_format_test_cases[i])) + if (!func(format_desc, &util_format_test_cases[i])) success = FALSE; } @@ -220,16 +225,16 @@ test_all(void) { bool success = TRUE; - if (!test_one(&test_format_pack_4f, "pack_4f")) + if (!test_one(&test_format_pack_float, "pack_float")) success = FALSE; - if (!test_one(&test_format_unpack_4f, "unpack_4f")) + if (!test_one(&test_format_unpack_float, "unpack_float")) success = FALSE; - if (!test_one(&test_format_pack_4ub, "pack_4ub")) + if (!test_one(&test_format_pack_8unorm, "pack_8unorm")) success = FALSE; - if (!test_one(&test_format_unpack_4ub, "unpack_4ub")) + if (!test_one(&test_format_unpack_8unorm, "unpack_8unorm")) success = FALSE; return success; diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 1b75915ff2d..903c5a331ce 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -168,7 +168,6 @@ GENERATED_SOURCES = \ indices/u_indices_gen.c \ indices/u_unfilled_gen.c \ util/u_format_access.c \ - util/u_format_pack.h \ util/u_format_table.c @@ -192,12 +191,9 @@ indices/u_indices_gen.c: indices/u_indices_gen.py indices/u_unfilled_gen.c: indices/u_unfilled_gen.py python $< > $@ -util/u_format_table.c: util/u_format_table.py util/u_format_parse.py util/u_format.csv +util/u_format_table.c: util/u_format_table.py util/u_format_pack.py util/u_format_parse.py util/u_format.csv python util/u_format_table.py util/u_format.csv > $@ -util/u_format_pack.h: util/u_format_pack.py util/u_format_parse.py util/u_format.csv - python util/u_format_pack.py util/u_format.csv > $@ - util/u_format_access.c: util/u_format_access.py util/u_format_parse.py util/u_format.csv python util/u_format_access.py util/u_format.csv > $@ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 8cf13fc293d..772ab415235 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -30,13 +30,6 @@ env.CodeGenerate( command = 'python $SCRIPT $SOURCE > $TARGET' ) -env.CodeGenerate( - target = File('util/u_format_pack.h').srcnode(), - script = 'util/u_format_pack.py', - source = ['util/u_format.csv'], - command = 'python $SCRIPT $SOURCE > $TARGET' -) - env.CodeGenerate( target = 'util/u_format_access.c', script = 'util/u_format_access.py', diff --git a/src/gallium/auxiliary/util/.gitignore b/src/gallium/auxiliary/util/.gitignore index 448d2f304fb..29c586c9b51 100644 --- a/src/gallium/auxiliary/util/.gitignore +++ b/src/gallium/auxiliary/util/.gitignore @@ -1,3 +1,2 @@ u_format_access.c u_format_table.c -u_format_pack.h diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 4d59b9927d3..609d398ebfc 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -189,6 +189,23 @@ struct util_format_description * Colorspace transformation. */ enum util_format_colorspace colorspace; + + /** + * Accessor functions. + */ + + void + (*unpack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks); + + void + (*pack_8unorm)(uint8_t *dst, const uint8_t *src, unsigned nr_blocks); + + void + (*unpack_float)(float *dst, const uint8_t *src, unsigned nr_blocks); + + void + (*pack_float)(uint8_t *dst, const float *src, unsigned nr_blocks); + }; diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index a5cb67f7e4d..c85f5386261 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -317,7 +317,7 @@ def main(): print print '#include "pipe/p_compiler.h"' print '#include "u_math.h"' - print '#include "u_format_pack.h"' + print '#include "u_format.h"' print generate_srgb_tables() diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index e156b30203f..28a9dad60ea 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -304,114 +304,116 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to unpack pixels from a particular format''' - assert format.layout == PLAIN - name = format.short_name() - src_native_type = native_type(format) - print 'static INLINE void' print 'util_format_%s_unpack_%s(%s *dst, const uint8_t *src, unsigned length)' % (name, dst_suffix, dst_native_type) print '{' + + if is_format_supported(format): + + assert format.layout == PLAIN - print ' while(length--) {' + src_native_type = native_type(format) - if format.is_bitmask(): - depth = format.block_size() - print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) - - # Declare the intermediate variables - for i in range(format.nr_channels()): - src_channel = format.channels[i] - if src_channel.type == UNSIGNED: - print ' uint%u_t %s;' % (depth, src_channel.name) - elif src_channel.type == SIGNED: - print ' int%u_t %s;' % (depth, src_channel.name) - - print ' #ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth - print ' #endif' - - # Compute the intermediate unshifted values - shift = 0 - for i in range(format.nr_channels()): - src_channel = format.channels[i] - value = 'value' - if src_channel.type == UNSIGNED: - if shift: - value = '%s >> %u' % (value, shift) - if shift + src_channel.size < depth: - value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1) - elif src_channel.type == SIGNED: - if shift + src_channel.size < depth: - # Align the sign bit - lshift = depth - (shift + src_channel.size) - value = '%s << %u' % (value, lshift) - # Cast to signed - value = '(int%u_t)(%s) ' % (depth, value) - if src_channel.size < depth: - # Align the LSB bit - rshift = depth - src_channel.size - value = '(%s) >> %u' % (value, rshift) - else: - value = None - - if value is not None: - print ' %s = %s;' % (src_channel.name, value) - - shift += src_channel.size - - # Convert, swizzle, and store final values - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - src_channel = format.channels[swizzle] - value = src_channel.name - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - elif swizzle == SWIZZLE_0: - value = '0' - elif swizzle == SWIZZLE_1: - value = get_one(dst_channel) - elif swizzle == SWIZZLE_NONE: - value = '0' - else: - assert False - if format.colorspace == ZS: - if i == 3: + print ' while(length--) {' + + if format.is_bitmask(): + depth = format.block_size() + print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) + + # Declare the intermediate variables + for i in range(format.nr_channels()): + src_channel = format.channels[i] + if src_channel.type == UNSIGNED: + print ' uint%u_t %s;' % (depth, src_channel.name) + elif src_channel.type == SIGNED: + print ' int%u_t %s;' % (depth, src_channel.name) + + print ' #ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print ' #endif' + + # Compute the intermediate unshifted values + shift = 0 + for i in range(format.nr_channels()): + src_channel = format.channels[i] + value = 'value' + if src_channel.type == UNSIGNED: + if shift: + value = '%s >> %u' % (value, shift) + if shift + src_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1) + elif src_channel.type == SIGNED: + if shift + src_channel.size < depth: + # Align the sign bit + lshift = depth - (shift + src_channel.size) + value = '%s << %u' % (value, lshift) + # Cast to signed + value = '(int%u_t)(%s) ' % (depth, value) + if src_channel.size < depth: + # Align the LSB bit + rshift = depth - src_channel.size + value = '(%s) >> %u' % (value, rshift) + else: + value = None + + if value is not None: + print ' %s = %s;' % (src_channel.name, value) + + shift += src_channel.size + + # Convert, swizzle, and store final values + for i in range(4): + swizzle = format.swizzles[i] + if swizzle < 4: + src_channel = format.channels[swizzle] + value = src_channel.name + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: value = get_one(dst_channel) - elif i >= 1: - value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = 'dst[0]' + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + else: + print ' union util_format_%s pixel;' % format.short_name() + print ' memcpy(&pixel, src, sizeof pixel);' + bswap_format(format) - else: - print ' union util_format_%s pixel;' % format.short_name() - print ' memcpy(&pixel, src, sizeof pixel);' - bswap_format(format) - - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - src_channel = format.channels[swizzle] - value = 'pixel.chan.%s' % src_channel.name - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - elif swizzle == SWIZZLE_0: - value = '0' - elif swizzle == SWIZZLE_1: - value = get_one(dst_channel) - elif swizzle == SWIZZLE_NONE: - value = '0' - else: - assert False - if format.colorspace == ZS: - if i == 3: + for i in range(4): + swizzle = format.swizzles[i] + if swizzle < 4: + src_channel = format.channels[swizzle] + value = 'pixel.chan.%s' % src_channel.name + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: value = get_one(dst_channel) - elif i >= 1: - value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) - - print ' src += %u;' % (format.block_size() / 8,) - print ' dst += 4;' - print ' }' + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = 'dst[0]' + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + print ' src += %u;' % (format.block_size() / 8,) + print ' dst += 4;' + print ' }' print '}' print @@ -422,26 +424,63 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): name = format.short_name() - dst_native_type = native_type(format) - - assert format.layout == PLAIN - - inv_swizzle = format.inv_swizzles() - print 'static INLINE void' print 'util_format_%s_pack_%s(uint8_t *dst, const %s *src, unsigned length)' % (name, src_suffix, src_native_type) print '{' - print ' while(length--) {' - - if format.is_bitmask(): - depth = format.block_size() - print ' uint%u_t value = 0;' % depth - - shift = 0 - for i in range(4): - dst_channel = format.channels[i] - if inv_swizzle[i] is not None: + if is_format_supported(format): + dst_native_type = native_type(format) + + assert format.layout == PLAIN + + inv_swizzle = format.inv_swizzles() + + print ' while(length--) {' + + if format.is_bitmask(): + depth = format.block_size() + print ' uint%u_t value = 0;' % depth + + shift = 0 + for i in range(4): + dst_channel = format.channels[i] + if inv_swizzle[i] is not None: + value ='src[%u]' % inv_swizzle[i] + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = '0' + if dst_channel.type in (UNSIGNED, SIGNED): + if shift + dst_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1) + if shift: + value = '(%s) << %u' % (value, shift) + if dst_channel.type == SIGNED: + # Cast to unsigned + value = '(uint%u_t)(%s) ' % (depth, value) + else: + value = None + if value is not None: + print ' value |= %s;' % (value) + + shift += dst_channel.size + + print '#ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print '#endif' + + print ' *(uint%u_t *)dst = value;' % depth + + else: + print ' union util_format_%s pixel;' % format.short_name() + + for i in range(4): + dst_channel = format.channels[i] + width = dst_channel.size + if inv_swizzle[i] is None: + continue value ='src[%u]' % inv_swizzle[i] value = conversion_expr(src_channel, dst_channel, dst_native_type, value) if format.colorspace == ZS: @@ -449,50 +488,14 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): value = get_one(dst_channel) elif i >= 1: value = '0' - if dst_channel.type in (UNSIGNED, SIGNED): - if shift + dst_channel.size < depth: - value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1) - if shift: - value = '(%s) << %u' % (value, shift) - if dst_channel.type == SIGNED: - # Cast to unsigned - value = '(uint%u_t)(%s) ' % (depth, value) - else: - value = None - if value is not None: - print ' value |= %s;' % (value) - - shift += dst_channel.size - - print '#ifdef PIPE_ARCH_BIG_ENDIAN' - print ' value = util_bswap%u(value);' % depth - print '#endif' - - print ' *(uint%u_t *)dst = value;' % depth - - else: - print ' union util_format_%s pixel;' % format.short_name() - - for i in range(4): - dst_channel = format.channels[i] - width = dst_channel.size - if inv_swizzle[i] is None: - continue - value ='src[%u]' % inv_swizzle[i] - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - if format.colorspace == ZS: - if i == 3: - value = get_one(dst_channel) - elif i >= 1: - value = '0' - print ' pixel.chan.%s = %s;' % (dst_channel.name, value) - - bswap_format(format) - print ' memcpy(dst, &pixel, sizeof pixel);' + print ' pixel.chan.%s = %s;' % (dst_channel.name, value) - print ' src += 4;' - print ' dst += %u;' % (format.block_size() / 8,) - print ' }' + bswap_format(format) + print ' memcpy(dst, &pixel, sizeof pixel);' + + print ' src += 4;' + print ' dst += %u;' % (format.block_size() / 8,) + print ' }' print '}' print @@ -502,67 +505,17 @@ def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix): '''Generate the dispatch function to unpack pixels from any format''' for format in formats: - if is_format_supported(format): - generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix) - - print 'static INLINE void' - print 'util_format_unpack_%s(enum pipe_format format, %s *dst, const uint8_t *src, unsigned length)' % (dst_suffix, dst_native_type) - print '{' - print ' void (*func)(%s *dst, const uint8_t *src, unsigned length);' % dst_native_type - print ' switch(format) {' - for format in formats: - if is_format_supported(format): - print ' case %s:' % format.name - print ' func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix) - print ' break;' - print ' default:' - print ' debug_printf("unsupported format\\n");' - print ' return;' - print ' }' - print ' func(dst, src, length);' - print '}' - print + generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix) def generate_pack(formats, src_channel, src_native_type, src_suffix): '''Generate the dispatch function to pack pixels to any format''' for format in formats: - if is_format_supported(format): - generate_format_pack(format, src_channel, src_native_type, src_suffix) - - print 'static INLINE void' - print 'util_format_pack_%s(enum pipe_format format, uint8_t *dst, const %s *src, unsigned length)' % (src_suffix, src_native_type) - print '{' - print ' void (*func)(uint8_t *dst, const %s *src, unsigned length);' % (src_native_type,) - print ' switch(format) {' - for format in formats: - if is_format_supported(format): - print ' case %s:' % format.name - print ' func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix) - print ' break;' - print ' default:' - print ' debug_printf("%s: unsupported format\\n", __FUNCTION__);' - print ' return;' - print ' }' - print ' func(dst, src, length);' - print '}' - print - + generate_format_pack(format, src_channel, src_native_type, src_suffix) -def main(): - formats = [] - for arg in sys.argv[1:]: - formats.extend(parse(arg)) - print '/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */' - print - # This will print the copyright message on the top of this file - print __doc__.strip() - - print - print '#ifndef U_FORMAT_PACK_H' - print '#define U_FORMAT_PACK_H' +def generate(formats): print print '#include "pipe/p_compiler.h"' print '#include "u_math.h"' @@ -572,30 +525,20 @@ def main(): generate_clamp() for format in formats: - if format.layout == PLAIN: + if is_format_supported(format): generate_format_type(format) channel = Channel(FLOAT, False, 32) native_type = 'float' - suffix = '4f' + suffix = 'float' generate_unpack(formats, channel, native_type, suffix) generate_pack(formats, channel, native_type, suffix) channel = Channel(UNSIGNED, True, 8) native_type = 'uint8_t' - suffix = '4ub' + suffix = '8unorm' generate_unpack(formats, channel, native_type, suffix) generate_pack(formats, channel, native_type, suffix) - print - print '#ifdef __cplusplus' - print '}' - print '#endif' - print - print '#endif /* ! U_FORMAT_PACK_H */' - - -if __name__ == '__main__': - main() diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index fb68852a530..fe910d9a772 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -33,6 +33,7 @@ import sys from u_format_parse import * +import u_format_pack def layout_map(layout): @@ -86,6 +87,27 @@ def write_format_table(formats): print print '#include "u_format.h"' print + print ''' +static void +util_format_none_unpack_8unorm(uint8_t *dst, const uint8_t *src, unsigned length) +{ +} + +static void +util_format_none_pack_8unorm(uint8_t *dst, const uint8_t *src, unsigned length) +{ +} + +static void +util_format_none_unpack_float(float *dst, const uint8_t *src, unsigned length) +{ +} + +static void +util_format_none_pack_float(uint8_t *dst, const float *src, unsigned length) +{ +} + ''' print 'const struct util_format_description' print 'util_format_none_description = {' print " PIPE_FORMAT_NONE," @@ -99,9 +121,16 @@ def write_format_table(formats): print " 0," print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," print " {0, 0, 0, 0}," - print " 0" + print " 0," + print " &util_format_none_unpack_8unorm," + print " &util_format_none_pack_8unorm," + print " &util_format_none_unpack_float," + print " &util_format_none_pack_float" print "};" print + + u_format_pack.generate(formats) + for format in formats: print 'const struct util_format_description' print 'util_format_%s_description = {' % (format.short_name(),) @@ -140,8 +169,13 @@ def write_format_table(formats): print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) print " }," print " %s," % (colorspace_map(format.colorspace),) + print " &util_format_%s_unpack_8unorm," % format.short_name() + print " &util_format_%s_pack_8unorm," % format.short_name() + print " &util_format_%s_unpack_float," % format.short_name() + print " &util_format_%s_pack_float" % format.short_name() print "};" print + print "const struct util_format_description *" print "util_format_description(enum pipe_format format)" print "{" -- 2.30.2