diff options
author | Jason Ekstrand <jason.ekstrand@intel.com> | 2015-06-24 18:08:17 -0700 |
---|---|---|
committer | Jason Ekstrand <jason.ekstrand@intel.com> | 2015-06-24 18:09:10 -0700 |
commit | 8ec389e1880d2e7bfa0cb960d6936a65eda30162 (patch) | |
tree | de64d4298498f51af2a2e9977f07ba5f15509175 /misc | |
parent | db8e2a553e592246710213abe4ae199a7af96357 (diff) |
glsl_scraper: Gracefully fall back to GLSL-only if a shader fails to
compile.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/glsl_scraper.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/misc/glsl_scraper.py b/misc/glsl_scraper.py index 613780f..0f00316 100644 --- a/misc/glsl_scraper.py +++ b/misc/glsl_scraper.py @@ -31,6 +31,8 @@ class Shader: else: assert False + self.dwords = None + def add_text(self, s): self.stream.write(s) @@ -57,7 +59,7 @@ class Shader: out = open('glslang.out', 'r') sys.stderr.write(out.read()) out.close() - exit(1) + return False def dwords(f): while True: @@ -74,6 +76,8 @@ class Shader: os.remove(glsl_fname) os.remove(spirv_fname) + return True + def _dump_glsl_code(self, f, var_name): # First dump the GLSL source as strings f.write('static const char {0}[] ='.format(var_name)) @@ -101,7 +105,7 @@ class Shader: self._dump_glsl_code(f, var_prefix + '_glsl_src') - if not glsl_only: + if self.dwords and not glsl_only: self._dump_spirv_code(f, var_prefix + '_spir_v_src') f.write(dedent("""\ @@ -110,7 +114,7 @@ class Shader: .pGlsl = {0}_glsl_src, """.format(var_prefix))) - if not glsl_only: + if self.dwords and not glsl_only: f.write(dedent("""\ .spirvSize = sizeof({0}_spir_v_src), .pSpirv = {0}_spir_v_src, @@ -251,7 +255,15 @@ if not glsl_only: os.chdir(tmpdir) for shader in parser.shaders: - shader.compile() + success = shader.compile() + + # If any compile fails, we set glsl_only and bail. This way + # the entire fill will either support SPIR-V or not. If we did + # it per-shader, then we could have problems with linking a + # pipeline that's half GLSL and half SPIR-V. + if not success: + glsl_only = True + break os.chdir(current_dir) finally: |