Skip to content

refactor(render): each replay pass says what it is - #1281

Open
nitoygo wants to merge 2 commits into
Mutizens:mainfrom
nitoygo:refactor/replay-pass
Open

nitoygo wants to merge 2 commits into
Mutizens:mainfrom
nitoygo:refactor/replay-pass

Conversation

@nitoygo

@nitoygo nitoygo commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

What was wrong

Each replay pass in MuRendererSDLGpu.cpp told ReplayDrawCommand what it was by setting file-static flags and clearing them afterwards: s_sunShadowPass, s_sceneDepthPass, s_hdrScenePass, s_uiModelPass, s_singleSamplePass and s_replayCellFromWindow. Every draw then read those flags to pick its pipeline twins, the matrix that moves it, and its fragment uniforms. Adding a pass meant knowing which of these distant flags to set and to reset. A missed reset would leak into the next pass, and s_hdrScenePass stayed set across several passes and helpers. An independent audit of the renderer named this the main extensibility cost of the replay code. Planned passes, such as a shared scene depth for fog and screen-space effects, would each have added one more flag.

What changed

  • A ReplayPass value carries what the draws need:
    • which commands the pass draws (ReplaySelection, now at file scope);
    • which pipeline twins its target takes (single-sample, HDR scene, UI models);
    • the matrix that moves each draw: into the sun's view, or onto a UI model's atlas cell.
  • Each pass builds it and hands it down ReplayCommands and ReplayDrawCommand.
  • SceneMultisampleTexture takes the HDR choice as an argument instead of reading the flag.
  • The six flags are gone. Nothing drawn changes, and there is no render graph: the passes and their order stay as they are.

Testing

  • Fork build (same refactor plus the fork's own lighting work): run on Linux/Vulkan. In game, every pass rendered as before: sun shadow map, scene, bloom source, scene depth with MSAA and AO, UI model atlas (inventory), offscreen captures. The fork's tests and the static source-contract scripts pass.
  • This branch: passes test_pipeline_fail_fast.cmake. A separate reviewer checked every former set/clear site against the new pass values, with no behaviour change found.

🤖 Generated with Claude Code

A replay pass used to set file-wide flags (s_sunShadowPass,
s_sceneDepthPass, s_hdrScenePass, s_uiModelPass, s_singleSamplePass,
s_replayCellFromWindow) for ReplayDrawCommand to find, and clear them
after. A new pass had to know which distant state to set, and a missed
reset leaked into the next pass.

A ReplayPass value now carries what the draws need: which commands it
draws, which pipeline twins its target takes (single-sample, HDR
scene, UI models) and the matrix that moves each draw (the sun's
view, a UI model's atlas cell). The passes build it and hand it down
ReplayCommands and ReplayDrawCommand. Nothing drawn changes.
Keeps main's skip of every draw while the frame's vertices are not staged,
with this branch's ReplayDrawCommand signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant