+from __future__ import print_function
CopyRight = '''
/**************************************************************************
if format.nr_channels() <= 1:
func(format.le_channels, format.le_swizzles)
else:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
+ print('#ifdef PIPE_ARCH_BIG_ENDIAN')
func(format.be_channels, format.be_swizzles)
- print '#else'
+ print('#else')
func(format.le_channels, format.le_swizzles)
- print '#endif'
+ print('#endif')
def write_format_table(formats):
- print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */'
- print
+ print('/* This file is autogenerated by vk_format_table.py from vk_format_layout.csv. Do not edit directly. */')
+ print()
# This will print the copyright message on the top of this file
- print CopyRight.strip()
- print
- print '#include "stdbool.h"'
- print '#include "vk_format.h"'
- print
+ print(CopyRight.strip())
+ print()
+ print('#include "stdbool.h"')
+ print('#include "vk_format.h"')
+ print()
def do_channel_array(channels, swizzles):
- print " {"
+ print(" {")
for i in range(4):
channel = channels[i]
if i < 3:
else:
sep = ""
if channel.size:
- print " {%s, %s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), bool_map(channel.scaled), channel.size, channel.shift, sep, "xyzw"[i], channel.name)
+ print(" {%s, %s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), bool_map(channel.scaled), channel.size, channel.shift, sep, "xyzw"[i], channel.name))
else:
- print " {0, 0, 0, 0, 0}%s" % (sep,)
- print " },"
+ print(" {0, 0, 0, 0, 0}%s" % (sep,))
+ print(" },")
def do_swizzle_array(channels, swizzles):
- print " {"
+ print(" {")
for i in range(4):
swizzle = swizzles[i]
if i < 3:
comment = colorspace_channels_map[format.colorspace][i]
except (KeyError, IndexError):
comment = 'ignored'
- print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
- print " },"
+ print(" %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment))
+ print(" },")
for format in formats:
- print 'const struct vk_format_description'
- print 'vk_format_%s_description = {' % (format.short_name(),)
- print " %s," % (format.name,)
- print " \"%s\"," % (format.name,)
- print " \"%s\"," % (format.short_name(),)
- print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
- print " %s," % (layout_map(format.layout),)
- print " %u,\t/* nr_channels */" % (format.nr_channels(),)
- print " %s,\t/* is_array */" % (bool_map(format.is_array()),)
- print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
- print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
+ print('static const struct vk_format_description')
+ print('vk_format_%s_description = {' % (format.short_name(),))
+ print(" %s," % (format.name,))
+ print(" \"%s\"," % (format.name,))
+ print(" \"%s\"," % (format.short_name(),))
+ print(" {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()))
+ print(" %s," % (layout_map(format.layout),))
+ print(" %u,\t/* nr_channels */" % (format.nr_channels(),))
+ print(" %s,\t/* is_array */" % (bool_map(format.is_array()),))
+ print(" %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),))
+ print(" %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),))
print_channels(format, do_channel_array)
print_channels(format, do_swizzle_array)
- print " %s," % (colorspace_map(format.colorspace),)
- print "};"
- print
-
- print "const struct vk_format_description *"
- print "vk_format_description(VkFormat format)"
- print "{"
- print " if (format > VK_FORMAT_END_RANGE) {"
- print " return NULL;"
- print " }"
- print
- print " switch (format) {"
+ print(" %s," % (colorspace_map(format.colorspace),))
+ print(" %u,\t/* plane_count */" % (format.plane_count))
+ print(" %u,\t/* width_divisor */" % (format.width_divisor))
+ print(" %u,\t/* height_divisor */" % (format.height_divisor))
+ print(" {%s, %s, %s}," % (format.plane_formats[0], format.plane_formats[1], format.plane_formats[2]))
+ print("};")
+ print()
+
+ print("const struct vk_format_description *")
+ print("vk_format_description(VkFormat format)")
+ print("{")
+ print(" switch (format) {")
for format in formats:
- print " case %s:" % format.name
- print " return &vk_format_%s_description;" % (format.short_name(),)
- print " default:"
- print " return NULL;"
- print " }"
- print "}"
- print
+ print(" case %s:" % format.name)
+ print(" return &vk_format_%s_description;" % (format.short_name(),))
+ print(" default:")
+ print(" return NULL;")
+ print(" }")
+ print("}")
+ print()
def main():