summaryrefslogtreecommitdiff
path: root/src/util/format/u_format_table.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/format/u_format_table.py')
-rw-r--r--src/util/format/u_format_table.py48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/util/format/u_format_table.py b/src/util/format/u_format_table.py
index 10659d5c4b1..35f2872f0ed 100644
--- a/src/util/format/u_format_table.py
+++ b/src/util/format/u_format_table.py
@@ -61,9 +61,9 @@ type_map = {
def bool_map(value):
if value:
- return "TRUE"
+ return "true"
else:
- return "FALSE"
+ return "false"
swizzle_map = {
@@ -90,6 +90,7 @@ def has_access(format):
'p010',
'p012',
'p016',
+ 'p030',
'y210',
'y212',
'y216',
@@ -99,8 +100,13 @@ def has_access(format):
'xyuv',
'ayuv',
'r8g8_r8b8_unorm',
+ 'r8b8_r8g8_unorm',
'g8r8_b8r8_unorm',
+ 'b8r8_g8r8_unorm',
'g8r8_g8b8_unorm',
+ 'g8b8_g8r8_unorm',
+ 'b8g8_r8g8_unorm',
+ 'y8_400_unorm',
'y8_u8_v8_422_unorm',
'y8_u8v8_422_unorm',
'y8_u8_v8_444_unorm',
@@ -109,6 +115,13 @@ def has_access(format):
'y16_u16v16_422_unorm',
'y16_u16_v16_444_unorm',
'r8_g8b8_420_unorm',
+ 'r8_b8g8_420_unorm',
+ 'g8_b8r8_420_unorm',
+ 'r8_g8_b8_420_unorm',
+ 'r8_b8_g8_420_unorm',
+ 'g8_b8_r8_420_unorm',
+ 'r8_g8_b8_unorm',
+ 'y8_unorm',
]
if format.short_name() in noaccess_formats:
return False
@@ -137,9 +150,18 @@ def write_format_table(formats):
print()
write_format_table_header(sys.stdout2)
-
+
+ print('#ifdef __cplusplus', file=sys.stdout2)
+ print('extern "C" {', file=sys.stdout2)
+ print('#endif', file=sys.stdout2)
+ print(file=sys.stdout2)
+
u_format_pack.generate(formats)
-
+
+ print('#ifdef __cplusplus', file=sys.stdout2)
+ print('} /* extern "C" */', file=sys.stdout2)
+ print('#endif', file=sys.stdout2)
+
def do_channel_array(channels, swizzles):
print(" {")
for i in range(4):
@@ -173,12 +195,10 @@ def write_format_table(formats):
suffix = ""
if type == "unpack_":
suffix = "_generic"
- print("const struct util_format_%sdescription *" % type)
+ print("ATTRIBUTE_RETURNS_NONNULL const struct util_format_%sdescription *" % type)
print("util_format_%sdescription%s(enum pipe_format format)" % (type, suffix))
print("{")
- print(" if (format >= ARRAY_SIZE(util_format_%sdescriptions))" % (type))
- print(" return NULL;")
- print()
+ print(" assert(format < PIPE_FORMAT_COUNT);")
print(" return &util_format_%sdescriptions[format];" % (type))
print("}")
print()
@@ -187,15 +207,13 @@ def write_format_table(formats):
print("util_format_%s_func_ptr" % func)
print("util_format_%s_func(enum pipe_format format)" % (func))
print("{")
- print(" if (format >= ARRAY_SIZE(util_format_%s_table))" % (func))
- print(" return NULL;")
- print()
+ print(" assert(format < PIPE_FORMAT_COUNT);")
print(" return util_format_%s_table[format];" % (func))
print("}")
print()
print('static const struct util_format_description')
- print('util_format_descriptions[] = {')
+ print('util_format_descriptions[PIPE_FORMAT_COUNT] = {')
for format in formats:
sn = format.short_name()
@@ -221,7 +239,7 @@ def write_format_table(formats):
generate_table_getter("")
print('static const struct util_format_pack_description')
- print('util_format_pack_descriptions[] = {')
+ print('util_format_pack_descriptions[PIPE_FORMAT_COUNT] = {')
for format in formats:
sn = format.short_name()
@@ -250,7 +268,7 @@ def write_format_table(formats):
print()
generate_table_getter("pack_")
print('static const struct util_format_unpack_description')
- print('util_format_unpack_descriptions[] = {')
+ print('util_format_unpack_descriptions[PIPE_FORMAT_COUNT] = {')
for format in formats:
sn = format.short_name()
@@ -290,7 +308,7 @@ def write_format_table(formats):
generate_table_getter("unpack_")
- print('static const util_format_fetch_rgba_func_ptr util_format_fetch_rgba_table[] = {')
+ print('static const util_format_fetch_rgba_func_ptr util_format_fetch_rgba_table[PIPE_FORMAT_COUNT] = {')
for format in formats:
sn = format.short_name()