#!/usr/bin/env python3 """Rebuild the embedded Vulkan shaders with glslc; Metal uses the same source semantics.""" from pathlib import Path import subprocess import tempfile root = Path(__file__).resolve().parents[1] parts = ['// Generated by tools/compile_scene_shaders.py; do not edit.\n#pragma once\n'] with tempfile.TemporaryDirectory() as tmp: for stage in ('vert', 'frag'): source = root / 'src/eter_render/shaders' / ('scene.' + stage) binary = Path(tmp) / stage subprocess.run(['glslc', str(source), '-o', str(binary)], check=True) data = binary.read_bytes() parts.append('alignas(4) inline constexpr unsigned char scene_' + stage + '_spv[] = {\n') for start in range(0, len(data), 24): parts.append(','.join(str(v) for v in data[start:start+24]) + ',\n') parts.append('};\n') (root / 'src/eter_render/shaders/SceneSpirv.h').write_text(''.join(parts))