Python script for compiling example shaders
This commit is contained in:
parent
ba8ff21d36
commit
be68bc0a5a
1 changed files with 31 additions and 0 deletions
31
data/shaders/compileshaders.py
Normal file
31
data/shaders/compileshaders.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue