util/format: expose generated format packing functions through a header
Some of the generated functions can be useful without going through the format table (filling border color struct in turnip). By not calling these functions through the format table, we should eventually be able to garbage collect the unused packing functions, and also allows LTOs to happen. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6093>
This commit is contained in:
committed by
Marge Bot
parent
a322924d9c
commit
84ed2d0980
@@ -30,7 +30,7 @@ CopyRight = '''
|
||||
'''
|
||||
|
||||
|
||||
import sys
|
||||
import sys, os
|
||||
|
||||
from u_format_parse import *
|
||||
import u_format_pack
|
||||
@@ -112,19 +112,24 @@ def has_access(format):
|
||||
return False
|
||||
return True
|
||||
|
||||
def write_format_table(formats):
|
||||
print('/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */')
|
||||
print()
|
||||
def write_format_table_header(file):
|
||||
print('/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */', file=file)
|
||||
print(file=file)
|
||||
# This will print the copyright message on the top of this file
|
||||
print(CopyRight.strip())
|
||||
print()
|
||||
print('#include "u_format.h"')
|
||||
print(CopyRight.strip(), file=file)
|
||||
print(file=file)
|
||||
print('#include "util/format/u_format.h"', file=file)
|
||||
|
||||
def write_format_table(formats):
|
||||
write_format_table_header(sys.stdout)
|
||||
print('#include "u_format_bptc.h"')
|
||||
print('#include "u_format_s3tc.h"')
|
||||
print('#include "u_format_rgtc.h"')
|
||||
print('#include "u_format_latc.h"')
|
||||
print('#include "u_format_etc.h"')
|
||||
print()
|
||||
|
||||
write_format_table_header(sys.stdout2)
|
||||
|
||||
u_format_pack.generate(formats)
|
||||
|
||||
@@ -261,12 +266,19 @@ def write_format_table(formats):
|
||||
generate_table_getter("unpack_")
|
||||
|
||||
def main():
|
||||
|
||||
formats = []
|
||||
for arg in sys.argv[1:]:
|
||||
formats.extend(parse(arg))
|
||||
write_format_table(formats)
|
||||
|
||||
sys.stdout2 = open(os.devnull, "w")
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
if arg == '--header':
|
||||
sys.stdout2 = sys.stdout
|
||||
sys.stdout = open(os.devnull, "w")
|
||||
continue
|
||||
|
||||
formats.extend(parse(arg))
|
||||
|
||||
write_format_table(formats)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user