startup: record the calls into the D3D12 stand-in and replay them offline (draft for discussion) #3208
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3208
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3206"
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?
@tedin7 on GitHub · 2026-11-27 21:43 UTC · original
tedin7:up-replay-tool→main· +7106 −4 · 30 files · 15 commits · draftPart of #870
What this unblocks: reproducing a title's D3D12 work offline, on WARP or any GPU, with the real stand-in and translator, so a runtime or translator fix can be checked against the same frames without the title.
Draft for discussion. This is large (about 6.7k lines, most of it tests and the player). It will be split into reviewable PRs before anyone is asked to review it (plan at the end). It is open now so the design can be discussed and so the refusal census in #3200 has its input documented.
What it records
X2W_REPLAY_RECORD=all,<start s>,<seconds>,f<first present>,<presents>ord<draws>,<seconds>wraps every slot of every object kind the stand-in hands out (src/startup_stubs/d3d12_record.inl) and writesX2W_REPLAY_RECORD_FILE(defaultreplay.x2wr). Unset, nothing is wrapped and nothing changes. Per call it keeps:src/startup_stubs/d3d12_replay_slots.h(generic calls copy a bounded amount), stored once per content as blobs;src/startup_stubs/replay_pages.h);X2W_settings.Each title thread appends to its own buffer (no lock shared between title threads per call); full buffers go to the file under one lock. Size caps stop the recording cleanly with its end chunk.
File format
Chunks
<4-byte tag><u32 header bytes><u64 data bytes>, header, data (src/replay/replay_file.hreads it mapped, in place):XREC(version, timer frequency),XENV(settings),CALL,ARGM(argument memory: seq, arg, address, bytes, blob hash),BLOB(hash, bytes; once per content),OUTP(output wrapper after the call),HPLC(heap behind a slot 133 placement),DARR/DHPM(descriptor-copy arrays, caller-backed descriptor heap),PAGE/MAP(title memory pages and where they apply),SHDR(shader cache files),PRES(present),XEND(totals, dropped counts). The reader validates every chunk against its call before playing.How a replay runs
src/replay/x2w_replay.cpploads the stand-in (delay-loaded, so the recorded settings are in the environment first), reserves the recorded title ranges at their addresses, seeds the shader cache, then makes every recorded call again in sequence order on the stand-in's objects: recorded wrappers, descriptor handles, mapped and GPU addresses are rewritten to the replay's, argument memory is rebuilt from the blobs, pages are written before the first call that follows them, and fence waits wait for the recorded value. No title code runs; the stand-in, the translator and any fix run for real. It writesstderr.txt(the stand-in log),present_<nnnn>.pngper present (X2W_PRESENT_PICTURES,src/startup_stubs/d3d12_present_pictures.inl),replay_summary.json, and onex2w-replay scoreline; exit codes name the failure (bad file, a title range that cannot be reserved, no device, time limit, a slot result that differs, no adapter).What it found
Replaying recordings on WARP with the debug layer showed invalid calls that hardware drivers had tolerated; each one is its own small draft: console-format clear values (#3196), viewports, scissors and DSV formats (#3197), the presenter's allocator reset (#3198), debug-layer floods (#3199), sampler fields (#3201), UAV/RTV/DSV view fields (#3202). Shader resource view validation (MipLevels 0 from a UAV descriptor read as an SRV, depth-stencil plane slices) follows. Run on a recording with
X2W_SHADER_CACHEset,tools/startup/refusal_census.py(#3200) ranks the first shader refusals by the draws and dispatches they block.Not in this draft (follow-ups)
Split plan
startup_replay_pages,startup_replay_prefix_live,startup_replay_call_formats).startup_replay_record_*.startup_replay_*,startup_replay_determinism_*,startup_replay_submit_pages_*,startup_replay_title_ranges_warp.Tests in this draft
startup_replay_pages+ 3 WILL_FAIL mutants,startup_replay_prefix_live,startup_replay_invoke,startup_replay_call_formats,startup_replay_pages_play(pure or synthetic recordings).startup_replay_record_{warp,hardware}: a stream draw fixture recorded draws the same pixels and the file is well formed.startup_replay_{warp,hardware}and theslot_layouts,null_views,pacedvariants: a recorded scene replays to the same pictures pixel for pixel; a recording with one clear colour changed replays to a different last picture only; mutated frame token / no-op return are detected.startup_replay_determinism_{warp,hardware},startup_replay_submit_pages_{warp,hardware},startup_replay_title_ranges_warp.Verification:
x86_64-w64-mingw32-g++ -std=c++20 -fsyntax-only -fms-extensions -Isrc -Isrc/startup_stubs src/startup_stubs/d3d12_xs_device.cpp-> the same 17 errors as on main (MSVC__try/__exceptonly), no new onesx86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only -fms-extensions -Isrc src/replay/x2w_replay.cpp-> OK; same for the five new test programspython3 -m py_compile tests/startup_replay_*.py-> OKcmake -S . -B /tmp/cfg -G Ninja -DDXC_EXECUTABLE=/bin/true-> configure OK35a14b3e,x2w_pipe.py win2025 3206 --targets x2w_replay,startup_replay_quad,startup_replay_pages,startup_replay_prefix_live_check,startup_replay_submit_pages,startup_replay_invoke,startup_stream_consumer,d3d12_xs_shim --regex '^startup_replay_' --force:ctest --preset dev -R '^startup_replay_'-> 23/23 passed/O2): same -> 23/23 passedThanks to @Makto94 for the testing that found this.
AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-28 13:01 UTC · original
Update (still Draft), head
9bdc41be5. Merged current main, then added:startup_replay_execute_slot35_{warp,hardware}.X2W_REPLAY_INFER_EXECUTE=1in the player: a submit recorded without its array submits the next closed lists in Close order; a recorded array always wins. New teststartup_replay_infer_execute_{warp,hardware}.X2W_REPLAY_CARRY_MAX_MIB, default 64) and written to the file when the window first submits the list; a list the window Resets is dropped. Testsstartup_replay_static_list_*.startup_replay_static_release_*(reads the carried bytes before and after the Release).Not included: the GPU-VA binding of plain title memory, the window-start GPU snapshot and the timed-window shift. They build on replay-draw-memory and GPU-state pieces this PR does not contain, so they belong with those pieces. The pass-statistics option is also left out: it is a separate diagnostic outside this PR's scope.
Verification (aws-1, dev + release):
x2w_pipe.py win2025 3206 --host aws-1 --wait 7200 --regex '^startup_replay_' --force: 31/31 passed on both legs.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-28 22:08 UTC · original
Status update, still Draft: merged current
main(merge commit, no force push, no conflicts); head is now8494b98cd.Verification (Windows Server 2025, D3D12 WARP, head
8494b98cd):x2w_pipe.py win2025 3206 --regex '^startup_replay'-> 31/31 passed.This stays Draft until an independent review of the head. @KelboLive or @MasterDomino, a review of this head would be welcome; after that I will mark it Ready.
AI-assisted; commands listed were executed locally.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.