From 36569b9f8cbcaea1dbfeed7a7f0c6d4b33dd99a6 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 27 Apr 2021 15:17:39 -0700 Subject: 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 Acked-by: Ilia Mirkin Part-of: --- src/util/format/u_format_parse.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/util/format/u_format_parse.py b/src/util/format/u_format_parse.py index aba4e29ee36..0094d576cf5 100644 --- a/src/util/format/u_format_parse.py +++ b/src/util/format/u_format_parse.py @@ -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 -- cgit v1.2.3