diff options
author | Jason Ekstrand <jason.ekstrand@intel.com> | 2015-06-24 20:23:37 -0700 |
---|---|---|
committer | Jason Ekstrand <jason.ekstrand@intel.com> | 2015-06-24 20:23:37 -0700 |
commit | 52ac022cf1fb21298f69684dca111dfba5fb918b (patch) | |
tree | 1c115bb298b7d7e9c83ed645378e393b7641b661 /misc | |
parent | c4bcbed1252c2e4c11567a17e85d558e524ef0c4 (diff) |
glsl_scraper: Dump the SPIR-V assembly code as a comment in the header
Diffstat (limited to 'misc')
-rw-r--r-- | misc/glsl_scraper.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/misc/glsl_scraper.py b/misc/glsl_scraper.py index 0f00316..ece63dc 100644 --- a/misc/glsl_scraper.py +++ b/misc/glsl_scraper.py @@ -54,12 +54,16 @@ class Shader: glsl_file.close() out = open('glslang.out', 'wb') - err = subprocess.call([glslang, '-V', glsl_fname], stdout=out) + err = subprocess.call([glslang, '-H', '-V', glsl_fname], stdout=out) + out.close() + out = open('glslang.out', 'r') if err != 0: - out = open('glslang.out', 'r') sys.stderr.write(out.read()) - out.close() return False + else: + self.assembly = out.readlines() + + out.close() def dwords(f): while True: @@ -90,6 +94,19 @@ class Shader: f.write(';\n\n') def _dump_spirv_code(self, f, var_name): + f.write('/* SPIR-V Assembly:\n') + f.write(' *\n') + preamble = True + for line in self.assembly: + if preamble and line.startswith('// Module'): + preamble = False + + if preamble: + continue + + f.write(' * ' + line) + f.write(' */\n') + f.write('static const uint32_t {0}[] = {{'.format(var_name)) line_start = 0 while line_start < len(self.dwords): |