The GPU renderer previously read .spv files from a cwd-relative path at runtime; when they were missing or the editor was launched from outside the repo root, it silently fell back to the SDL renderer, losing syntax highlighting. The shaders are now baked in at compile time, so the binary is self-contained. The compiled .spv files are committed (no longer gitignored) since they are required to build; regenerate with scripts/compile-shaders.sh after editing the GLSL sources. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1.6 KiB
1.6 KiB
SDL3 GPU Shader Toolchain
SDL3 GPU accepts different shader formats depending on the selected backend:
- Vulkan: SPIR-V
- D3D12: DXBC or DXIL
- Metal: MSL or metallib
For this Linux-first prototype, use GLSL compiled to SPIR-V with glslc from shaderc.
scripts/compile-shaders.sh
Outputs are written to client/odin/shaders/compiled/ and are committed to git: the Odin client embeds them at compile time with #load, so they must exist to build. After editing the GLSL sources, rerun the script and rebuild the client.
Fedora install:
sudo dnf install glslc
Cross-platform path later:
- Use SDL_shadercross for offline conversion from SPIR-V or HLSL to backend-specific shader formats.
- Keep source shaders in git.
- Generate SPIR-V/DXIL/MSL in CI or release packaging.
- At runtime, choose the shader blob matching
SDL.GetGPUDeviceDriver(device)orSDL.GetGPUShaderFormats(device).
Current recommendation:
- Build Linux/Vulkan first with checked-in GLSL sources and generated SPIR-V as build artifacts.
- Add SDL_shadercross only when Windows/macOS backends matter.
Current renderer state:
- The editor embeds
rect.vert.spvandrect.frag.spvfor the direct SDL3 GPU path. - The editor embeds
text.vert.spvandtext.frag.spvfor font-atlas text. - The binary has no runtime dependency on the shader files; they are baked in at build time.
- Text is rendered from a baked
stb_truetypeatlas using/usr/share/fonts/google-noto/NotoSansMono-Regular.ttf. - A later portability step should bundle a project font or add configurable font discovery.