mirror of https://gitlab.freedesktop.org/mesa/mesa
meson: use glslang --depfile argument when possible
This reduces the amount of manual dependency tracking developers need to do. This is turned on if glslang >= 11.3.0 is used, or 11.9.0 on Windows, but otherwise the status quo is maintained. This means I have not removed any use of `depend_files`. We could make make these hard requirements and remove the use of `depend_files` too. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28329>
This commit is contained in:
parent
32e43fe77c
commit
46644ba371
16
meson.build
16
meson.build
|
@ -623,8 +623,22 @@ if vdpau_drivers_path == ''
|
|||
vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau')
|
||||
endif
|
||||
|
||||
prog_glslang = find_program('glslangValidator', native : true, required : with_vulkan_overlay_layer or with_aco_tests or with_amd_vk or with_intel_vk)
|
||||
# GLSL has interesting version output and Meson doesn't parse it correctly as of
|
||||
# Meson 1.4.0
|
||||
prog_glslang = find_program('glslangValidator', native : true,
|
||||
required : with_vulkan_overlay_layer or with_aco_tests or with_amd_vk or with_intel_vk)
|
||||
if prog_glslang.found()
|
||||
# Check if glslang has depfile support. Support was added in 11.3.0, but
|
||||
# Windows path support was broken until 11.9.0.
|
||||
#
|
||||
# It is intentional to check the build machine, since we need to ensure that
|
||||
# glslang will output valid paths on the build platform
|
||||
_glslang_check = build_machine.system() == 'windows' ? '>= 11.9.0' : '>= 11.3.0'
|
||||
if run_command(prog_glslang, ['--version'], check : false).stdout().split(':')[2].version_compare(_glslang_check)
|
||||
glslang_depfile = ['--depfile', '@DEPFILE@']
|
||||
else
|
||||
glslang_depfile = []
|
||||
endif
|
||||
if run_command(prog_glslang, [ '--quiet', '--version' ], check : false).returncode() == 0
|
||||
glslang_quiet = ['--quiet']
|
||||
else
|
||||
|
|
|
@ -91,6 +91,8 @@ class Shader:
|
|||
if self.target_env:
|
||||
args += ['--target-env', self.target_env]
|
||||
args += ['-o', out_file.name, in_file.name]
|
||||
if depfile is not None:
|
||||
args.extend(['--depfile', depfile])
|
||||
with subprocess.Popen(args,
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE,
|
||||
|
@ -300,6 +302,8 @@ def parse_args():
|
|||
default='glslangValidator',
|
||||
dest='glslang',
|
||||
help='Full path to the glslangValidator shader compiler.')
|
||||
p.add_argument('--depfile', metavar='DEPFILE', default=None, action="store",
|
||||
help="Where to have glslang write a depfile")
|
||||
p.add_argument('infile', metavar='INFILE')
|
||||
|
||||
return p.parse_args()
|
||||
|
@ -309,6 +313,7 @@ args = parse_args()
|
|||
infname = args.infile
|
||||
outfname = args.outfile
|
||||
glslang = args.glslang
|
||||
depfile = args.depfile
|
||||
|
||||
with open_file(infname, 'r') as infile:
|
||||
parser = Parser(infile)
|
||||
|
|
|
@ -30,10 +30,16 @@ spirv_files = files(
|
|||
'test_d3d11_derivs.cpp',
|
||||
)
|
||||
|
||||
gen_spirv = generator(prog_python,
|
||||
output : '@BASENAME@-spirv.h',
|
||||
arguments : [join_paths(meson.current_source_dir(), 'glsl_scraper.py'),
|
||||
'@INPUT@', '--with-glslang', prog_glslang.full_path(), '-o', '@OUTPUT@'])
|
||||
gen_spirv = generator(
|
||||
prog_python,
|
||||
output : '@BASENAME@-spirv.h',
|
||||
arguments : [
|
||||
join_paths(meson.current_source_dir(), 'glsl_scraper.py'),
|
||||
'@INPUT@', '--with-glslang', prog_glslang.full_path(), '-o', '@OUTPUT@',
|
||||
glslang_depfile,
|
||||
],
|
||||
depfile: '@BASENAME@-spriv.h.d',
|
||||
)
|
||||
gen_spirv_files = gen_spirv.process(spirv_files)
|
||||
|
||||
test(
|
||||
|
|
|
@ -72,19 +72,21 @@ bvh_includes = files(
|
|||
bvh_spv = []
|
||||
foreach s : bvh_shaders
|
||||
command = [
|
||||
prog_glslang, '-V', '-I' + bvh_include_dir, '--target-env', 'spirv1.5', '-x', '-o', '@OUTPUT@', '@INPUT@'
|
||||
prog_glslang, '-V', '-I' + bvh_include_dir, '--target-env', 'spirv1.5',
|
||||
'-x', '-o', '@OUTPUT@', '@INPUT@', glslang_depfile, glslang_quiet,
|
||||
]
|
||||
command += glslang_quiet
|
||||
|
||||
foreach define : s[2]
|
||||
command += '-D' + define
|
||||
endforeach
|
||||
|
||||
_bvh_name = '@0@.spv.h'.format(s[1])
|
||||
bvh_spv += custom_target(
|
||||
s[1] + '.spv.h',
|
||||
_bvh_name,
|
||||
input : s[0],
|
||||
output : s[1] + '.spv.h',
|
||||
output : _bvh_name,
|
||||
command : command,
|
||||
depfile : f'@_bvh_name@.d',
|
||||
depend_files: bvh_includes
|
||||
)
|
||||
endforeach
|
||||
|
|
|
@ -26,10 +26,16 @@ shader_include_files = files(
|
|||
|
||||
radix_sort_spv = []
|
||||
foreach s : radix_sort_shaders
|
||||
_name = f'@s@.spv.h'
|
||||
radix_sort_spv += custom_target(
|
||||
s + '.spv.h',
|
||||
_name,
|
||||
input : s,
|
||||
output : s + '.spv.h',
|
||||
command : [prog_glslang, '-V', '-I' + shader_include_dir, '--target-env', 'spirv1.3', '-x', '-o', '@OUTPUT@', '@INPUT@'] + glslang_quiet,
|
||||
depend_files: shader_include_files)
|
||||
output : _name,
|
||||
command : [
|
||||
prog_glslang, '-V', '-I' + shader_include_dir, '--target-env', 'spirv1.3',
|
||||
'-x', '-o', '@OUTPUT@', '@INPUT@', glslang_quiet, glslang_depfile,
|
||||
],
|
||||
depfile : f'@_name@.d',
|
||||
depend_files : shader_include_files,
|
||||
)
|
||||
endforeach
|
||||
|
|
|
@ -13,7 +13,9 @@ if with_intel_vk
|
|||
'--vn', 'float64_spv_source',
|
||||
'--glsl-version', '450',
|
||||
'-Olib',
|
||||
]
|
||||
glslang_depfile,
|
||||
],
|
||||
depfile : 'float64_spv.h.d',
|
||||
)
|
||||
endif
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ if T.TYPE_CHECKING:
|
|||
extra: T.Optional[str]
|
||||
vn: str
|
||||
stage: str
|
||||
includes: T.List[str]
|
||||
defines: T.List[str]
|
||||
depfile: T.Optional[str]
|
||||
|
||||
|
||||
def get_args() -> 'Arguments':
|
||||
|
@ -84,6 +87,12 @@ def get_args() -> 'Arguments':
|
|||
default=[],
|
||||
action='append',
|
||||
help="Defines")
|
||||
|
||||
parser.add_argument('--depfile',
|
||||
dest="depfile",
|
||||
default=None,
|
||||
action='store',
|
||||
help='Where glslangValidator should write its depfile, if unset no depfile will be written.')
|
||||
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
@ -170,6 +179,9 @@ def process_file(args: 'Arguments') -> None:
|
|||
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])
|
||||
|
||||
for f in args.includes:
|
||||
cmd_list.append('-I' + f)
|
||||
|
||||
|
|
|
@ -24,9 +24,17 @@ overlay_shaders = [
|
|||
]
|
||||
overlay_spv = []
|
||||
foreach s : ['overlay.frag', 'overlay.vert']
|
||||
_name = f'@s@.spv.h'
|
||||
overlay_spv += custom_target(
|
||||
s + '.spv.h', input : s, output : s + '.spv.h',
|
||||
command : [prog_glslang, '-V', '-x', '-o', '@OUTPUT@', '@INPUT@'] + glslang_quiet)
|
||||
_name,
|
||||
input : s,
|
||||
output : _name,
|
||||
command : [
|
||||
prog_glslang, '-V', '-x', '-o', '@OUTPUT@', '@INPUT@', glslang_quiet,
|
||||
glslang_depfile,
|
||||
],
|
||||
depfile : f'@_name@.d',
|
||||
)
|
||||
endforeach
|
||||
|
||||
vklayer_files = files(
|
||||
|
|
|
@ -295,7 +295,11 @@ if prog_glslang.found()
|
|||
'astc_spv.h',
|
||||
input : astc_decoder_glsl_file,
|
||||
output : 'astc_spv.h',
|
||||
command : [prog_glslang, '-V', '-S', 'comp', '-x', '-o', '@OUTPUT@', '@INPUT@'] + glslang_quiet,
|
||||
command : [
|
||||
prog_glslang, '-V', '-S', 'comp', '-x', '-o', '@OUTPUT@', '@INPUT@',
|
||||
glslang_quiet, glslang_depfile,
|
||||
],
|
||||
depfile : 'astc_spv.h.d',
|
||||
)
|
||||
endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue