Shader hot reload #27

Open
UnflavoredMeson/Primal_Plus_Plus
opened 2026-11-24 20:15:56 +00:00 by UnflavoredMeson · 0 comments
Owner

Why

Editing a shader and seeing it change without restarting is the fastest way to learn and debug rendering.

Decided

  • watch_engine_shaders(), watch_shader_pack(manifest, groups, platform), shader_hot_reload::update() between frames, stop() before the groups go.
  • Compiles in a background job; applies with content::update_shader_group() + graphics::reload_shaders(), which rebuilds every pipeline in place (render items keep their pipeline ids). Pipelines remember their sources; pipeline caches are keyed by shader hashes, not byte-code pointers.
  • The editor hook comes in S7-03. The compiler becomes a library in S6-09.

Read first

  • UnflavoredMeson/Primal#46.

Steps

  • 1. Write a test that changes a shader group's byte code and checks the pipeline id stays and the source serial changes.
  • 2. Write the watcher and the background compile.
  • 3. Add reload_shaders() to the D3D12 backend (Vulkan gets it in S6).
  • 4. Edit TestShader.hlsl while the renderer test runs.

Done when

  • A shader edit shows in the running renderer test on D3D12; tests pass; 0 warnings; tidy 0.

Claude can help with

  • File-watching differences between Linux (inotify) and Windows.

Learn

  • Why pipeline ids, not pipeline objects, let you swap shaders under running render items.
## Why Editing a shader and seeing it change without restarting is the fastest way to learn and debug rendering. ## Decided - `watch_engine_shaders()`, `watch_shader_pack(manifest, groups, platform)`, `shader_hot_reload::update()` between frames, `stop()` before the groups go. - Compiles in a background job; applies with `content::update_shader_group()` + `graphics::reload_shaders()`, which rebuilds every pipeline in place (render items keep their pipeline ids). Pipelines remember their sources; pipeline caches are keyed by shader hashes, not byte-code pointers. - The editor hook comes in S7-03. The compiler becomes a library in S6-09. ## Read first - `UnflavoredMeson/Primal#46`. ## Steps - [ ] 1. Write a test that changes a shader group's byte code and checks the pipeline id stays and the source serial changes. - [ ] 2. Write the watcher and the background compile. - [ ] 3. Add `reload_shaders()` to the D3D12 backend (Vulkan gets it in S6). - [ ] 4. Edit `TestShader.hlsl` while the renderer test runs. ## Done when - [ ] A shader edit shows in the running renderer test on D3D12; tests pass; 0 warnings; tidy 0. ## Claude can help with - File-watching differences between Linux (inotify) and Windows. ## Learn - Why pipeline ids, not pipeline objects, let you swap shaders under running render items.
Sign in to join this conversation.
No assignees
No project
No milestone
Blocks Depends on
#16 Job system module primal.jobs
UnflavoredMeson/Primal_Plus_Plus
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
UnflavoredMeson/Primal_Plus_Plus#27
No description provided.