From ad1a81ba3016919b127c8abfce366bdd6c0af8e8 Mon Sep 17 00:00:00 2001 From: Vladimir Kosachev Date: Thu, 16 May 2024 01:04:22 +0700 Subject: [PATCH] Compile all shaders and count errors --- shaders/glsl/compileshaders.py | 14 ++++++++++---- shaders/hlsl/compile.py | 11 ++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/shaders/glsl/compileshaders.py b/shaders/glsl/compileshaders.py index e0a4e1f5f..a60f8ae84 100644 --- a/shaders/glsl/compileshaders.py +++ b/shaders/glsl/compileshaders.py @@ -30,6 +30,7 @@ def isExe(path): glslang_path = findGlslang() dir_path = os.path.dirname(os.path.realpath(__file__)) dir_path = dir_path.replace('\\', '/') +errors_count = 0 for root, dirs, files in os.walk(dir_path): for file in files: if file.endswith(".vert") or file.endswith(".frag") or file.endswith(".comp") or file.endswith(".geom") or file.endswith(".tesc") or file.endswith(".tese") or file.endswith(".rgen") or file.endswith(".rchit") or file.endswith(".rmiss"): @@ -43,7 +44,12 @@ def isExe(path): if file.endswith(".rgen") or file.endswith(".rchit") or file.endswith(".rmiss"): add_params = add_params + " --target-env vulkan1.2" - res = subprocess.call("%s -V %s -o %s %s" % (glslang_path, input_file, output_file, add_params), shell=True) - # res = subprocess.call([glslang_path, '-V', input_file, '-o', output_file, add_params], shell=True) - if res != 0: - sys.exit() \ No newline at end of file + result = subprocess.call("%s -V %s -o %s %s" % (glslang_path, input_file, output_file, add_params), shell=True) + if result != 0: + print('Error compiling %s' % (input_file)) + errors_count += 1 + +if errors_count == 0: + print('All shaders compiled successfully!') +else: + print('%i shaders failed to compile' % errors_count) diff --git a/shaders/hlsl/compile.py b/shaders/hlsl/compile.py index 3923c618a..453b512a0 100644 --- a/shaders/hlsl/compile.py +++ b/shaders/hlsl/compile.py @@ -32,6 +32,7 @@ def isExe(path): dxc_path = findDXC() dir_path = os.path.dirname(os.path.realpath(__file__)) dir_path = dir_path.replace('\\', '/') +errors_count = 0 for root, dirs, files in os.walk(dir_path): for file in files: if file.endswith(".vert") or file.endswith(".frag") or file.endswith(".comp") or file.endswith(".geom") or file.endswith(".tesc") or file.endswith(".tese") or file.endswith(".rgen") or file.endswith(".rchit") or file.endswith(".rmiss") or file.endswith(".mesh") : @@ -62,7 +63,7 @@ def isExe(path): profile = 'ms_6_6' print('Compiling %s' % (hlsl_file)) - subprocess.check_output([ + result = subprocess.run([ dxc_path, '-spirv', '-T', profile, @@ -76,3 +77,11 @@ def isExe(path): target, hlsl_file, '-Fo', spv_out]) + if result.returncode != 0: + print('Error compiling %s' % (hlsl_file)) + errors_count += 1 + +if errors_count == 0: + print('All shaders compiled successfully!') +else: + print('%i shaders failed to compile' % errors_count)