From: Eric Anholt Date: Tue, 27 Apr 2021 22:39:16 +0000 (-0700) Subject: u_format: Move the BE swizzle computation into Format init. X-Git-Tag: upstream/21.2.3~2577 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8ef4f3615a5b24a40c24041c54e5a4638dad5a4;p=platform%2Fupstream%2Fmesa.git 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 Acked-by: Ilia Mirkin Part-of: --- diff --git a/src/util/format/u_format_parse.py b/src/util/format/u_format_parse.py index 2c3b1aa..395376d 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)