procedural-3d-engine/data/shaders/glsl/compileshaders.py
Ben Clayton ca884587a4 Move shaders into glsl and hlsl directories
Move `data/shaders` to `data/shaders/glsl`
Move `data/hlsl` to `data/shaders/hlsl`

Fix up shader paths in the cpp files to point to the new glsl location.

`data/shaders/hlsl/compile.py` still overwrites the glsl .spv files (for
now).

Issue: #723
2020-06-01 12:22:28 +01:00

31 lines
897 B
Python

import sys
import os
import glob
import subprocess
if len(sys.argv) < 2:
sys.exit("Please provide a target directory")
if not os.path.exists(sys.argv[1]):
sys.exit("%s is not a valid directory" % sys.argv[1])
path = sys.argv[1]
shaderfiles = []
for exts in ('*.vert', '*.frag', '*.comp', '*.geom', '*.tesc', '*.tese'):
shaderfiles.extend(glob.glob(os.path.join(path, exts)))
failedshaders = []
for shaderfile in shaderfiles:
print("\n-------- %s --------\n" % shaderfile)
if subprocess.call("glslangValidator -V %s -o %s.spv" % (shaderfile, shaderfile), shell=True) != 0:
failedshaders.append(shaderfile)
print("\n-------- Compilation result --------\n")
if len(failedshaders) == 0:
print("SUCCESS: All shaders compiled to SPIR-V")
else:
print("ERROR: %d shader(s) could not be compiled:\n" % len(failedshaders))
for failedshader in failedshaders:
print("\t" + failedshader)