util: Store more derived data in the the format description.
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user