Skip to content

Commit

Permalink
Compile all shaders and count errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Kosachev committed May 15, 2024
1 parent 97b91d5 commit ad1a81b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
14 changes: 10 additions & 4 deletions shaders/glsl/compileshaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand All @@ -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()
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)
11 changes: 10 additions & 1 deletion shaders/hlsl/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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") :
Expand Down Expand Up @@ -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,
Expand All @@ -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)

0 comments on commit ad1a81b

Please sign in to comment.