Skip to content

WGSL Shaders Through Naga

Scene shaders are written once in WGSL, and a generator with a pinned Naga translates them into the programs that each backend of the graphics layer loads.

Field Value
ID REN-10
Status Shipped
Scope Core
Pillar Rendering and 3-D
Sprint None
Depends On Graphics Layer (REN-09)
Unblocks Scene Core (REN-11)
WebGPU Backend of the Graphics Layer (REN-13)
Vulkan Backend of the Graphics Layer (REN-53)
Docs Shader Authoring, Translator
Branches None
Design None

Coverage Ledger

  • Branch sprint4-build, 165 commits, none outside sprint4-integ3. Head of pull request 1 (546bacaa): sprint 4 through demo 0 with every review fix.
  • Branch sprint4-integ3, 209 commits not on main, the superset of the finished build branches; the six branches draws, rec, tex, time, ts9, points hold 30 commits outside it. Third integration branch: every finished build branch (protocol 3.2 series, step 5, 7, 9, scale bar, up-axis, rest of scene calls, first draws commit).
  • Branch sprint4-pr1-main2, 165 commits, none outside sprint4-integ3. Pull request 1 candidate, 546bacaa with main merged in.
  • Branch sprint4-shaders, 12 commits, none outside sprint4-integ3. The shader generator with Naga.
  • Branch sprint4-integ3, ca2aebb7, 3d1fc8fd, bc87fa60, a67fc22f, cf7b56cf. The shader generator: WGSL sources translated by a pinned Naga 30.0.2 driver into MSL, SPIR-V and WGSL programs, with a regeneration check.
  • Branch sprint4-integ3, 9e748d41, 8f8835b3, e7afd3e6, 1db29207, 340f2183, a10abdfa. Shader tests, CI and guide: headless Metal compile test, Chromium WGSL compile spec, CI without -Werror, the Write a shader guide, Naga in the licence table.
  • design/producer-runtime.md, under Read-Only Rule. Naga validation, the binder rule and a read-only import in the layer refuse a write to a training tensor.
  • design/renderer-core.md on the branch sprint4, under Shader copies. Hand-written shader copies: colormap four times, points three times, geometry twice.
  • design/renderer-core.md on the branch sprint4, under One shader source. Every shader is written once in WGSL and translated to MSL and SPIR-V by a pinned Naga, with the generated sources checked in and regenerated in CI.
  • design/renderer-core.md on the branch sprint4, under The options. Slang, Naga, Tint and hand-written copies compared.
  • design/renderer-core.md on the branch sprint4, under A trial translation. A trial translation of three small shaders through Slang.
  • design/renderer-core.md on the branch sprint4, under Recommendation. The recommendation to write WGSL, translate with Naga and allow a hand-written native version of a shader, with CUDA kernels staying hand-written.
  • design/renderer-core.md on the branch sprint4, under The steps. Step 2, shader generator with WGSL sources, pinned Naga and the scene programs; 3 days.
  • design/renderer-core.md on the branch sprint4, under Decisions. Decisions on WGSL as the one source through Naga, hand-written native versions, CUDA kernels, integer keys for the colormap, conventions, no immediate data, and ImGui keeping its backends.
  • design/roadmap.md, under Renderers. Renderers 3: evaluate writing each shader once and translating it, for example with Slang; the WebGPU backend's two shaders are hand-written WGSL for now.
  • design/roadmap.md on the branch sprint4, under Renderers. The rewritten Renderers section: Metal and Vulkan backends of a thin graphics layer, GLEW retired now, one WebGPU backend with the Dawn fallback landing with Windows parity, shaders written once in WGSL and translated by Naga, a scene service for applets, and one version of each graphics service.
  • design/roadmap.md on the branch sprint4, under Scenes and recordings. The renderer core part: one graphics layer, one shader source, a shared scene core, zero-copy as an import capability, GLEW retired early, views moved onto the layer, TypeScript WebGPU views removed, a scene service replacing the geometry service, one version of each graphics service with one epoch bump.
  • design/sprint-4.md on the branch sprint4, under 0. The renderer core's minimum cut. Increment 0 as a whole: a quad and a one-entity scene drawn through the graphics layer on Metal and read back byte for byte, scene programs compiled on Metal and in a browser, the sprint 2 heatmap and points drawn unchanged in a browser through the layer (22 days).
  • design/sprint-4.md on the branch sprint4, under 0. The renderer core's minimum cut. Step 2, the shader generator with pinned Naga and the scene programs (3 days).
  • design/sprint-4.md on the branch sprint4, under 1. A loss landscape in a notebook. Their WGSL and the index clamp's, in the one shader source (2 of 4 days).
  • design/sprint-4.md on the branch sprint4, under 4. Every primitive in the browser, and the scene model's additions. Their WGSL, and moving the drafted shaders into the one source (2 of 4 days).
  • design/web-geometry.md on the branch sprint4, under Shader sources. The WGSL as seven blocks plus the index clamp module, now the one shader source in src/host/gfx/shaders/.
  • design/web-geometry.md on the branch sprint4, under Declarations. Declarations, bind group layout and parameter structs of the scene WGSL.
  • design/web-geometry.md on the branch sprint4, under The point shaders. Point shaders, vs_points and the depth point shader.
  • design/web-geometry.md on the branch sprint4, under The line and arrow shaders. Line and arrow shaders, vs_lines.
  • design/web-geometry.md on the branch sprint4, under The box shaders. Box edge and box face shaders.
  • design/web-geometry.md on the branch sprint4, under The mesh shaders. Mesh shaders and their three fragment stages.
  • design/web-geometry.md on the branch sprint4, under The image shaders. Image shaders for colour, depth value and class images.
  • design/web-geometry.md on the branch sprint4, under The index clamp. The index clamp and edge gather compute module, with a noted limit above 4,194,240 indices.
  • design/web-geometry.md on the branch sprint4, under Work items. Scene shaders in WGSL by hand then moved into the one shader source; 3 days and 1 for the move.
  • design/windows-parity.md on the branch sprint4-pr1-main2, under 7. Renderer fallbacks. The Windows build loses its build-time glslang; the Vulkan backend takes SPIR-V that Naga generates from the WGSL sources.
  • Orchestrators' notes, _notes/HANDOFF-sprint4.md. Pull request 1 content is finished and held on sprint4-pr1-main2 at 44840c5b: graphics layer, shader generation, scene core, scene view, WebGPU backend, colormap by keys, protocol 3.2 subset, caliper.scene and demo 0.
  • Orchestrators' notes, _notes/HANDOFF-sprint4.md. The reviewer's major findings were fixed with tests: the hub's retained scene state bound, a queued Metal write ordering, index clamps of an unsubmitted frame, scene buffer release on reset, the viewer queue never dropping a reset, the browser recolour check, and the demo grid orientation.
  • Orchestrators' notes, _notes/SPRINT4-BUILD.md. Rule that each migration step replaces the old code and deletes it in the same series, with no dual paths and no backwards compatibility in the graphics API.
  • Orchestrators' notes, _notes/SPRINT4-BUILD.md. Decision: the shader translator is a pinned Naga run at developer time; generated MSL and SPIR-V are committed and a check regenerates them; building Caliper needs no Rust.
  • Orchestrators' notes, s4-shaders/STATUS.md. Generated uniform structs, ProgramDesc tables and MSL, SPIR-V and WGSL for the scene programs, with generate.py --check, a SPIR-V validation script and a CI workflow.
  • Orchestrators' notes, s4-shaders/STATUS.md. docs/guides/write-a-shader.md describes how to write a shader program.

Roadmap Graph Feature in Graph