gpu(native): pay a refused submission's value writes on the CPU (#80) #317
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/317"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T11:06:51Z.
What this changes
Refs #80.
submit_passesdrops a pass it cannot encode while the command buffer still commits, and a piece refused before a command buffer exists at all loses its fills either way. Another queue waiting on one of those bottom-of-pipe value writes (the per-frame cross-queue barrier words) then holds for good — the title'sUnsignaled CrossQueueBarrier, then its watchdog atimage+0x55e56f8(seen in tester reports #265 and #280 after OOM-failed command buffers: queues held on0x18437f9d8 cmp 7 ref 0x883 ... now Some(2178), fps decaying to 0.4).When the
submit_passescall inNativeHost::execute(crates/victory-gpu/src/native/host.rs) returns an error, the host now makes the piece's fills on the CPU, in order, with a release fence after them, and warns the first time (native host pays a refused submission's value writes on the CPU). A fill the GPU still runs (a kept pass of a partly refused submission) repeats the same bytes. Fence signals were already paid on every path that commits a command buffer, and bygfx::Owed/recover_lostwhen it fails or is lost, so value writes were the remaining hole.One change:
host.rsplus two tests (vertex_tests.rs) and thenative-host.mdsection "A refused submission still pays its value writes".How it was tested
cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings— rc=0 (compiles the new tests for the Windows target)cargo xtask policy— "asset policy: 371 files ok"cargo test -p xtask— 6 passed, 0 failedcargo test -p victory-gpu(lib tests, incl.a_refused_submission_pays_its_value_writes_on_the_cpuanda_submitted_piece_leaves_its_value_writes_to_the_gpu) — runs on CI's windows-latestcheckjob; this sandbox is Linux, where victory-gpu'snativemodule iscfg(any(windows, macos))and does not build, so I could not execute them herework held for a wait that does not holdstill appears after OOM-failed command buffersChecklist
VICTORY_*variable and documented — none added (the warn line follows the existing once-per-kind pattern of the other drop warnings)Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T11:54:12Z.
Thank you. The two tests are good and the code is easy to follow.
I have two questions.
0x18437f9d8 cmp 7 ref 0x883 ... now Some(2178), "fps decaying to 0.4")? I cannot find them in #265 or #280; those logs are attachments and I have not opened them. On #80 I wrote that failed command buffers already pay their fence signals on main. Please say which log, which commit, and what the log showed before the title's fault.native-host.md.I have not run this in the game. It needs a run on a 16 GB Mac that gets past the world load.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T13:03:17Z.
Review note, not merging yet. In the Metal host,
submit_passesreturns Err but still commits the command buffer when one pass fails to encode (native/host.rs, around line 1893). This PR then writes every fill of the piece on the CPU at once. Two things follow:Only the fills of a refused blit pass, or of a piece that never committed, are really lost. Could the CPU write be limited to those two cases? A test with one failing pass in the middle of a piece would pin it.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T13:20:17Z.
Where the log lines come from. The warn native host pays a refused submission's value writes on the CPU (first time; each after at debug level) is emitted in NativeHost::execute (crates/victory-gpu/src/native/host.rs) right after backend.submit_passes(...) returns an error: the piece's Cmd::Fills are made on the CPU in order (write_bytes into the pool's title memory), then a Release fence, then a std::sync::Once warn; later refusals log native host paid {n} value writes of a refused submission on the CPU at debug. It sits beside the existing dropped_* warnings in the same function.
What a waiting queue can read early. Nothing harmful: the fill is a plain store of the word range into coherent title memory plus a release fence; a queue polling the barrier word reads either the old value (keeps waiting) or the filled value — a partial multi-word fill just means it waits on the next word. The hazard closed is the opposite: the word staying 0 forever after a refused submission, which hung the queue. A fill the GPU still runs (kept pass of a partly refused submission) repeats the same bytes, so a waiter never sees a torn word.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:15:26Z.
Merged in
4cf84c83. Before pushing I ran the tests (native arm64), Windows clippy, the policy check, a release build, and one headless game run of the exact tree (170 s, Series S): menus at 30 fps, the world entered at about 81 s and kept presenting to the end at about 1 frame a second, 0 GPU errors, no crash. The run had no refused submission, so the CPU fill path itself was not exercised, and I did not do the 16 GB run. Thanks.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T16:20:18Z.
After the review rework (
2ab63898): submit_passes returns SubmitFailure { committed, refused, error } — whether the command buffer committed and which pass indices were dropped (with VICTORY_PASSES_PER_BUFFER pieces, a failed next_piece marks the remainder lost with committed: true). On error, NativeHost::execute pays on the CPU only the lost passes' fills (all fills when nothing committed); kept passes' fills stay on the GPU, so a waiting queue can't go on before earlier GPU passes ran and the GPU's later fill can't be overwritten by the CPU write. Tests: vertex_tests::only_the_fills_of_refused_passes_are_paid_on_the_cpu (one refused pass in the middle of a piece), plus the two earlier ones; Metal render tests assert err.refused == [0], err.committed. Also paste my reply to the maintainer's 13:03 note (text in my earlier message).