Repository navigation
Conversation
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed and tested against main (63bcca43) on Windows 11 with both hardware D3D12 (RTX 5090) and WARP (VICTORY_D3D12_DEBUG=1). While the Arc::try_unwrap / HostList::deferred() lifecycle in list::restart -> leave -> recycle is well-guarded, there are four blocking defects that currently break both VICTORY_QUEUE2=1 and VICTORY_ASYNC_SUBMIT=1 as well as CI lint:
-
clippy -D warningsfailure (crates/victory-gpu/src/list.rs:911-924):- The
// SAFETY:comment sits outsideif !queued {, so theunsafeblock atlist.rs:914failscargo clippy --locked -p victory-gpu --tests -- -D warningswithclippy::undocumented-unsafe-blocks.
- The
-
VICTORY_QUEUE2=1silently fails on its first readback with zero bytes copied (reproduced on both RTX 5090 and WARP):Lists::new(crates/victory-gpu/src/queue2.rs:98-105) callsCreateCommandList(which returns an open command list) without callingClose().- On the very first
fetch_on_copy(queue2.rs:279),lists.reset()tries to reset the still-open list/allocator, fails immediately, callsbroke("a list did not reset", e), and permanently setsBROKEN = true. queue2::run(queue2.rs:394) then falls back tosecond.fetch_on_direct(&now), whosedirect_listswere also created byLists::newwithoutClose(), soqueue2.rs:313fails identically and returnsfalse.- Because
list.rs:913already skipped recordingCopyTextureRegionon the original list, neither queue copies anything. With onlyVICTORY_QUEUE2=1set, bothresource::tests::a_texture_read_back_reaches_the_title_bufferandresource::tests::a_list_waiting_for_another_queues_write_reads_what_it_wrotefail 100% on RTX 5090 and WARP. Closing each freshly created command list insideLists::newis needed beforereset()can ever succeed.
-
Deferred readback ordering hazard when the source texture is overwritten later in the same list/batch:
list.rs:900-924omits the inlineCopyTextureRegionand defers it tocrate::queue2::run(&fetches)after the entireHost::executebatch (host.rs:1351).- If a later command in the same list or a later list in the same
runsbatch overwrites the source texture after the readback command, even thefetch_on_directfallback (queue2.rs:307-347, 387-398) runs after the batch completes and therefore reads the post-overwrite texture contents rather than the state at the readback point.
-
VICTORY_ASYNC_SUBMIT=1synchronization contract breaks &queue::presentstate race:- With
VICTORY_ASYNC_SUBMIT=1,queue::execute/queue::signalenqueueWork::Run/Work::Signaland return beforeExecuteCommandLists/Signalhave reached the host queue, whilefence::completed,fence::set_event_on_completion, and subsequent readbacks do not callbefore_sync(). UnderVICTORY_ASYNC_SUBMIT=1,queue::tests::queue_signals_complete_at_once(expects7, observes0),a_texture_read_back_reaches_the_title_buffer, anda_list_waiting_for_another_queues_write_reads_what_it_wroteall fail on both RTX 5090 and WARP. - In
queue::present(queue.rs:733, 747),host_transitionreads/mutatescopy.stateon the calling thread beforehost.presenteventually callsbefore_sync()insideself.execute(&[&p.copy])(host.rs:3506), racing with the backgroundvictory-submitthread touchingcopy.stateinsideHostList::prelude()(host.rs:1958, 1967). Callingcrate::queue::before_sync()at the start ofqueue::present(before touching plane states) would close that race.
- With
(Note: cargo xtask policy passed (192 files ok); default-off tests matched main's baseline on RTX 5090 and WARP.)
|
Fixed 1 and 2 in 2e72cc9: the SAFETY comment moved inside the On 3 and 4: both are real and I have no fix yet. For 3 the simplest reading is that the deferred copy is only safe while nothing later in the same batch writes the source; a version that records the copy inline when the texture is written again later in the batch would need the list to know what it has already written. For 4 the reports are consistent with what the reviewer says — the ordering contract is not enforced, so the numbers in the body come partly from a path that can race. Measured after 1 and 2 on the RTX 4060: the reset path no longer breaks, no device removal in 12 minutes, but a frame at 3 135 draws still takes 16.7 s. The 0.5-2 s numbers are at 1 100-2 500 draws only. |
|
3 addressed in the latest push: 4 is still open. Current state: clippy clean, reset path fixed, no device removal over 15 minutes, frame time unchanged at 16.7 s on a 2 941-draw frame. |
|
4 addressed too: That leaves the intentional part of 4 — Frame time again unchanged at 16.7 s on 3 289 draws; no device removal in any of the runs after the four fixes. |
kotekompotek
left a comment
There was a problem hiding this comment.
Verified the ordering invariants: the worker drains the FIFO strictly (signals queued behind submissions, pump_held_if_free(Worker) runs before pending-- so released held work joins the line before a later submission can pass it), before_sync drains the submitter before synchronous submissions and before present's state moves, and SUBMITTING_HERE guards the worker's own host.execute. Fetch dedup by (copy, subresource) is right — a second read-back would snapshot the end-of-batch state. The documented assumption (title memory not rewritten between submit and prepare) is sound vs console timing. Both switches default off, so the hot path is unchanged.
After its watchdog fires the title writes a marker through a null pointer (`mov dword ptr [0], 0x4d8bd421`): the console maps a null page, the PC does not, and no allocator places memory at zero. A 64 KiB page is reserved at 0x10000 and every such instruction in the mapped image has its absolute operand rewritten to it, keeping the original offset (some sites use [4]). The page is made writable for the patch, flushed, and restored. Measured: runs stop dying at the point every earlier one did (~150 s in).
A watchdog path in the title ends with an unconditional `int3` after writing its breadcrumb; on a console its own handler catches it. With none attached, the breakpoint killed the run. Only a real 0xCC at the reported address is stepped, so debugger breakpoints are untouched. Measured: a run that died on the trap at ~150 s passes it and continues.
|
Added the fork's relay on top (the flights thread, 1 406 lines), with the two crash fixes it needs to survive here at all: With both: 10 minutes, no device removal, no exception. Frame time on the RTX 4060 is unchanged though — 16 s on 3 157 draws, one outlier at 33 s. So the relay is a working option here, not a gain; on this card the wall is the per-draw preparation, not the submit or the copy-back path. |
|
Ported the fork's So the heavy frames are the card's own time, not our preparation and not pipeline creation: 0 pipelines made, 16.8 s of waiting for the card, 57 MB of copies. Lighter frames of the same scene settle at 1.3 s. My earlier "CPU preparation" guess in the comments above was wrong — that comes from the fork's own overlay on its own build. The counters fx has that our tree cannot source (card clock, per-call list timings, remaps) are noted in the commit; the copy-back counter covers the relay landing path here. |
|
Baseline with the same frame log and no switches, for comparison: |
|
RTX 3070 8 GB, Windows 10: with the switches on, the world runs at about half the speed it does with them off. That held on two heads, Setup: RTX 3070 8 GB, driver 621.14, Windows 10 22H2 (19045).
Without this PR, the same stack ran at 1.8 fps, so with the switches off the PR costs nothing here. The switches also log as on ( Since all four settings were set together, I can't yet say which one costs the speed. A natural next split is the two switches without the workers and wait. Fewer indirect dispatches dropped with them on could be a side effect of fewer frames, not a fix. One unrelated thing: the branch commits Not tested: a second run of each cell; the frame log for the steady state (on this card it records almost no long frames after the first minutes). No game data attached. I'm testing with Claude's help, and Claude drafted this comment. |
|
Automated triage for the maintainers. Proposed close. The PR adds about 2,900 lines of opt-in submission/copy-queue/relay code ported from another fork. By its own measurements in the comments, it does not help. The heavy frames stay at about 16.7 s with the switches on, and the frame log puts that time in waiting for the GPU, not in our submit path. An independent RTX 3070 run found the world at roughly half speed with the switches on (0.8 vs 1.8 fps). The deferred copy also has a known unfixed race: a later write to the source in the same batch lands in the deferred copy ( It also bundles unrelated, risky changes:
CI: failing. What would change this: a small PR with one change that a frame log shows lowering frame time on Generated by Claude Code |
|
Correction to my comment above: the "switches on halve the speed" result isn't solid. Since posting it, I found that frame rate on this RTX 3070 swings between roughly 0.7 and 1.8 fps from run to run of the same build. A control run of an earlier fast tree came out at 0.93 fps. My on/off runs alternated (on, off, on, off), and the "on" runs may simply have landed on slow turns. Please treat that table as not showing an effect either way until I can measure the run-to-run spread here. The stray I'm testing with Claude's help, and Claude drafted this comment. |
The world stalls for 17 s a frame here (RTX 4060 8 GB): the render thread waits inside submit and inside the fetch of what shaders wrote, so the intro cutscene never draws. With the three things below the same frames take 0.3-2 s and the prologue card renders.
Ported from
fxceless/victory-fork, where they sit behind switches:VICTORY_ASYNC_SUBMIT=1: submissions are prepared and sent by a thread of the layer. A profile in that fork had the render thread inside submit for 257 of 292 ms a frame.VICTORY_QUEUE2=1: fetches of what shaders wrote go to a copy queue; the copy-back thread's wait fell from about 125 to 7 ms a frame there. Itsqueue2.rscomes over with the fix for a piece fetched beside a later flight: textures count their state moves so a fetch recorded before a later use is told from one recorded after it.VICTORY_PIPELINE_WAIT_MSandVICTORY_PIPELINE_WORKERSalready exist upstream; the numbers below use 24 and 4.Measured on one machine (Ryzen 7 5700X, RTX 4060 8 GB, Windows 11 26200, Series X, 1080p, warm shader cache), same build, from the first-run screens into the intro cutscene:
No device removal in any of the runs with the device layer's debug output on; the runs above are 10-15 minutes each. Above about 2 900 draws the frame still goes back to 8-17 s, so this does not make the title playable, it makes the cutscene visible. Halving neither the worker count nor doubling it (4 against 8 workers) moves those heavy frames; they are not worker-bound.
The three are opt-in; the last row was run as
VICTORY_ASYNC_SUBMIT=1 VICTORY_QUEUE2=1 VICTORY_PIPELINE_WAIT_MS=24 VICTORY_PIPELINE_WORKERS=4.Two caveats from the fork's own notes: the async path assumes the title leaves its memory alone between submit and preparation (it does there, but nothing enforces it), and the copy queue brings reads back with an up-lane bit this port does not add.