summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2021-04-27 15:17:39 -0700
committerMarge Bot <eric+marge@anholt.net>2021-06-03 00:12:39 +0000
commit36569b9f8cbcaea1dbfeed7a7f0c6d4b33dd99a6 (patch)
tree8260965156b46b7096ff2df772c59d65d6470484
parent9d77cecf88b0816c234dd97a630429242c868db1 (diff)
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>
-rw-r--r--src/util/format/u_format_parse.py24
1 files changed, 24 insertions, 0 deletions
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