Repository navigation
startup: record the calls into the D3D12 stand-in and replay them offline (draft for discussion) - #3206
startup: record the calls into the D3D12 stand-in and replay them offline (draft for discussion)#3206tedin7 wants to merge 15 commits into
Conversation
…mandLists (the title's slot 35) The recorder captured the array for queue slot 10 only, so a recording of a title that submits on slot 35 replayed no list. Any queue slot called with (count 1-64, readable array of list wrappers) is captured now. Adds a slot-35 scene mode and a WARP replay test. (cherry picked from commit cb3fc81)
…pture uses it (cherry picked from commit d1c7775)
…e submits recorded without their array (cherry picked from commit c89e574)
…ow into the window (cherry picked from commit f0a080f)
… it, drop it when the window Resets it (cherry picked from commit b262dfd)
… window replay test (cherry picked from commit 71be2dd)
(cherry picked from commit 0e9b856)
…ing an address reuse (cherry picked from commit b1c859f)
|
Update (still Draft), head 9bdc41b. Merged current main, then added:
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):
AI-assisted; commands listed were executed locally. |
|
Status update, still Draft: merged current Verification (Windows Server 2025, D3D12 WARP, head 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. |
Part 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 #3198 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 (#3194), viewports, scissors and DSV formats (#3195), the presenter's allocator reset (#3196), debug-layer floods (#3197), sampler fields (#3199), UAV/RTV/DSV view fields (#3200). 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(#3198) 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.