#!/usr/bin/env python3 """spv2h.py = ...: SPIR-V como arrays uint32_t em C.""" import struct, sys out = ["/* Gerado por tools/spv2h.py a partir de src/shaders (glslc). Nao edite. */", "#ifndef TB_VK_SHADERS_H", "#define TB_VK_SHADERS_H", "#include ", ""] for arg in sys.argv[2:]: name, path = arg.split("=", 1) data = open(path, "rb").read() words = struct.unpack("<%dI" % (len(data) // 4), data) out.append("static const uint32_t %s[%d] = {" % (name, len(words))) for i in range(0, len(words), 8): out.append(" " + ", ".join("0x%08x" % w for w in words[i:i + 8]) + ",") out.append("};") out.append("") out.append("#endif") open(sys.argv[1], "w").write("\n".join(out) + "\n")