Mesa (main): u_format: Move the BE swizzle computation into Format init.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 3 00:44:43 UTC 2021
Module: Mesa
Branch: main
Commit: c8ef4f3615a5b24a40c24041c54e5a4638dad5a4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c8ef4f3615a5b24a40c24041c54e5a4638dad5a4
Author: Eric Anholt <eric at anholt.net>
Date: Tue Apr 27 15:39:16 2021 -0700
u_format: Move the BE swizzle computation into Format init.
I wanted to do the next set BE changes here where I have Format's helper
functions available.
No changes in generated u_format_table.c.
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 | 54 ++++++++++++++++++++++++---------------
1 file changed, 33 insertions(+), 21 deletions(-)
diff --git a/src/util/format/u_format_parse.py b/src/util/format/u_format_parse.py
index 2c3b1aa9148..395376d0e5e 100644
--- a/src/util/format/u_format_parse.py
+++ b/src/util/format/u_format_parse.py
@@ -30,7 +30,7 @@
from __future__ import division
-
+import copy
VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5)
@@ -118,11 +118,32 @@ class Format:
self.block_width = block_width
self.block_height = block_height
self.block_depth = block_depth
+ self.colorspace = colorspace
+
self.le_channels = le_channels
self.le_swizzles = le_swizzles
- self.be_channels = be_channels
- self.be_swizzles = be_swizzles
- self.colorspace = colorspace
+
+ le_shift = 0
+ for channel in self.le_channels:
+ channel.shift = le_shift
+ le_shift += channel.size
+
+ if be_channels:
+ self.be_channels = be_channels
+ self.be_swizzles = be_swizzles
+ else:
+ self.be_channels = copy.deepcopy(le_channels)
+ self.be_swizzles = le_swizzles
+
+ be_shift = 0
+ for channel in self.be_channels[3::-1]:
+ channel.shift = be_shift
+ be_shift += channel.size
+
+ assert le_shift == be_shift
+ for i in range(4):
+ assert (self.le_swizzles[i] != SWIZZLE_NONE) == (
+ self.be_swizzles[i] != SWIZZLE_NONE)
def __str__(self):
return self.name
@@ -360,9 +381,7 @@ def parse(filename):
continue
fields = [field.strip() for field in line.split(',')]
- if len (fields) == 11:
- fields += fields[5:10]
- assert len (fields) == 16
+ assert(len(fields) == 11 or len(fields) == 16)
name = fields[0]
layout = fields[1]
@@ -372,22 +391,15 @@ def parse(filename):
le_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[9]]
le_channels = _parse_channels(fields[5:9], layout, colorspace, le_swizzles)
- be_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[15]]
- be_channels = _parse_channels(fields[11:15], layout, colorspace, be_swizzles)
+ be_swizzles = None
+ be_channels = None
+ if len(fields) == 16:
+ be_swizzles = [_swizzle_parse_map[swizzle]
- le_shift = 0
- for channel in le_channels:
- channel.shift = le_shift
- le_shift += channel.size
+ for swizzle in fields[15]]
+ be_channels = _parse_channels(
- be_shift = 0
- for channel in be_channels[3::-1]:
- channel.shift = be_shift
- be_shift += channel.size
-
- assert le_shift == be_shift
- for i in range(4):
- assert (le_swizzles[i] != SWIZZLE_NONE) == (be_swizzles[i] != SWIZZLE_NONE)
+ fields[11:15], layout, colorspace, be_swizzles)
format = Format(name, layout, block_width, block_height, block_depth, le_channels, le_swizzles, be_channels, be_swizzles, colorspace)
formats.append(format)
More information about the mesa-commit
mailing list