X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Famd%2Fvulkan%2Fvk_format_parse.py;h=506c723ea515f0f615239f58ef6c3d82cf7bd99f;hb=c39a1611ab36cbeb10590dde937a8c11f3b87b02;hp=00cf1adf5a7b6f0b83710498348717f6c0b04496;hpb=a1d186cb707f71f8d85d654c241af2b9fccc68ec;p=mesa.git diff --git a/src/amd/vulkan/vk_format_parse.py b/src/amd/vulkan/vk_format_parse.py index 00cf1adf5a7..506c723ea51 100644 --- a/src/amd/vulkan/vk_format_parse.py +++ b/src/amd/vulkan/vk_format_parse.py @@ -73,8 +73,14 @@ class Channel: return s def __eq__(self, other): + if other is None: + return False + return self.type == other.type and self.norm == other.norm and self.pure == other.pure and self.size == other.size and self.scaled == other.scaled + def __ne__(self, other): + return not self == other + def max(self): '''Maximum representable number.''' if self.type == FLOAT: @@ -107,7 +113,7 @@ class Channel: class Format: '''Describe a pixel format.''' - def __init__(self, name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace): + def __init__(self, name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace, width_divisor, height_divisor, plane_formats): self.name = name self.layout = layout self.block_width = block_width @@ -118,6 +124,13 @@ class Format: self.be_swizzles = be_swizzles self.name = name self.colorspace = colorspace + self.plane_count = len(plane_formats) + self.width_divisor = width_divisor + self.height_divisor = height_divisor + self.plane_formats = plane_formats + + while len(self.plane_formats) < 3: + self.plane_formats.append("VK_FORMAT_UNDEFINED") def __str__(self): return self.name @@ -328,6 +341,16 @@ def _parse_channels(fields, layout, colorspace, swizzles): return channels +def parse_plane_divisor(format): + if format == '444': + return (1, 1) + elif format == '422': + return (2, 1) + elif format == '420': + return (2, 2) + else: + return (1, 1) + def parse(filename): '''Parse the format description in CSV format in terms of the Channel and Format classes above.''' @@ -348,10 +371,9 @@ def parse(filename): fields = [field.strip() for field in line.split(',')] if len (fields) < 10: continue - if len (fields) == 10: - fields += fields[4:9] - assert len (fields) == 15 - + + be_fields = fields[4:9] + name = fields[0] layout = fields[1] block_width, block_height = map(int, fields[2:4]) @@ -360,8 +382,8 @@ def parse(filename): le_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] le_channels = _parse_channels(fields[4:8], layout, colorspace, le_swizzles) - be_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[14]] - be_channels = _parse_channels(fields[10:14], layout, colorspace, be_swizzles) + be_swizzles = [_swizzle_parse_map[swizzle] for swizzle in be_fields[4]] + be_channels = _parse_channels(be_fields, layout, colorspace, be_swizzles) le_shift = 0 for channel in le_channels: @@ -377,7 +399,18 @@ def parse(filename): for i in range(4): assert (le_swizzles[i] != SWIZZLE_NONE) == (be_swizzles[i] != SWIZZLE_NONE) - format = Format(name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace) + width_divisor = 1 + height_divisor = 1 + plane_formats = [name] + if layout == "multiplane": + plane_formats = [] + (width_divisor, height_divisor) = parse_plane_divisor(fields[10]) + + for i in range(11, len(fields)): + plane_formats.append(fields[i]) + assert (len(plane_formats) > 1) + + format = Format(name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace, width_divisor, height_divisor, plane_formats) formats.append(format) return formats