replay: more than one capture in a run (LEONIDA_RECORD_MORE) #2
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from klong4/kuma. Originally posted by DoluTattoo on 2026-12-03T02:11:36Z.
Claimed in the coordination issue as: n/a (no open "Coordinating who works on what" issue found)
What and why
The frame recorder takes one capture per process. Comparing several moments of the same session (an hour of the
day, a place, a weather) then means one launch of the title for each, which is slow and does not keep the rest of the
session's state.
With
LEONIDA_RECORD_MORE=1, once a capture is written (or failed) the trigger filegois moved into thatcapture's folder, and the recorder waits. A new
goarms it again and the next capture goes to the nextcapture-<n>.shaders.bingrows for the whole run and a frame names shader code by its place in it, so each newfolder gets a hard link to it, or a copy that is written on from then on if a link cannot be made. Each folder plays
on its own with
leonida replay. Without the variable nothing changes. Documented ind3d12/docs/replay.md.Tested
cargo build --locked --profile diag -p leonida --features diagnosticsandcargo test --locked -p leonida-gpu --features diagnostics(all pass,tests/replay.rsincluded; a new unit testcovers the folder numbering), clippy with no new warnings in the touched files. In the title: two and three captures
in one run, each read back and identical in its values to captures of the same views taken by separate runs.
GPUs tested: NVIDIA GeForce RTX 4090, driver 621.40, Windows 11 Pro
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Summary by Sourcery
Enable multiple frame captures in a single run with the opt-in
LEONIDA_RECORD_MORE=1setting.New Features:
LEONIDA_RECORD_MORE=1, placing each capture in its own numbered folder and enabling the next capture with a newgotrigger.Enhancements:
Documentation:
Tests:
Imported from klong4/kuma. Originally posted by sourcery-ai[bot] on 2026-12-03T02:11:43Z.
Reviewer's Guide
API
Add the public
Settings::moreoption and update recorder folder handling so each capture can use its own numbered folder while retaining the existing start and completion APIs.d3d12/crates/leonida-gpu/src/replay/record.rsL83-96, L429-433, L465-487 (+7 small edits)Implementation
Move each completed or failed capture’s trigger into its folder, then arm a new numbered capture when another trigger appears.
d3d12/crates/leonida-gpu/src/replay/snap.rsL111-123, L193-211 (+6 small edits)Documentation
Document the opt-in multiple-capture workflow, including trigger handling and the shared growing shader-code file.
d3d12/docs/replay.mdL20, L25-28Tests
Update existing recorder settings fixtures for the new option and test that capture folders receive increasing numbers.
d3d12/crates/leonida-gpu/src/replay/record.rsL2781-2791d3d12/crates/leonida-gpu/tests/replay.rsL1656, L1667-1668d3d12/crates/leonida-gpu/tests/replay_big.rsL353Tips and commands
Interacting with Sourcery
@sourcery-ai reviewon the pull request.issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it.@sourcery-aianywhere in the pullrequest title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time.@sourcery-ai summaryanywhere inthe pull request body to generate a PR summary at any time exactly where you
want it. You can also comment
@sourcery-ai summaryon the pull request to(re-)generate the summary at any time.
@sourcery-ai guideon the pullrequest to (re-)generate the reviewer's guide at any time.
@sourcery-ai resolveon thepull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
@sourcery-ai dismisson the pullrequest to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!Customizing Your Experience
Access your dashboard to:
summary, the reviewer's guide, and others.
Getting Help
Imported from klong4/kuma. Originally posted by sourcery-ai[bot] on 2026-12-03T02:15:36Z.
Code review location:
d3d12/crates/leonida-gpu/src/replay/snap.rs; line 201🟠 High · Next replay omits list commands
When
LEONIDA_RECORD_MORE=1is enabled and a command list is reset and closed between captures, before the nextgois detected,r.arm(false)leaveslist_resetmarking the list incomplete, andlist_closestores no commands; re-arming at the next trigger cannot restore them, so the next capture proceeds with a missing list and produces an incomplete replay.Keep list recording armed across captures so resets during the gap are recorded.
Prompt for AI agents
Imported from klong4/kuma. Originally posted by sourcery-ai[bot] on 2026-12-03T02:15:36Z.
Code review location:
d3d12/crates/leonida-gpu/src/replay/record.rs; line 481⚪ Low · Fallback shader copy misses concurrent writes
next_capturecopiesshaders.binbefore lockingcodes, while pipeline creation can write shader bytes and update their offsets throughRecorder::code. The new copy can omit bytes already referenced bycodes.all, so replaying the next capture reads incorrect shader data.Prompt for AI agents
Imported from klong4/kuma. Originally posted by sourcery-ai[bot] on 2026-12-03T02:15:36Z.
Code review location:
d3d12/crates/leonida-gpu/src/replay/snap.rs; line 194🟠 High · Later captures omit live resource contents
When a resource created during one capture remains live and is used in a later capture,
Recorderretains each resource's originallateflag across captures, soCapture::startexcludes resources created during an earlier capture from the next snapshot even when they are still live. Their current contents are absent from that capture, and replay starts those resources without the data the frame used.Reclassify or otherwise include surviving resources in each new capture's initial snapshot, rather than reusing the process-lifetime
lateflag.Prompt for AI agents
Imported from klong4/kuma. Originally posted by sourcery-ai[bot] on 2026-12-03T02:15:36Z.
Code review location:
d3d12/crates/leonida-gpu/src/replay/snap.rs; line 115🟡 Medium · Requested next capture is lost
When
LEONIDA_RECORD_MORE=1is enabled and a caller createsgoduring a capture,took_triggermoves that newgointo the capture that just finished, so theStage::Donecheck finds no request and the recorder waits for anothergoinstead of starting the requested capture.Track which trigger started the current capture and leave any later
goin the base folder.Also at
d3d12/crates/leonida-gpu/src/replay/snap.rs:116.Prompt for AI agents
Imported from klong4/kuma. Originally posted by sourcery-ai[bot] on 2026-12-03T02:15:36Z.
Code review location:
d3d12/crates/leonida-gpu/src/replay/snap.rs; line 115🟡 Medium · Failed rename starts repeated captures
When renaming the trigger file fails,
took_triggerand thenext_captureerror branch discard rename errors, leavinggoin the base folder;Stage::Donetreats it as a fresh request on a later present, starting another capture or retrying folder creation without a new request.Handle rename failures explicitly and prevent an unarchived
gofrom being treated as a new request.Also at
d3d12/crates/leonida-gpu/src/replay/snap.rs:193,d3d12/crates/leonida-gpu/src/replay/snap.rs:208-209.Prompt for AI agents
Imported from klong4/kuma. Originally posted by sourcery-ai[bot] on 2026-12-03T02:15:36Z.
Review: COMMENTED
Hey - I've found 7 issues
Prompt for AI Agents
Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Imported from klong4/kuma. Originally posted by sourcery-ai[bot] on 2026-12-03T02:15:37Z.
Code review location:
d3d12/crates/leonida-gpu/src/replay/record.rs; line 46🟡 Medium · Downstream struct literals stop compiling
When A downstream crate constructs
record::Settingsusing the previous public struct shape, adding the requiredmorefield makes existingSettingsstruct literals fail to compile, and the type has no constructor orDefaultfor those callers to use.Preserve compatibility with the previous public struct literals instead of requiring callers to supply a new field.
Prompt for AI agents
Imported from klong4/kuma. Originally posted by sourcery-ai[bot] on 2026-12-03T02:15:37Z.
Code review location:
d3d12/crates/leonida-gpu/src/replay/snap.rs; line 1110🟡 Medium · Later notes include old failures
When an earlier capture records a problem and a later capture finishes,
Capture::finishgets notes from recorder-wider.problems(), which is never reset between captures, so a later capture'snotes.txtreports problems from earlier captures as if they occurred in that capture.Track and reset problems per capture, or snapshot only the problems added since that capture began.
Prompt for AI agents
Pull request closed