| git.druid.rocks | index | militantprogrammer | astral_canvas | scripts/ | spv_to_h.py |
scripts/spv_to_h.py
#!/usr/bin/env python3
import sys
src, dst, name = sys.argv[1], sys.argv[2], sys.argv[3]
data = open(src, "rb").read()
if len(data) % 4 != 0:
sys.exit(src + ": SPIR-V size is not a multiple of 4")
words = [int.from_bytes(data[i:i + 4], "little") for i in range(0, len(data), 4)]
out = ["static const uint32_t %s[] = {\n" % name]
out.extend(" 0x%08x,\n" % w for w in words)
out.append("};\n")
open(dst, "w").write("".join(out))