Skip to content

Commit

Permalink
build: shader compiler: Support custom glslangValidator args in gener…
Browse files Browse the repository at this point in the history
…ator
  • Loading branch information
LDAP committed Aug 7, 2024
1 parent da48ec6 commit 579d415
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ else
shader_generator_deps = [glslc_tgt]
endif

spv_compile_script = [meson.project_source_root() + '/scripts/compile_shader.py', '--glslc_path', glslc_path, '@EXTRA_ARGS@']
spv_compile_script = [meson.project_source_root() + '/scripts/compile_shader.py', '--glslc_path', glslc_path]
glslc_args = ['--target-env', 'vulkan1.3']
glslc_args += ['-I' + meson.project_source_root()]
glslc_args += ['-I' + join_paths(project_root, 'src')]
Expand All @@ -125,7 +125,7 @@ shader_generator = generator(
py,
output: ['@[email protected]', '@[email protected]'],
depfile: '@[email protected]',
arguments: spv_compile_script + ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@'] + glslc_args,
arguments: spv_compile_script + ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@'] + glslc_args + ['@EXTRA_ARGS@'],
depends: shader_generator_deps
)

Expand Down
10 changes: 5 additions & 5 deletions scripts/compile_shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def main():
parser.add_argument("shader_path", type=Path)
parser.add_argument("header_path", type=Path)
parser.add_argument("implementation_path", type=Path)
parser.add_argument("glslc_args", nargs=argparse.REMAINDER)
args = parser.parse_args()
args, glslc_args = parser.parse_known_args()
if args.debug:
print(args)
print(f"glslc args: {glslc_args}")
print(f"cwd {os.getcwd()}")

shader_name = re.sub(
Expand Down Expand Up @@ -96,7 +96,7 @@ def main():
print(f"wrote header to {args.header_path}")

spv = compile_shader(
args.glslc_path, args.shader_path, args.glslc_args, args.optimize
args.glslc_path, args.shader_path, glslc_args, args.optimize
)
implementation = """\
#include "stdint.h"
Expand Down Expand Up @@ -124,8 +124,8 @@ def main():
if args.debug:
print(f"wrote implementation to {args.implementation_path}")

if "--depfile" in args.glslc_args:
depfile_path = args.glslc_args[args.glslc_args.index("--depfile") + 1]
if "--depfile" in glslc_args:
depfile_path = glslc_args[glslc_args.index("--depfile") + 1]
if args.debug:
print(f"fixup depfile {depfile_path}")
with open(depfile_path, "r") as f:
Expand Down

0 comments on commit 579d415

Please sign in to comment.