From 5dce9b252b65102ed69956fdd47862d5cb1c4af1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 23 Feb 2010 19:51:42 +0000 Subject: util: Store more derived data in the the format description. --- src/gallium/auxiliary/util/u_format_table.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 571cab55dc..05e176d567 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -94,6 +94,9 @@ def write_format_table(formats): print " \"PIPE_FORMAT_NONE\"," print " {0, 0, 0}," print " 0," + print " 0," + print " 0," + print " 0," print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," print " {0, 0, 0, 0}," print " 0" @@ -104,6 +107,9 @@ def write_format_table(formats): print " \"%s\"," % (format.name,) print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) print " %s," % (layout_map(format.layout),) + print " %u,\t/* nr_channels */" % (format.nr_channels(),) + print " %s,\t/* is_array */" % (bool_map(format.is_array()),) + print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) print " {" for i in range(4): type = format.in_types[i] -- cgit v1.2.3 From 3c45c4bc44310c1af4f0c06d29eb0a9d39a38837 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 15:11:28 +0000 Subject: util: Cope with the fact that formats in u_format.csv are not ordered. --- src/gallium/auxiliary/Makefile | 1 - src/gallium/auxiliary/SConscript | 1 - src/gallium/auxiliary/util/u_format.c | 45 ----------------- src/gallium/auxiliary/util/u_format_table.py | 75 +++++++++++++++++----------- 4 files changed, 47 insertions(+), 75 deletions(-) delete mode 100644 src/gallium/auxiliary/util/u_format.c (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 916f5f6c91..2d41fb3dca 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -105,7 +105,6 @@ C_SOURCES = \ util/u_cpu_detect.c \ util/u_dl.c \ util/u_draw_quad.c \ - util/u_format.c \ util/u_format_access.c \ util/u_format_table.c \ util/u_gen_mipmap.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index b531ad2dbd..8d2859fa71 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -140,7 +140,6 @@ source = [ 'util/u_dump_state.c', 'util/u_dl.c', 'util/u_draw_quad.c', - 'util/u_format.c', 'util/u_format_access.c', 'util/u_format_table.c', 'util/u_gen_mipmap.c', diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c deleted file mode 100644 index e0724a1a8b..0000000000 --- a/src/gallium/auxiliary/util/u_format.c +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 Vmware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#include "u_format.h" - - -const struct util_format_description * -util_format_description(enum pipe_format format) -{ - const struct util_format_description *desc; - - if (format >= PIPE_FORMAT_COUNT) { - return NULL; - } - - desc = &util_format_description_table[format]; - assert(desc->format == format); - - return desc; -} diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 05e176d567..3d0e3a0349 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -87,39 +87,39 @@ def write_format_table(formats): print '#include "u_format.h"' print print 'const struct util_format_description' - print 'util_format_description_table[] = ' - print "{" - print " {" - print " PIPE_FORMAT_NONE," - print " \"PIPE_FORMAT_NONE\"," - print " {0, 0, 0}," - print " 0," - print " 0," - print " 0," - print " 0," - print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," - print " {0, 0, 0, 0}," - print " 0" - print " }," + print 'util_format_none_description = {' + print " PIPE_FORMAT_NONE," + print " \"PIPE_FORMAT_NONE\"," + print " {0, 0, 0}," + print " 0," + print " 0," + print " 0," + print " 0," + print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," + print " {0, 0, 0, 0}," + print " 0" + print "};" + print for format in formats: + print 'const struct util_format_description' + print 'util_format_%s_description = {' % (format.short_name(),) + print " %s," % (format.name,) + print " \"%s\"," % (format.name,) + print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) + print " %s," % (layout_map(format.layout),) + print " %u,\t/* nr_channels */" % (format.nr_channels(),) + print " %s,\t/* is_array */" % (bool_map(format.is_array()),) + print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) print " {" - print " %s," % (format.name,) - print " \"%s\"," % (format.name,) - print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) - print " %s," % (layout_map(format.layout),) - print " %u,\t/* nr_channels */" % (format.nr_channels(),) - print " %s,\t/* is_array */" % (bool_map(format.is_array()),) - print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) - print " {" for i in range(4): type = format.in_types[i] if i < 3: sep = "," else: sep = "" - print " {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i]) - print " }," - print " {" + print " {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i]) + print " }," + print " {" for i in range(4): swizzle = format.out_swizzle[i] if i < 3: @@ -130,11 +130,30 @@ def write_format_table(formats): comment = colorspace_channels_map[format.colorspace][i] except (KeyError, IndexError): comment = 'ignored' - print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) - print " }," - print " %s," % (colorspace_map(format.colorspace),) + print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) print " }," + print " %s," % (colorspace_map(format.colorspace),) + print "};" + print + print "const struct util_format_description *" + print "util_format_description(enum pipe_format format)" + print "{" + print " if (format >= PIPE_FORMAT_COUNT) {" + print " return NULL;" + print " }" + print + print " switch (format) {" + print " case PIPE_FORMAT_NONE:" + print " return &util_format_none_description;" + for format in formats: + print " case %s:" % format.name + print " return &util_format_%s_description;" % (format.short_name(),) + print " default:" + print " assert(0);" + print " return NULL;" + print " }" print "};" + print def main(): -- cgit v1.2.3 From 31ff9b0a135bf913ae6b44868bde31534a87802c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Feb 2010 16:20:01 -0700 Subject: util: remove a trailing semicolon in format table code --- src/gallium/auxiliary/util/u_format_table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 3d0e3a0349..953b5aed87 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -152,7 +152,7 @@ def write_format_table(formats): print " assert(0);" print " return NULL;" print " }" - print "};" + print "}" print -- cgit v1.2.3 From 092010db3798f9a49ff9184bf238099af849e885 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 11:03:06 +0000 Subject: util: Use python names consistent with u_format.h --- src/gallium/auxiliary/util/u_format_access.py | 158 +++++++++++++------------- src/gallium/auxiliary/util/u_format_parse.py | 74 +++++++----- src/gallium/auxiliary/util/u_format_table.py | 8 +- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 70 ++++++------ 4 files changed, 161 insertions(+), 149 deletions(-) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index f7a92f62a8..267fb3fbbd 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -56,12 +56,12 @@ def is_format_supported(format): return False for i in range(4): - type = format.in_types[i] - if type.kind not in (VOID, UNSIGNED, FLOAT): + channel = format.channels[i] + if channel.type not in (VOID, UNSIGNED, FLOAT): return False # We can only read a color from a depth/stencil format if the depth channel is present - if format.colorspace == 'zs' and format.out_swizzle[0] == SWIZZLE_NONE: + if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE: return False return True @@ -76,15 +76,15 @@ def native_type(format): return 'uint%u_t' % format.block_size() else: # For array pixel formats return the integer type that matches the color channel - type = format.in_types[0] - if type.kind == UNSIGNED: - return 'uint%u_t' % type.size - elif type.kind == SIGNED: - return 'int%u_t' % type.size - elif type.kind == FLOAT: - if type.size == 32: + channel = format.channels[0] + if channel.type == UNSIGNED: + return 'uint%u_t' % channel.size + elif channel.type == SIGNED: + return 'int%u_t' % channel.size + elif channel.type == FLOAT: + if channel.size == 32: return 'float' - elif type.size == 64: + elif channel.size == 64: return 'double' else: assert False @@ -108,27 +108,27 @@ def intermediate_native_type(bits, sign): return 'uint%u_t' % bits -def get_one_shift(type): - '''Get the number of the bit that matches unity for this type.''' - if type.kind == 'FLOAT': +def get_one_shift(channel): + '''Get the number of the bit that matches unity for this channel.''' + if channel.type == 'FLOAT': assert False - if not type.norm: + if not channel.norm: return 0 - if type.kind == UNSIGNED: - return type.size - if type.kind == SIGNED: - return type.size - 1 - if type.kind == FIXED: - return type.size / 2 + if channel.type == UNSIGNED: + return channel.size + if channel.type == SIGNED: + return channel.size - 1 + if channel.type == FIXED: + return channel.size / 2 assert False -def get_one(type): - '''Get the value of unity for this type.''' - if type.kind == 'FLOAT' or not type.norm: +def get_one(channel): + '''Get the value of unity for this channel.''' + if channel.type == 'FLOAT' or not channel.norm: return 1 else: - return (1 << get_one_shift(type)) - 1 + return (1 << get_one_shift(channel)) - 1 def generate_clamp(): @@ -156,32 +156,32 @@ def generate_clamp(): print -def clamp_expr(src_type, dst_type, dst_native_type, value): +def clamp_expr(src_channel, dst_channel, dst_native_type, value): '''Generate the expression to clamp the value in the source type to the destination type range.''' - if src_type == dst_type: + if src_channel == dst_channel: return value # Pick the approriate clamp function - if src_type.kind == FLOAT: - if src_type.size == 32: + if src_channel.type == FLOAT: + if src_channel.size == 32: func = 'clampf' - elif src_type.size == 64: + elif src_channel.size == 64: func = 'clamp' else: assert False - elif src_type.kind == UNSIGNED: + elif src_channel.type == UNSIGNED: func = 'clampui' - elif src_type.kind == SIGNED: + elif src_channel.type == SIGNED: func = 'clampsi' else: assert False # Clamp floats to [-1, 1] or [0, 1] range - if src_type.kind == FLOAT and dst_type.norm: + if src_channel.type == FLOAT and dst_channel.norm: max = 1 - if src_type.sign and dst_type.sign: + if src_channel.sign and dst_channel.sign: min = -1 else: min = 0 @@ -192,24 +192,24 @@ def clamp_expr(src_type, dst_type, dst_native_type, value): return value -def conversion_expr(src_type, dst_type, dst_native_type, value): +def conversion_expr(src_channel, dst_channel, dst_native_type, value): '''Generate the expression to convert a value between two types.''' - if src_type == dst_type: + if src_channel == dst_channel: return value - if src_type.kind == FLOAT and dst_type.kind == FLOAT: + if src_channel.type == FLOAT and dst_channel.type == FLOAT: return '(%s)%s' % (dst_native_type, value) - if not src_type.norm and not dst_type.norm: + if not src_channel.norm and not dst_channel.norm: return '(%s)%s' % (dst_native_type, value) - value = clamp_expr(src_type, dst_type, dst_native_type, value) + value = clamp_expr(src_channel, dst_channel, dst_native_type, value) - if dst_type.kind == FLOAT: - if src_type.norm: - one = get_one(src_type) - if src_type.size <= 23: + if dst_channel.type == FLOAT: + if src_channel.norm: + one = get_one(src_channel) + if src_channel.size <= 23: scale = '(1.0f/0x%x)' % one else: # bigger than single precision mantissa, use double @@ -217,10 +217,10 @@ def conversion_expr(src_type, dst_type, dst_native_type, value): value = '(%s * %s)' % (value, scale) return '(%s)%s' % (dst_native_type, value) - if src_type.kind == FLOAT: - if dst_type.norm: - dst_one = get_one(dst_type) - if dst_type.size <= 23: + if src_channel.type == FLOAT: + if dst_channel.norm: + dst_one = get_one(dst_channel) + if dst_channel.size <= 23: scale = '0x%x' % dst_one else: # bigger than single precision mantissa, use double @@ -228,18 +228,18 @@ def conversion_expr(src_type, dst_type, dst_native_type, value): value = '(%s * %s)' % (value, scale) return '(%s)%s' % (dst_native_type, value) - if src_type.kind == dst_type.kind: - src_one = get_one(src_type) - dst_one = get_one(dst_type) + if src_channel.type == dst_channel.type: + src_one = get_one(src_channel) + dst_one = get_one(dst_channel) - if src_one > dst_one and src_type.norm and dst_type.norm: + if src_one > dst_one and src_channel.norm and dst_channel.norm: # We can just bitshift - src_shift = get_one_shift(src_type) - dst_shift = get_one_shift(dst_type) + src_shift = get_one_shift(src_channel) + dst_shift = get_one_shift(dst_channel) value = '(%s >> %s)' % (value, src_shift - dst_shift) else: # We need to rescale using an intermediate type big enough to hold the multiplication of both - tmp_native_type = intermediate_native_type(src_type.size + dst_type.size, src_type.sign and dst_type.sign) + tmp_native_type = intermediate_native_type(src_channel.size + dst_channel.size, src_channel.sign and dst_channel.sign) value = '(%s)%s' % (tmp_native_type, value) value = '%s * 0x%x / 0x%x' % (value, dst_one, src_one) value = '(%s)%s' % (dst_native_type, value) @@ -253,11 +253,11 @@ def compute_inverse_swizzle(format): inv_swizzle = [None]*4 if format.colorspace == 'rgb': for i in range(4): - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: inv_swizzle[swizzle] = i elif format.colorspace == 'zs': - swizzle = format.out_swizzle[0] + swizzle = format.swizzles[0] if swizzle < 4: inv_swizzle[swizzle] = 0 else: @@ -266,7 +266,7 @@ def compute_inverse_swizzle(format): return inv_swizzle -def generate_format_read(format, dst_type, dst_native_type, dst_suffix): +def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' name = format.short_name() @@ -287,11 +287,11 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): names = ['']*4 if format.colorspace == 'rgb': for i in range(4): - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: names[swizzle] += 'rgba'[i] elif format.colorspace == 'zs': - swizzle = format.out_swizzle[0] + swizzle = format.swizzles[0] if swizzle < 4: names[swizzle] = 'z' else: @@ -304,8 +304,8 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print ' %s pixel = *src_pixel++;' % src_native_type shift = 0; for i in range(4): - src_type = format.in_types[i] - width = src_type.size + src_channel = format.channels[i] + width = src_channel.size if names[i]: value = 'pixel' mask = (1 << width) - 1 @@ -313,35 +313,35 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): value = '(%s >> %u)' % (value, shift) if shift + width < format.block_size(): value = '(%s & 0x%x)' % (value, mask) - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' %s %s = %s;' % (dst_native_type, names[i], value) shift += width else: for i in range(4): - src_type = format.in_types[i] + src_channel = format.channels[i] if names[i]: value = '(*src_pixel++)' - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' %s %s = %s;' % (dst_native_type, names[i], value) else: assert False for i in range(4): if format.colorspace == 'rgb': - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: value = names[swizzle] elif swizzle == SWIZZLE_0: value = '0' elif swizzle == SWIZZLE_1: - value = get_one(dst_type) + value = get_one(dst_channel) else: assert False elif format.colorspace == 'zs': if i < 3: value = 'z' else: - value = get_one(dst_type) + value = get_one(dst_channel) else: assert False print ' *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i]) @@ -354,7 +354,7 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print -def generate_format_write(format, src_type, src_native_type, src_suffix): +def generate_format_write(format, src_channel, src_native_type, src_suffix): '''Generate the function to write pixels to a particular format''' name = format.short_name() @@ -379,11 +379,11 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): print ' %s pixel = 0;' % dst_native_type shift = 0; for i in range(4): - dst_type = format.in_types[i] - width = dst_type.size + dst_channel = format.channels[i] + width = dst_channel.size if inv_swizzle[i] is not None: value = 'src_pixel[%u]' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) if shift: value = '(%s << %u)' % (value, shift) print ' pixel |= %s;' % value @@ -391,10 +391,10 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): print ' *dst_pixel++ = pixel;' else: for i in range(4): - dst_type = format.in_types[i] + dst_channel = format.channels[i] if inv_swizzle[i] is not None: value = 'src_pixel[%u]' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' *dst_pixel++ = %s;' % value else: assert False @@ -408,12 +408,12 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): print -def generate_read(formats, dst_type, dst_native_type, dst_suffix): +def generate_read(formats, dst_channel, dst_native_type, dst_suffix): '''Generate the dispatch function to read pixels from any format''' for format in formats: if is_format_supported(format): - generate_format_read(format, dst_type, dst_native_type, dst_suffix) + generate_format_read(format, dst_channel, dst_native_type, dst_suffix) print 'void' print 'util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type) @@ -434,12 +434,12 @@ def generate_read(formats, dst_type, dst_native_type, dst_suffix): print -def generate_write(formats, src_type, src_native_type, src_suffix): +def generate_write(formats, src_channel, src_native_type, src_suffix): '''Generate the dispatch function to write pixels to any format''' for format in formats: if is_format_supported(format): - generate_format_write(format, src_type, src_native_type, src_suffix) + generate_format_write(format, src_channel, src_native_type, src_suffix) print 'void' print 'util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type) @@ -478,14 +478,14 @@ def main(): generate_clamp() - type = Type(FLOAT, False, 32) + type = Channel(FLOAT, False, 32) native_type = 'float' suffix = '4f' generate_read(formats, type, native_type, suffix) generate_write(formats, type, native_type, suffix) - type = Type(UNSIGNED, True, 8) + type = Channel(UNSIGNED, True, 8) native_type = 'uint8_t' suffix = '4ub' diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index f26cb37237..edc6bba795 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -41,36 +41,36 @@ def is_pot(x): return (x & (x - 1)) == 0; -class Type: - '''Describe the type of a color channel.''' +class Channel: + '''Describe the channel of a color channel.''' - def __init__(self, kind, norm, size): - self.kind = kind + def __init__(self, type, norm, size): + self.type = type self.norm = norm self.size = size - self.sign = kind in (SIGNED, FIXED, FLOAT) + self.sign = type in (SIGNED, FIXED, FLOAT) def __str__(self): - s = str(self.kind) + s = str(self.type) if self.norm: s += 'n' s += str(self.size) return s def __eq__(self, other): - return self.kind == other.kind and self.norm == other.norm and self.size == other.size + return self.type == other.type and self.norm == other.norm and self.size == other.size class Format: '''Describe a pixel format.''' - def __init__(self, name, layout, block_width, block_height, in_types, out_swizzle, colorspace): + def __init__(self, name, layout, block_width, block_height, channels, swizzles, colorspace): self.name = name self.layout = layout self.block_width = block_width self.block_height = block_height - self.in_types = in_types - self.out_swizzle = out_swizzle + self.channels = channels + self.swizzles = swizzles self.name = name self.colorspace = colorspace @@ -89,42 +89,54 @@ class Format: def block_size(self): size = 0 - for type in self.in_types: - size += type.size + for channel in self.channels: + size += channel.size return size def nr_channels(self): nr_channels = 0 - for type in self.in_types: - if type.size: + for channel in self.channels: + if channel.size: nr_channels += 1 return nr_channels def is_array(self): - ref_type = self.in_types[0] - for type in self.in_types[1:]: - if type.size and (type.size != ref_type.size or type.size % 8): + ref_channel = self.channels[0] + for channel in self.channels[1:]: + if channel.size and (channel.size != ref_channel.size or channel.size % 8): return False return True def is_mixed(self): - ref_type = self.in_types[0] - for type in self.in_types[1:]: - if type.kind != VOID: - if type.kind != ref_type.kind: + ref_channel = self.channels[0] + for channel in self.channels[1:]: + if channel.type != VOID: + if channel.type != ref_channel.type: return True - if type.norm != ref_type.norm: + if channel.norm != ref_channel.norm: return True return False def is_pot(self): return is_pot(self.block_size()) + def is_int(self): + for channel in self.channels: + if channel.type not in (VOID, UNSIGNED, SIGNED): + return False + return True + + def is_float(self): + for channel in self.channels: + if channel.type not in (VOID, FLOAT): + return False + return True + def stride(self): return self.block_size()/8 -_kind_parse_map = { +_type_parse_map = { '': VOID, 'x': VOID, 'u': UNSIGNED, @@ -145,7 +157,7 @@ _swizzle_parse_map = { def parse(filename): '''Parse the format descrition in CSV format in terms of the - Type and Format classes above.''' + Channel and Format classes above.''' stream = open(filename) formats = [] @@ -163,10 +175,10 @@ def parse(filename): name = fields[0] layout = fields[1] block_width, block_height = map(int, fields[2:4]) - in_types = [] + channels = [] for field in fields[4:8]: if field: - kind = _kind_parse_map[field[0]] + type = _type_parse_map[field[0]] if field[1] == 'n': norm = True size = int(field[2:]) @@ -174,13 +186,13 @@ def parse(filename): norm = False size = int(field[1:]) else: - kind = VOID + type = VOID norm = False size = 0 - in_type = Type(kind, norm, size) - in_types.append(in_type) - out_swizzle = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] + channel = Channel(type, norm, size) + channels.append(channel) + swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] colorspace = fields[9] - formats.append(Format(name, layout, block_width, block_height, in_types, out_swizzle, colorspace)) + formats.append(Format(name, layout, block_width, block_height, channels, swizzles, colorspace)) return formats diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 953b5aed87..a7a4fd18a8 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -51,7 +51,7 @@ colorspace_channels_map = { } -kind_map = { +type_map = { VOID: "UTIL_FORMAT_TYPE_VOID", UNSIGNED: "UTIL_FORMAT_TYPE_UNSIGNED", SIGNED: "UTIL_FORMAT_TYPE_SIGNED", @@ -112,16 +112,16 @@ def write_format_table(formats): print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) print " {" for i in range(4): - type = format.in_types[i] + channel = format.channels[i] if i < 3: sep = "," else: sep = "" - print " {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i]) + print " {%s, %s, %u}%s\t/* %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i]) print " }," print " {" for i in range(4): - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if i < 3: sep = "," else: diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index 4d04905958..52d7d3186a 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -45,7 +45,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), '../../auxiliary/u from u_format_access import * -def generate_format_read(format, dst_type, dst_native_type, dst_suffix): +def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' name = format.short_name() @@ -64,11 +64,11 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): names = ['']*4 if format.colorspace == 'rgb': for i in range(4): - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: names[swizzle] += 'rgba'[i] elif format.colorspace == 'zs': - swizzle = format.out_swizzle[0] + swizzle = format.swizzles[0] if swizzle < 4: names[swizzle] = 'z' else: @@ -81,8 +81,8 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print ' %s pixel = *src_pixel++;' % src_native_type shift = 0; for i in range(4): - src_type = format.in_types[i] - width = src_type.size + src_channel = format.channels[i] + width = src_channel.size if names[i]: value = 'pixel' mask = (1 << width) - 1 @@ -90,35 +90,35 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): value = '(%s >> %u)' % (value, shift) if shift + width < format.block_size(): value = '(%s & 0x%x)' % (value, mask) - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' %s %s = %s;' % (dst_native_type, names[i], value) shift += width else: for i in range(4): - src_type = format.in_types[i] + src_channel = format.channels[i] if names[i]: value = '(*src_pixel++)' - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' %s %s = %s;' % (dst_native_type, names[i], value) else: assert False for i in range(4): if format.colorspace == 'rgb': - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: value = names[swizzle] elif swizzle == SWIZZLE_0: value = '0' elif swizzle == SWIZZLE_1: - value = get_one(dst_type) + value = get_one(dst_channel) else: assert False elif format.colorspace == 'zs': if i < 3: value = 'z' else: - value = get_one(dst_type) + value = get_one(dst_channel) else: assert False print ' TILE_PIXEL(dst, x, y, %u) = %s; /* %s */' % (i, value, 'rgba'[i]) @@ -130,7 +130,7 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print -def pack_rgba(format, src_type, r, g, b, a): +def pack_rgba(format, src_channel, r, g, b, a): """Return an expression for packing r, g, b, a into a pixel of the given format. Ex: '(b << 24) | (g << 16) | (r << 8) | (a << 0)' """ @@ -152,21 +152,21 @@ def pack_rgba(format, src_type, r, g, b, a): value = None if value: - dst_type = format.in_types[i] + dst_channel = format.channels[i] dst_native_type = native_type(format) - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) term = "((%s) << %d)" % (value, shift) if expr: expr = expr + " | " + term else: expr = term - width = format.in_types[i].size + width = format.channels[i].size shift = shift + width return expr -def emit_unrolled_write_code(format, src_type): +def emit_unrolled_write_code(format, src_channel): '''Emit code for writing a block based on unrolled loops. This is considerably faster than the TILE_PIXEL-based code below. ''' @@ -185,8 +185,8 @@ def emit_unrolled_write_code(format, src_type): print ' const uint8_t *a = src + 3 * TILE_C_STRIDE;' print ' (void) r; (void) g; (void) b; (void) a; /* silence warnings */' print ' for (i = 0; i < TILE_C_STRIDE; i += 2) {' - print ' const uint32_t pixel0 = %s;' % pack_rgba(format, src_type, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]") - print ' const uint32_t pixel1 = %s;' % pack_rgba(format, src_type, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]") + print ' const uint32_t pixel0 = %s;' % pack_rgba(format, src_channel, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]") + print ' const uint32_t pixel1 = %s;' % pack_rgba(format, src_channel, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]") print ' const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]);' print ' dstpix[offset + 0] = pixel0;' print ' dstpix[offset + 1] = pixel1;' @@ -196,7 +196,7 @@ def emit_unrolled_write_code(format, src_type): print ' }' -def emit_tile_pixel_write_code(format, src_type): +def emit_tile_pixel_write_code(format, src_channel): '''Emit code for writing a block based on the TILE_PIXEL macro.''' dst_native_type = native_type(format) @@ -213,11 +213,11 @@ def emit_tile_pixel_write_code(format, src_type): print ' %s pixel = 0;' % dst_native_type shift = 0; for i in range(4): - dst_type = format.in_types[i] - width = dst_type.size + dst_channel = format.channels[i] + width = dst_channel.size if inv_swizzle[i] is not None: value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) if shift: value = '(%s << %u)' % (value, shift) print ' pixel |= %s;' % value @@ -225,10 +225,10 @@ def emit_tile_pixel_write_code(format, src_type): print ' *dst_pixel++ = pixel;' else: for i in range(4): - dst_type = format.in_types[i] + dst_channel = format.channels[i] if inv_swizzle[i] is not None: value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' *dst_pixel++ = %s;' % value else: assert False @@ -238,7 +238,7 @@ def emit_tile_pixel_write_code(format, src_type): print ' }' -def generate_format_write(format, src_type, src_native_type, src_suffix): +def generate_format_write(format, src_channel, src_native_type, src_suffix): '''Generate the function to write pixels to a particular format''' name = format.short_name() @@ -251,20 +251,20 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): and format.block_size() <= 32 \ and format.is_pot() \ and not format.is_mixed() \ - and format.in_types[0].kind == UNSIGNED: - emit_unrolled_write_code(format, src_type) + and format.channels[0].type == UNSIGNED: + emit_unrolled_write_code(format, src_channel) else: - emit_tile_pixel_write_code(format, src_type) + emit_tile_pixel_write_code(format, src_channel) print '}' print -def generate_read(formats, dst_type, dst_native_type, dst_suffix): +def generate_read(formats, dst_channel, dst_native_type, dst_suffix): '''Generate the dispatch function to read pixels from any format''' for format in formats: if is_format_supported(format): - generate_format_read(format, dst_type, dst_native_type, dst_suffix) + generate_format_read(format, dst_channel, dst_native_type, dst_suffix) print 'void' print 'lp_tile_read_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type) @@ -285,12 +285,12 @@ def generate_read(formats, dst_type, dst_native_type, dst_suffix): print -def generate_write(formats, src_type, src_native_type, src_suffix): +def generate_write(formats, src_channel, src_native_type, src_suffix): '''Generate the dispatch function to write pixels to any format''' for format in formats: if is_format_supported(format): - generate_format_write(format, src_type, src_native_type, src_suffix) + generate_format_write(format, src_channel, src_native_type, src_suffix) print 'void' print 'lp_tile_write_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type) @@ -351,12 +351,12 @@ def main(): generate_clamp() - type = Type(UNSIGNED, True, 8) + channel = Channel(UNSIGNED, True, 8) native_type = 'uint8_t' suffix = '4ub' - generate_read(formats, type, native_type, suffix) - generate_write(formats, type, native_type, suffix) + generate_read(formats, channel, native_type, suffix) + generate_write(formats, channel, native_type, suffix) if __name__ == '__main__': -- cgit v1.2.3 From 4757325951e35460975e77d70dacf8b6eb10ab11 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 15:45:48 +0000 Subject: util: Factor some code into u_format_parse.py --- src/gallium/auxiliary/util/u_format_access.py | 20 +----- src/gallium/auxiliary/util/u_format_parse.py | 95 +++++++++++++++++++++++++-- src/gallium/auxiliary/util/u_format_table.py | 5 +- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 4 +- 4 files changed, 96 insertions(+), 28 deletions(-) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index 267fb3fbbd..a7a91ea652 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -248,24 +248,6 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value): assert False -def compute_inverse_swizzle(format): - '''Return an array[4] of inverse swizzle terms''' - inv_swizzle = [None]*4 - if format.colorspace == 'rgb': - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - inv_swizzle[swizzle] = i - elif format.colorspace == 'zs': - swizzle = format.swizzles[0] - if swizzle < 4: - inv_swizzle[swizzle] = 0 - else: - assert False - - return inv_swizzle - - def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' @@ -372,7 +354,7 @@ def generate_format_write(format, src_channel, src_native_type, src_suffix): print ' const %s *src_pixel = src_row;' %src_native_type print ' for (x = 0; x < w; ++x) {' - inv_swizzle = compute_inverse_swizzle(format) + inv_swizzle = format.inv_swizzles() if format.layout == PLAIN: if not format.is_array(): diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index edc6bba795..250926418e 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -36,19 +36,28 @@ SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, PLAIN = 'plain' +RGB = 'rgb' +SRGB = 'srgb' +YUV = 'yuv' +ZS = 'zs' + def is_pot(x): return (x & (x - 1)) == 0; +VERY_LARGE = 99999999999999999999999 + + class Channel: '''Describe the channel of a color channel.''' - def __init__(self, type, norm, size): + def __init__(self, type, norm, size, name = ''): self.type = type self.norm = norm self.size = size self.sign = type in (SIGNED, FIXED, FLOAT) + self.name = name def __str__(self): s = str(self.type) @@ -60,6 +69,30 @@ class Channel: def __eq__(self, other): return self.type == other.type and self.norm == other.norm and self.size == other.size + def max(self): + '''Maximum representable number.''' + if self.type == FLOAT: + return VERY_LARGE + if self.norm: + return 1 + if self.type == UNSIGNED: + return (1 << self.size) - 1 + if self.type == SIGNED: + return self.size - 1 + assert False + + def min(self): + '''Minimum representable number.''' + if self.type == FLOAT: + return -VERY_LARGE + if self.type == UNSIGNED: + return 0 + if self.norm: + return -1 + if self.type == SIGNED: + return -(1 << (self.size - 1)) + assert False + class Format: '''Describe a pixel format.''' @@ -132,6 +165,29 @@ class Format: return False return True + def is_bitmask(self): + if self.block_size() > 32: + return False + if not self.is_pot(): + return False + for channel in self.channels: + if not is_pot(channel.size): + return True + if channel.type not in (VOID, UNSIGNED, SIGNED): + return False + if channel.size >= 32: + return False + return True + + def inv_swizzles(self): + '''Return an array[4] of inverse swizzle terms''' + inv_swizzle = [None]*4 + for i in range(4): + swizzle = self.swizzles[i] + if swizzle < 4: + inv_swizzle[swizzle] = i + return inv_swizzle + def stride(self): return self.block_size()/8 @@ -171,12 +227,39 @@ def parse(filename): line = line.strip() if not line: continue + fields = [field.strip() for field in line.split(',')] + name = fields[0] layout = fields[1] block_width, block_height = map(int, fields[2:4]) + + swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] + colorspace = fields[9] + + if layout == PLAIN: + names = ['']*4 + if colorspace in (RGB, SRGB): + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + names[swizzle] += 'rgba'[i] + elif colorspace == ZS: + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + names[swizzle] += 'zs'[i] + else: + assert False + for i in range(4): + if names[i] == '': + names[i] = 'x' + else: + names = ['x', 'y', 'z', 'w'] + channels = [] - for field in fields[4:8]: + for i in range(0, 4): + field = fields[4 + i] if field: type = _type_parse_map[field[0]] if field[1] == 'n': @@ -189,10 +272,10 @@ def parse(filename): type = VOID norm = False size = 0 - channel = Channel(type, norm, size) + channel = Channel(type, norm, size, names[i]) channels.append(channel) - swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] - colorspace = fields[9] - formats.append(Format(name, layout, block_width, block_height, channels, swizzles, colorspace)) + + format = Format(name, layout, block_width, block_height, channels, swizzles, colorspace) + formats.append(format) return formats diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index a7a4fd18a8..4e29d15f3b 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -117,7 +117,10 @@ def write_format_table(formats): sep = "," else: sep = "" - print " {%s, %s, %u}%s\t/* %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i]) + if channel.size: + print " {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name) + else: + print " {0, 0, 0}%s" % (sep,) print " }," print " {" for i in range(4): diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index 52d7d3186a..dc44d67d63 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -135,7 +135,7 @@ def pack_rgba(format, src_channel, r, g, b, a): given format. Ex: '(b << 24) | (g << 16) | (r << 8) | (a << 0)' """ assert format.colorspace == 'rgb' - inv_swizzle = compute_inverse_swizzle(format) + inv_swizzle = format.inv_swizzles() shift = 0 expr = None for i in range(4): @@ -200,7 +200,7 @@ def emit_tile_pixel_write_code(format, src_channel): '''Emit code for writing a block based on the TILE_PIXEL macro.''' dst_native_type = native_type(format) - inv_swizzle = compute_inverse_swizzle(format) + inv_swizzle = format.inv_swizzles() print ' unsigned x, y;' print ' uint8_t *dst_row = dst + y0*dst_stride;' -- cgit v1.2.3 From 4afae877e6914e311340e0b1d3490ec2fed9422f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 12:46:29 +0000 Subject: util: Add the shortened format name to the description. --- src/gallium/auxiliary/util/u_format.h | 6 ++++++ src/gallium/auxiliary/util/u_format_table.py | 2 ++ 2 files changed, 8 insertions(+) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index e8fa0022b5..ec6b077734 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -120,8 +120,14 @@ struct util_format_channel_description struct util_format_description { enum pipe_format format; + const char *name; + /** + * Short name, striped of the prefix, lower case. + */ + const char *short_name; + /** * Pixel block dimensions. */ diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 4e29d15f3b..f9d21ed8aa 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -90,6 +90,7 @@ def write_format_table(formats): print 'util_format_none_description = {' print " PIPE_FORMAT_NONE," print " \"PIPE_FORMAT_NONE\"," + print " \"none\"," print " {0, 0, 0}," print " 0," print " 0," @@ -105,6 +106,7 @@ def write_format_table(formats): print 'util_format_%s_description = {' % (format.short_name(),) print " %s," % (format.name,) print " \"%s\"," % (format.name,) + print " \"%s\"," % (format.short_name(),) print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) print " %s," % (layout_map(format.layout),) print " %u,\t/* nr_channels */" % (format.nr_channels(),) -- cgit v1.2.3 From cfde6c50ae6c3ce7912a3d1231c459d020d77f13 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 12:48:39 +0000 Subject: util: Add a new flag, for formats that can be described as a bitmask. --- src/gallium/auxiliary/util/u_format.h | 9 +++++++++ src/gallium/auxiliary/util/u_format_parse.py | 8 +------- src/gallium/auxiliary/util/u_format_table.py | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/gallium/auxiliary/util/u_format_table.py') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index ec6b077734..b2aa5bfb18 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -145,6 +145,15 @@ struct util_format_description */ unsigned is_array:1; + /** + * Whether the pixel format can be described as a bitfield structure. + * + * In particular: + * - pixel depth must be 8, 16, or 32 bits; + * - all channels must be unsigned, signed, or void + */ + unsigned is_bitmask:1; + /** * Whether channels have mixed types (ignoring UTIL_FORMAT_TYPE_VOID). */ diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 250926418e..80bae6fc95 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -166,17 +166,11 @@ class Format: return True def is_bitmask(self): - if self.block_size() > 32: - return False - if not self.is_pot(): + if self.block_size() not in (8, 16, 32): return False for channel in self.channels: - if not is_pot(channel.size): - return True if channel.type not in (VOID, UNSIGNED, SIGNED): return False - if channel.size >= 32: - return False return True def inv_swizzles(self): diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index f9d21ed8aa..fb68852a53 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -96,6 +96,7 @@ def write_format_table(formats): print " 0," print " 0," print " 0," + print " 0," print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," print " {0, 0, 0, 0}," print " 0" @@ -111,6 +112,7 @@ def write_format_table(formats): print " %s," % (layout_map(format.layout),) print " %u,\t/* nr_channels */" % (format.nr_channels(),) print " %s,\t/* is_array */" % (bool_map(format.is_array()),) + print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),) print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) print " {" for i in range(4): -- cgit v1.2.3