Repository navigation
GPU: split and flush command list segments after texture read-backs - #2608
fuzeofficlal wants to merge 1 commit into
Conversation
|
WARP verification of Environment: Windows 11. No physical GPU device was created: Commands and results:
Review notes:
Not tested: physical GPU or driver behaviour, or a retail title. WARP only. Independent review and WARP verification by Claude Code (Claude Sonnet 5.5), an AI. No game files, dumps or retail data were used. |
|
Reviewed: |
|
I reproduced #2781 by recording a real D3D12 GPU write and then invoking the guest CopyBufferRegion vtable entry. The GPU and title copies of the source both contain 0x55667788 after submission. The destination still reads the old 0x11223344 with main 13f91ca and with #2608 at 5bf6464 when both commands share a list or a submission. The separate-submission control reads the new value. 34fc326 is one commit on your exact 5bf6464. It reuses the segmentation path for a deferred buffer copy whose source overlaps a prior declared GPU write. The queue submits the current piece before preparing a later list with the same dependency. The same fixture now reads 0x55667788 in all three layouts. The disjoint-range and copy-before-write controls retain their original values and stay in one segment. Surrounding words stay intact. Six paired runs reproduced these results in both debug settings. The full serial GPU suite passed 203 tests with one ignored in each setting. Strict Clippy in both configurations and asset policy passed. If you prefer to keep this as a separate follow-up, the fork branch retains your exact PR head. Please retain the Git author on cherry-pick or rebase. If you fold the fix or test into another commit, please add the following trailer. Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com AI-assisted with Codex. Synthetic GPU commands on WARP. |
|
Thanks for the thorough reproduction and verification of |
|
Automated triage for the maintainers. Recommended for a maintainer's look. On your reply: confirmed. Generated by Claude Code |
A texture-to-buffer CopyTextureRegion (read_back) copies rows from host readback memory into title memory in HostList::defer_after once the host submission has finished. A later CopyTextureRegion (buffer-to-texture via defer_fill), CopyBufferRegion (defer_copy), CopyMemoryToMemoryX, title-written texture upload, or draw/dispatch in the same command list or same ExecuteCommandLists batch prepares its reads in run_deferred before GPU execution, reading stale title bytes from before the read-back. Track pending read-back guest byte ranges on HostList, cut the recording title list onto a fresh HostList segment when a subsequent read/write overlaps those ranges (or a draw/dispatch/title-written texture upload follows in the same list), and flush the queue piece in hold::Held::pump right after any segment with pending read-backs so its defer_after writes land before the next segment prepares its copies.
|
Rebased onto
Verified after rebase on Windows 11 (RTX 5090 + WARP): |
5bf6464 to
40d72b9
Compare
…er it; a step that reads what an earlier read-back of its list writes is said A list notes each texture the first time a draw samples it, and records its upload (or the check of it at submission) only then. A title memory copy later in the same list, or other work that may write title memory, can rewrite the texture's memory, and the draws after it read the texture as the first check left it. A copy or such work now clears the note, so the next draw that samples the texture records its check again, behind the copy (Marvisak/VIctory pull request Marvisak#2297, its test with it). A texture to buffer read-back lands in title memory once its list has run, but the list's later copies, fills and buffer refreshes read title memory at submission, before: they see the bytes from before the read-back (Marvisak pull request Marvisak#2608 cuts the list into segments there, +534 lines in list.rs, queue.rs and a hold module we do not have). Not ported until a run shows the title doing it: such a step is now counted and said in the log (at the 1st, 2nd, 4th... time), which costs nothing for the lists without read-backs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):
- Diff review: Tracking pending
read_backguest-memory ranges onHostList, cutting onto a fresh segment when subsequent copies/draws/dispatches in the same list would read those bytes, and flushing the piece viaWorld::flush_afterinHeld::pumpensures texture read-backs complete before dependent work in the same list or batch executes. cargo test -p victory-gpu hold::tests: 11 passed, 0 failed (includinga_segment_with_flush_after_runs_before_the_next_segment).cargo test -p victory-gpu resource::tests -- --test-threads=1(RTX 5090): 21 passed, 0 failed (including all 3 new read-back-then-copy tests).VICTORY_WARP=1 cargo test -p victory-gpu resource::tests -- --test-threads=1(WARP): 21 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Summary
list::read_backcopies texture rows from host readback memory into the title's buffer insideHostList::defer_after, which runs inHost::executeafter the host command lists finish on the GPU.However, a subsequent
CopyTextureRegion(buffer-to-texture viadefer_fill),CopyBufferRegion/CopyResource(defer_copy),CopyMemoryToMemoryX,title_writtentexture upload, or draw/dispatch (Shadow::refresh/bindless::uploads) prepares its title-memory reads insideHostList::run_deferredbefore GPU execution. This causes two related hazards:read_back), transitioning B, and copying Buffer B -> Texture C (or Buffer C) in one command list reads B's stale pre-readback bytes.ExecuteCommandListsbatch:hold::Held::pumpbatches consecutive ready segments on the same queue into a singlepiecepassed to oneHost::execute(&lists)call, so a second command list reading B still runsrun_deferredbefore the first list'sdefer_afterwrites B.Changes
crates/victory-gpu/src/host.rs: track pending read-back guest ranges (read_backs: Vec<(usize, usize)>) inDeferred(cleared automatically onHostList::reset()), withnote_read_back,has_read_backs, andreads_after_read_back.crates/victory-gpu/src/hold.rs&crates/victory-gpu/src/queue.rs: addWorld::flush_after(&|s| s.has_read_backs()inqueue::pump) soHeld::pumpflushespieceimmediately after any segment with pending read-backs, letting itsdefer_afterwrites land before the next segment prepares its copies.crates/victory-gpu/src/list.rs: record read-back row ranges inread_back, extract sharedcut_segment, and cut onto a freshHostListsegment only when a subsequent copy overlaps pending read-back ranges or a subsequent draw/dispatch/title_writtenupload follows in the same list (consecutive independentread_backs do not split).crates/victory-gpu/src/resource.rs&crates/victory-gpu/src/hold.rs: add unit tests covering same-listread_back -> copy_texture_region, same-listread_back -> copy_buffer_region, single-batchExecuteCommandLists(2, [list_a, list_b]), andHeld::pumpflush_afterpiece splitting.Verification
read_back -> copy_texture_regionandread_back -> copy_buffer_regionfail reading sentinel0x5Abytes instead of[1..=16]/[5..=20].--test-threads=1):read_back(4/4),hold::tests(11/11),list::tests(4/4),draw::tests(11/11),resource::tests(20/20) pass.VICTORY_D3D12_WARP=1,--features diagnostics,--test-threads=1): fullvictory-gpu --libsuite passes (202 passed; 0 failed; 1 ignored).cargo clippy -p victory-gpu --all-targets -- -D warningsand--features diagnostics— pass (0 warnings).cargo xtask policy— pass (184 files ok).