summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-06-24 17:38:41 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2015-06-24 18:09:10 -0700
commitf4843e1286d273080734cd0cba98967761665384 (patch)
tree5f94dc02d9fb27a70e536cbd7ea401f37f27be3d /misc
parent256ea53da094e9e979ec20dc63bcba959b0fcd64 (diff)
glsl_scraper: Refactor the C code dumping
Diffstat (limited to 'misc')
-rw-r--r--misc/glsl_scraper.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/misc/glsl_scraper.py b/misc/glsl_scraper.py
index 3a495a6..a1c88c2 100644
--- a/misc/glsl_scraper.py
+++ b/misc/glsl_scraper.py
@@ -74,12 +74,9 @@ class Shader:
os.remove(glsl_fname)
os.remove(spirv_fname)
- def dump_c_code(self, f, glsl_only = False):
- f.write('\n\n')
- var_prefix = '__qonos_shader{0}'.format(self.line)
-
+ def _dump_glsl_code(self, f, var_name):
# First dump the GLSL source as strings
- f.write('static const char {0}_glsl_src[] ='.format(var_prefix))
+ f.write('static const char {0}[] ='.format(var_name))
f.write('\n__QO_SPIRV_' + self.stage)
f.write('\n"#version 330\\n"')
for line in self.glsl_source().splitlines():
@@ -88,11 +85,8 @@ class Shader:
f.write('\n"{0}\\n"'.format(line))
f.write(';\n\n')
- if glsl_only:
- return
-
- # Now dump the SPIR-V source
- f.write('static const uint32_t {0}_spir_v_src[] = {{'.format(var_prefix))
+ def _dump_spirv_code(self, f, var_name):
+ f.write('static const uint32_t {0}[] = {{'.format(var_name))
line_start = 0
while line_start < len(self.dwords):
f.write('\n ')
@@ -101,6 +95,15 @@ class Shader:
line_start += 6
f.write('\n};\n')
+ def dump_c_code(self, f, glsl_only = False):
+ f.write('\n\n')
+ var_prefix = '__qonos_shader{0}'.format(self.line)
+
+ self._dump_glsl_code(f, var_prefix + '_glsl_src')
+
+ if not glsl_only:
+ self._dump_spirv_code(f, var_prefix + '_spir_v_src')
+
token_exp = re.compile(r'(qoShaderCreateInfoGLSL|qoCreateShaderGLSL|\(|\)|,)')
class Parser: