diff options
-rw-r--r-- | src/gallium/auxiliary/util/u_format.h | 18 | ||||
-rwxr-xr-x | src/gallium/auxiliary/util/u_format_parse.py | 24 | ||||
-rwxr-xr-x | src/gallium/auxiliary/util/u_format_table.py | 6 |
3 files changed, 48 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 2fbbb83d4ba..7054a07b2db 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -138,8 +138,26 @@ struct util_format_description const char *name; struct util_format_block block; enum util_format_layout layout; + + /** + * The number of channels. + */ + unsigned nr_channels:3; + + /** + * Whether all channels have the same number of whole bytes. + */ + unsigned is_array:1; + + /** + * Whether channels have mixed types (ignoring UTIL_FORMAT_TYPE_VOID). + */ + unsigned is_mixed:1; + struct util_format_channel_description channel[4]; + unsigned char swizzle[4]; + enum util_format_colorspace colorspace; }; diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 493aff71127..5d49fc7652b 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -83,6 +83,30 @@ class Format: size += type.size return size + def nr_channels(self): + nr_channels = 0 + for type in self.in_types: + if type.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): + 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: + return True + if type.norm != ref_type.norm: + return True + return False + def stride(self): return self.block_size()/8 diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 571cab55dc8..05e176d5675 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] |