Mesa (main): u_format: Sanity check that BE swizzles are appropriately mapped from LE.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 3 00:44:43 UTC 2021
Module: Mesa
Branch: main
Commit: 1c1997267fcb5c1cfef326d7c9e7d4580a19d3c4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1c1997267fcb5c1cfef326d7c9e7d4580a19d3c4
Author: Eric Anholt <eric at anholt.net>
Date: Wed Apr 28 14:10:08 2021 -0700
u_format: Sanity check that BE swizzles are appropriately mapped from LE.
Once you read enough of them, there's an obvious pattern that we can just
write a little code for instead of making every dev write it out each time.
Acked-by: Adam Jackson <ajax at redhat.com>
Acked-by: Ilia Mirkin <imirkin at alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10505>
---
src/util/format/u_format_parse.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/util/format/u_format_parse.py b/src/util/format/u_format_parse.py
index 0094d576cf5..f9216265127 100644
--- a/src/util/format/u_format_parse.py
+++ b/src/util/format/u_format_parse.py
@@ -159,6 +159,20 @@ class Format:
print("{}: {} != {}".format(
self.name, be_channels, packed_be_channels))
exit(1)
+
+ xyzw = [SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W]
+ chan_map = {SWIZZLE_X: xyzw[chans - 1] if chans >= 1 else SWIZZLE_X,
+ SWIZZLE_Y: xyzw[chans - 2] if chans >= 2 else SWIZZLE_X,
+ SWIZZLE_Z: xyzw[chans - 3] if chans >= 3 else SWIZZLE_X,
+ SWIZZLE_W: xyzw[chans - 4] if chans >= 4 else SWIZZLE_X,
+ SWIZZLE_1: SWIZZLE_1,
+ SWIZZLE_0: SWIZZLE_0,
+ SWIZZLE_NONE: SWIZZLE_NONE}
+ be_swizzles = [chan_map[s] for s in self.le_swizzles]
+ if be_swizzles != self.be_swizzles:
+ print("{}: LE {}, computed BE {} != {}".format(
+ self.name, self.le_swizzles, be_swizzles, self.be_swizzles))
+ exit(1)
else:
self.be_channels = copy.deepcopy(le_channels)
self.be_swizzles = le_swizzles
More information about the mesa-commit
mailing list