u_format: Sanity check the BE channels for all bitmask formats.

Just check against the CSV (which has its codegen now tested with
u_format_test in CI) for now, so we know that our computed channels are
correct.

Acked-by: Adam Jackson <ajax@redhat.com>
Acked-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10505>
This commit is contained in:
Eric Anholt 2021-04-27 15:17:39 -07:00 committed by Marge Bot
parent 9d77cecf88
commit 36569b9f8c

View file

@ -71,6 +71,9 @@ class Channel:
s += str(self.size)
return s
def __repr__(self):
return "Channel({})".format(self.__str__())
def __eq__(self, other):
if other is None:
return False
@ -135,6 +138,27 @@ class Format:
exit(1)
self.be_channels = be_channels
self.be_swizzles = be_swizzles
if self.is_bitmask():
# Bitmask formats are "load a word the size of the block and
# bitshift channels out of it." However, the channel shifts
# defined in u_format_table.c are numbered right-to-left on BE
# for some historical reason (see below), which is hard to
# change due to llvmpipe, so we also have to flip the channel
# order and the channel-to-rgba swizzle values to read
# right-to-left from the defined (non-VOID) channels so that the
# correct shifts happen.
#
# This is nonsense, but it's the nonsense that makes
# u_format_test pass and you get the right colors in softpipe at
# least.
chans = self.nr_channels()
packed_be_channels = self.le_channels[chans -
1::-1] + self.le_channels[chans:4]
if packed_be_channels != be_channels:
print("{}: {} != {}".format(
self.name, be_channels, packed_be_channels))
exit(1)
else:
self.be_channels = copy.deepcopy(le_channels)
self.be_swizzles = le_swizzles