util/glsl2spirv: Use better glslang flag for -Olib

--create-unlinked also creates entrypoints for the functions, and
obviates the need to create a dummy entrypoint. This is one step closer
to removing glsl2spirv and aligns us with other users of glslang.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38088>
This commit is contained in:
Connor Abbott 2025-10-07 18:27:02 -04:00 committed by Marge Bot
parent 9e3bc1f123
commit 3b3954e2b8
2 changed files with 2 additions and 16 deletions

View file

@ -9,7 +9,6 @@ if with_intel_vk
command : [
prog_python, '@INPUT@', '@OUTPUT@',
prog_glslang,
'--create-entry', 'main',
'--vn', 'float64_spv_source',
'--glsl-version', '450',
'-Olib',

View file

@ -49,10 +49,6 @@ def get_args() -> 'Arguments':
parser.add_argument('output', help="Name of output file.")
parser.add_argument('glslang', help="path to glslangValidator")
parser.add_argument("--create-entry",
dest="create_entry",
help="Create a new entry point and put to the end of a file.")
parser.add_argument('--glsl-version',
dest="glsl_ver",
choices=['100', '110', '120', '130', '140', '150', '300es', '310es', '330', '400', '410', '420', '430', '440', '450', '460'],
@ -146,15 +142,12 @@ def postprocess_file(args: 'Arguments') -> None:
def preprocess_file(args: 'Arguments', origin_file: T.TextIO, directory: os.PathLike, filemap: T.Dict[str, str]) -> str:
if args.create_entry is None and args.glsl_ver is None:
if args.glsl_ver is None:
return origin_file.name
with open(os.path.join(directory, os.path.basename(origin_file.name)), "w") as copy_file:
lines = origin_file.readlines()
if args.create_entry is not None:
lines.append(f"\nvoid {args.create_entry}() {{}}\n")
if args.glsl_ver is not None:
override_version(lines, args.glsl_ver)
@ -194,7 +187,7 @@ def process_file(args: 'Arguments') -> None:
cmd_list = [args.glslang]
if args.Olib:
cmd_list.append("--keep-uncalled")
cmd_list.append("--no-link")
if args.vn is not None:
cmd_list.extend(["--variable-name", args.vn])
@ -202,9 +195,6 @@ def process_file(args: 'Arguments') -> None:
if args.extra is not None:
cmd_list.append(args.extra)
if args.create_entry is not None:
cmd_list.extend(["--entry-point", args.create_entry])
if args.depfile is not None:
cmd_list.extend(['--depfile', args.depfile])
@ -229,9 +219,6 @@ def process_file(args: 'Arguments') -> None:
if args.vn is not None:
postprocess_file(args)
if args.create_entry is not None:
os.remove(copy_file)
if args.depfile is not None:
fixup_depfile(args.depfile, filemap)