A submission is prepared while the one before still runs (opt-in; median frame time 12 % lower on a Radeon 8060S on top of #178 and #179) #215

Open
github-bot wants to merge 1 commit from github-bot/gh-215 into main AGit
Owner

@⁠SPFCChris on GitHub · 2026-11-26 01:24 UTC · original
SPFCChris:perf/overlap-prep → main · +453 −17 · 3 files · 1 commits · open

Both switches are off by default, and the gain below was measured on top of #178 and #179. On main alone I could not show one (see "Measured"). Read that section before deciding where this belongs.

What it is for

In a world frame the title makes about 36 submissions, each followed by a Signal. Each is prepared on the processor and then waited for on the host GPU, one after the other: on a Radeon 8060S a heavy frame is about 60-85 ms of preparing and 80-87 ms of waiting. This lets part of the preparing of a submission happen while the one before is still running.

Three parts

Each is inert unless something is in flight when the next submission comes, which is rare while the title's Signal waits for the host GPU.

  1. VICTORY_LATE_SIGNALS=1 (off by default; timeline.rs, host.rs). A title fence signalled behind an unwaited host submission is noted against that submission's host fence value and signalled from Host::reap_completed (timeline::deliver). Signal returns at once, as the console's does, and the title's thread goes on to its next submission. A thread (victory-finish) waits for the host GPU without holding submitted when fences are owed, so a title that only waits for its fence is served. Wait, lists not ready and other work wait as before.
  2. Fills in the prewarm (VICTORY_EARLY_FILLS=0 turns it off; host.rs). Host::prewarm also does the lists' Step::Fill copies: title memory into the list's own upload memory, which nothing that runs reads. Up to the first step that writes title memory in any list of the submission, and not from ranges the submissions still running write back. Deferred::prefilled tells run_deferred which fills are done.
  3. VICTORY_EARLY_PLAN=1 (off by default; descriptor/host.rs, host.rs). Host::prewarm makes the directly indexed heaps' plans too. The slots such a plan makes go to a staging heap no shader sees (HostHeap::plan_ahead marks the thread; HostHeap::cpu then hands out the slot's place in the staging heap and notes the slot staged), and Host::execute_inner copies them into the shader-visible heap once the submission before has run (HostHeap::flush_staged: CopyDescriptorsSimple in runs, under the made lock; a write in place forgets what was staged for the slot). The plan made ahead is kept, and Batch::prepare_bindless copies its bounces and refreshes its reads before the heap's newer plan.

Why a plan made ahead used to stop the host GPU

It was tried before and gave DXGI_ERROR_DEVICE_HUNG at the world's first frames. The cause was not the slot writes. The plan made ahead was dropped, and when the submission then made a newer plan, that one listed as new (fresh, fresh_reads) only its own slots: the host copies behind the slots made ahead were never filled, and shaders read what the memory happened to hold. Two runs with the staging heap but the plan dropped still lost the device, the second right after "8147 slots staged and copied"; with the plan kept, none of the runs below did at that point.

Measured

Radeon 8060S (Ryzen AI Max+ 395), diag build, Series X profile, opening cutscene, 220 s in the world per run, runs alternated.

On main (4f62c2a) plus #148, #178, #179 (with its fix), the terminator fix of #156/#207 and a local texture-hash change, two runs per arm, every frame's time logged:

frames in 220 s median frame at 1-2k draws at 2-3k draws at 3-4k draws
switches off 1,033 and 1,112 168 and 162 ms 154, 156 ms 195, 186 ms 191, 191 ms
VICTORY_LATE_SIGNALS=1 1,081 and 1,276 170 and 135 ms 150, 140 ms 191, 153 ms 208, 157 ms
and VICTORY_EARLY_PLAN=1 1,217 and 1,332 155 and 135 ms 146, 129 ms 170, 157 ms 214, 168 ms

Median frame 165 ms to 145 ms with both switches (12 %; the two pairs gave 8 % and 17 %), 19 % more frames delivered. The gain is in scenes of up to about 3,000 draws; above that it is inside the noise. With both on, per 5 s (about 25 frames): 350-450 ms of plans made ahead, 30-67 MB of fills done ahead, 15,000-35,000 slots staged and copied.

On this branch as it is (main plus #148 only), one run per arm, from the frame-rate lines: 798 frames in 220 s with the switches off, 750 with both on; heavy frames 305 and 310 ms. No gain, and on that build a heavy frame is 305 ms rather than 180: its time goes to what #178 and #179 remove (threads made at every in_parallel call, which the prewarm calls too; copy-back 31 ms a frame against 9). So I would not merge this for speed before those, and one pair of runs proves little either way.

Stability

  • With both switches on, on the first build above: 8 runs of about four minutes in the world without a device loss or a crash. One further run lost the device (host GPU device removed after a submission of 1 lists, DEVICE_HUNG); it also had VICTORY_TEXTURES=keep set, so I cannot say which was the cause.
  • Earlier, on 000ffdd, late signals alone lost the device in one run of four. Never explained.
  • That is why both are off by default. With both off, the only change in behaviour is the fills done in the existing prewarm.

Tested

  • cargo test -p victory-gpu --lib --locked: 113 passed, 0 failed, 4 ignored.
  • cargo clippy -p victory-gpu --all-targets --locked: 40 warnings in the library, as on main.
  • The frames of the runs with both switches on were looked at as contact sheets: as before. (A dark green rectangle over the left half of one transition frame after the beach shot is there with the switches off as well, on 4f62c2a.)

Not tested

  • Any other GPU or CPU.
  • A build without diagnostics.
  • Anything past the opening cutscene.
  • No new unit test: the timeline's tests do not reach the host, and I found no small way to test fence delivery or the staging heap without a device and a title's lists.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

**@⁠SPFCChris** on GitHub · 2026-11-26 01:24 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/215) `SPFCChris:perf/overlap-prep` → `main` · +453 −17 · 3 files · 1 commits · open **Both switches are off by default, and the gain below was measured on top of #178 and #179. On `main` alone I could not show one (see "Measured"). Read that section before deciding where this belongs.** ## What it is for In a world frame the title makes about 36 submissions, each followed by a `Signal`. Each is prepared on the processor and then waited for on the host GPU, one after the other: on a Radeon 8060S a heavy frame is about 60-85 ms of preparing and 80-87 ms of waiting. This lets part of the preparing of a submission happen while the one before is still running. ## Three parts Each is inert unless something is in flight when the next submission comes, which is rare while the title's `Signal` waits for the host GPU. 1. **`VICTORY_LATE_SIGNALS=1`** (off by default; `timeline.rs`, `host.rs`). A title fence signalled behind an unwaited host submission is noted against that submission's host fence value and signalled from `Host::reap_completed` (`timeline::deliver`). `Signal` returns at once, as the console's does, and the title's thread goes on to its next submission. A thread (`victory-finish`) waits for the host GPU without holding `submitted` when fences are owed, so a title that only waits for its fence is served. `Wait`, lists not ready and other work wait as before. 2. **Fills in the prewarm** (`VICTORY_EARLY_FILLS=0` turns it off; `host.rs`). `Host::prewarm` also does the lists' `Step::Fill` copies: title memory into the list's own upload memory, which nothing that runs reads. Up to the first step that writes title memory in any list of the submission, and not from ranges the submissions still running write back. `Deferred::prefilled` tells `run_deferred` which fills are done. 3. **`VICTORY_EARLY_PLAN=1`** (off by default; `descriptor/host.rs`, `host.rs`). `Host::prewarm` makes the directly indexed heaps' plans too. The slots such a plan makes go to a **staging heap** no shader sees (`HostHeap::plan_ahead` marks the thread; `HostHeap::cpu` then hands out the slot's place in the staging heap and notes the slot staged), and `Host::execute_inner` copies them into the shader-visible heap once the submission before has run (`HostHeap::flush_staged`: `CopyDescriptorsSimple` in runs, under the `made` lock; a write in place forgets what was staged for the slot). The plan made ahead is kept, and `Batch::prepare_bindless` copies its bounces and refreshes its reads before the heap's newer plan. ## Why a plan made ahead used to stop the host GPU It was tried before and gave `DXGI_ERROR_DEVICE_HUNG` at the world's first frames. The cause was not the slot writes. The plan made ahead was dropped, and when the submission then made a newer plan, that one listed as new (`fresh`, `fresh_reads`) only its own slots: the host copies behind the slots made ahead were never filled, and shaders read what the memory happened to hold. Two runs with the staging heap but the plan dropped still lost the device, the second right after "8147 slots staged and copied"; with the plan kept, none of the runs below did at that point. ## Measured Radeon 8060S (Ryzen AI Max+ 395), diag build, Series X profile, opening cutscene, 220 s in the world per run, runs alternated. **On `main` (`4f62c2a`) plus #148, #178, #179 (with its fix), the terminator fix of #156/#207 and a local texture-hash change**, two runs per arm, every frame's time logged: | | frames in 220 s | median frame | at 1-2k draws | at 2-3k draws | at 3-4k draws | |---|---|---|---|---|---| | switches off | 1,033 and 1,112 | 168 and 162 ms | 154, 156 ms | 195, 186 ms | 191, 191 ms | | `VICTORY_LATE_SIGNALS=1` | 1,081 and 1,276 | 170 and 135 ms | 150, 140 ms | 191, 153 ms | 208, 157 ms | | and `VICTORY_EARLY_PLAN=1` | 1,217 and 1,332 | 155 and 135 ms | 146, 129 ms | 170, 157 ms | 214, 168 ms | Median frame 165 ms to 145 ms with both switches (12 %; the two pairs gave 8 % and 17 %), 19 % more frames delivered. The gain is in scenes of up to about 3,000 draws; above that it is inside the noise. With both on, per 5 s (about 25 frames): 350-450 ms of plans made ahead, 30-67 MB of fills done ahead, 15,000-35,000 slots staged and copied. **On this branch as it is (`main` plus #148 only)**, one run per arm, from the frame-rate lines: 798 frames in 220 s with the switches off, 750 with both on; heavy frames 305 and 310 ms. No gain, and on that build a heavy frame is 305 ms rather than 180: its time goes to what #178 and #179 remove (threads made at every `in_parallel` call, which the prewarm calls too; copy-back 31 ms a frame against 9). So I would not merge this for speed before those, and one pair of runs proves little either way. ## Stability - With both switches on, on the first build above: 8 runs of about four minutes in the world without a device loss or a crash. One further run lost the device (`host GPU device removed after a submission of 1 lists`, `DEVICE_HUNG`); it also had `VICTORY_TEXTURES=keep` set, so I cannot say which was the cause. - Earlier, on `000ffdd`, late signals alone lost the device in one run of four. Never explained. - That is why both are off by default. With both off, the only change in behaviour is the fills done in the existing prewarm. ## Tested - `cargo test -p victory-gpu --lib --locked`: 113 passed, 0 failed, 4 ignored. - `cargo clippy -p victory-gpu --all-targets --locked`: 40 warnings in the library, as on `main`. - The frames of the runs with both switches on were looked at as contact sheets: as before. (A dark green rectangle over the left half of one transition frame after the beach shot is there with the switches off as well, on `4f62c2a`.) ## Not tested - Any other GPU or CPU. - A build without `diagnostics`. - Anything past the opening cutscene. - No new unit test: the timeline's tests do not reach the host, and I found no small way to test fence delivery or the staging heap without a device and a title's lists. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Three parts, each inert unless something is in flight when the next
submission comes, which is rare while the title's Signal waits for the
host GPU:

- VICTORY_LATE_SIGNALS=1 (off by default). A title fence signalled behind
  an unwaited host submission is noted against that submission's host
  fence value and signalled from Host::reap_completed
  (timeline::deliver); Signal returns at once, as the console's does. A
  thread (victory-finish) waits for the host GPU without holding
  `submitted` when fences are owed, so a title that only waits for its
  fence is served. Waits, lists not ready and other work wait as before.
- Host::prewarm also does the lists' fills (VICTORY_EARLY_FILLS=0: not):
  title memory into the list's own upload memory, up to the first step
  that writes title memory, and not from ranges the submissions still
  running write back.
- VICTORY_EARLY_PLAN=1 (off by default). Host::prewarm makes the directly
  indexed heaps' plans too. The slots such a plan makes go to a staging
  heap no shader sees (HostHeap::plan_ahead, HostHeap::cpu) and are copied
  into the shader-visible heap once the submission before has run
  (HostHeap::flush_staged). The plan made ahead is kept and
  Batch::prepare_bindless copies its bounces and refreshes its reads
  before the heap's newer plan.

Why a plan made ahead used to stop the host GPU (DXGI_ERROR_DEVICE_HUNG at
the world's first frames): not the slot writes. The plan was dropped, and
when the submission then made a newer plan, that one listed as new only
its own slots, so the host copies behind the slots made ahead were never
filled and shaders read what the memory happened to hold.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:38:07 +00:00
Author
Owner

@⁠thejacte on GitHub · 2026-11-26 14:40 UTC · original

Measured on a second machine: here the gain shows on main alone.

Machine: RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 9800X3D, 64 GB, Windows 11.
Build: this PR's 91a914e (on main at 4f62c2a, without #178/#179), diag build with diagnostics, plus a local patch so my save loads (no runtime change).
Runs: same place of the same save in the world, about 4-5 minutes each, alternated. Both switches on (VICTORY_LATE_SIGNALS=1, VICTORY_EARLY_PLAN=1) against all off (VICTORY_EARLY_FILLS=0). Medians are over the 5-second frame-rate lines with more than 3,000 draws and no pipelines being made. One run before these only made pipelines.

Run Switches Median frame 90th % fps Preparing On the GPU
1 off 151 ms 284 ms 6.6 46 ms 3.5 ms
2 on 125 ms 392 ms 8.0 33 ms 38 ms
3 off 164 ms 253 ms 6.1 66 ms 1.8 ms
4 on 135 ms 168 ms 7.4 40 ms 33 ms
  • Median frame 157 ms to 130 ms with both on, about 17 %. The 90th percentile is mixed: one "on" run worse, one better.
  • No device loss and no DXGI_ERROR_DEVICE_HUNG. One driver compiler crash in run 2 was caught by the guard, and that pipeline left out (this card's compiler crashes on some compute pipelines whatever the switches; I've seen it on rx9070xt too).
  • I did not try the switches one at a time.

Two pairs of runs is still little, but on this machine the gain does not seem to depend on #178/#179.

🤖 Generated with Claude Code

**@⁠thejacte** on GitHub · 2026-11-26 14:40 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/215#issuecomment-7195146760) Measured on a second machine: here the gain shows on `main` alone. **Machine:** RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 9800X3D, 64 GB, Windows 11. **Build:** this PR's `91a914e` (on `main` at `4f62c2a`, **without** #178/#179), diag build with diagnostics, plus a local patch so my save loads (no runtime change). **Runs:** same place of the same save in the world, about 4-5 minutes each, alternated. Both switches on (`VICTORY_LATE_SIGNALS=1`, `VICTORY_EARLY_PLAN=1`) against all off (`VICTORY_EARLY_FILLS=0`). Medians are over the 5-second frame-rate lines with more than 3,000 draws and no pipelines being made. One run before these only made pipelines. | Run | Switches | Median frame | 90th % | fps | Preparing | On the GPU | |---|---|---|---|---|---|---| | 1 | off | 151 ms | 284 ms | 6.6 | 46 ms | 3.5 ms | | 2 | on | 125 ms | 392 ms | 8.0 | 33 ms | 38 ms | | 3 | off | 164 ms | 253 ms | 6.1 | 66 ms | 1.8 ms | | 4 | on | 135 ms | 168 ms | 7.4 | 40 ms | 33 ms | - Median frame 157 ms to 130 ms with both on, about 17 %. The 90th percentile is mixed: one "on" run worse, one better. - No device loss and no `DXGI_ERROR_DEVICE_HUNG`. One driver compiler crash in run 2 was caught by the guard, and that pipeline left out (this card's compiler crashes on some compute pipelines whatever the switches; I've seen it on `rx9070xt` too). - I did not try the switches one at a time. Two pairs of runs is still little, but on this machine the gain does not seem to depend on #178/#179. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 15:39 UTC · original · reviewed

AI-assisted static review; I inspected the descriptor staging and write-lock paths, but did not run tests or the game.

**@⁠gut0to** on GitHub · 2026-11-26 15:39 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/215#pullrequestreview-6076900979) · **reviewed** AI-assisted static review; I inspected the descriptor staging and write-lock paths, but did not run tests or the game.
@ -1148,0 +1228,4 @@
/// the lock on `made` (a title thread writing a slot in place holds it,
/// and forgets what was staged for the slot). Returns how many.
pub(crate) fn flush_staged(&self) -> usize {
if !self.staged_any.swap(false, Ordering::AcqRel) {
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 15:39 UTC · original

Could the made lock be acquired before clearing staged_any? A concurrent title-thread writer can enter cpu() after this swap but before the lock below; it then sees staged_any == false, skips clearing the staged bit for this slot, and writes the newer descriptor to the live heap. The subsequent flush still consumes that bit and copies the older staged descriptor over the newer write. Taking made before the swap would serialize the bit drain with descriptor writes.

**@⁠gut0to** on GitHub · 2026-11-26 15:39 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/215#discussion_r4710563001) Could the made lock be acquired before clearing staged_any? A concurrent title-thread writer can enter cpu() after this swap but before the lock below; it then sees staged_any == false, skips clearing the staged bit for this slot, and writes the newer descriptor to the live heap. The subsequent flush still consumes that bit and copies the older staged descriptor over the newer write. Taking made before the swap would serialize the bit drain with descriptor writes.
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 15:46 UTC · original · reviewed

AI-assisted static review; I inspected the staging allocation failure path, but did not run tests or the game.

**@⁠gut0to** on GitHub · 2026-11-26 15:46 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/215#pullrequestreview-6076994595) · **reviewed** AI-assisted static review; I inspected the staging allocation failure path, but did not run tests or the game.
@ -1143,0 +1164,4 @@
if index < self.count && !self.sampler {
let (word, bit) = (index as usize / 64, 1u64 << (index % 64));
if STAGING.get() {
if let Some(at) = self.staging_cpu() {
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 15:46 UTC · original

If staging_cpu() fails to create the staging heap, this branch falls through and returns the shader-visible descriptor handle. plan_ahead() then updates a live slot while the prior submission may still be reading that heap, which is the device-hang condition this staging path is meant to avoid. Could a failed staging allocation abort/defer the ahead plan instead of falling back to the live heap?

**@⁠gut0to** on GitHub · 2026-11-26 15:46 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/215#discussion_r4710641267) If `staging_cpu()` fails to create the staging heap, this branch falls through and returns the shader-visible descriptor handle. `plan_ahead()` then updates a live slot while the prior submission may still be reading that heap, which is the device-hang condition this staging path is meant to avoid. Could a failed staging allocation abort/defer the ahead plan instead of falling back to the live heap?
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 19:52 UTC · original

Tested 91a914e against its base 4f62c2a. Hardware: RX 7900 XT (RDNA3, driver 32.0.32029.2010), Windows 11 26300. Some tests also ran on WARP (diagnostics build). Other jobs were running on the machine at the same time. #178 and #179 were not included unless stated.

The lib tests do not reach the change

  • can_async in execute_inner starts with !cfg!(test), and late() has !cfg!(test) too. Under cargo test nothing is ever in flight, so prewarm, early fills, late signals and victory-finish never run.
  • cargo test -p victory-gpu --lib (debug), 8 interleaved runs each of base, PR, PR + VICTORY_LATE_SIGNALS=1, PR + late signals + VICTORY_EARLY_FILLS=0, and PR + late signals + VICTORY_EARLY_PLAN=1.
    • All 113 tests passed in every run, apart from known flaky tests.
    • watch:: guard-page tests failed in some runs of every config, base included.
    • frame::tests::waits_end_on_ticks_and_count_frames failed once, in the PR + late signals + fills-off config.

Local tests with title submissions made async

I added a test-only switch that lets can_async and late() be true under test, plus three tests in host.rs. They drive real HostLists through Host::execute_title and a Timeline. Results:

  1. Early fills (on by default) read memory before the submission in flight writes it.
    • Setup: list A has a bottom-of-pipe write of 0x22 to memory that starts as 0x11, and is submitted async. List B fills from that memory and is submitted while A is still in flight, with no Signal between them.
    • On base and with VICTORY_EARLY_FILLS=0, B's fill sees 0x22 in every run (10/10).
    • On the PR with default settings, B sees 0x11: 10/10 runs on the 7900 XT, 5/5 on WARP.
    • Cause: owed in prewarm only takes Finish::back. finish_submission also writes title memory through the in-flight lists' deferred.writes (bottom-of-pipe writes, timestamps) and readbacks. Those writes happen after the prewarm, so a fill from those ranges is stale. The test covers only the deferred.writes case. Adding those target ranges to owed would cover both.
  2. A late signal can come before its submission is finished.
    • Setup: one title thread, 300 rounds. Each round submits a list with a bottom-of-pipe write of i, then signals i. After each signal the test checks that the fence never shows a value whose write is not done yet.
    • With VICTORY_LATE_SIGNALS=1 it failed in 3/10 runs, and in 5/10 with fills also off. On WARP it failed 1/5 in each of those two configs. It failed 0/10 with late signals off and 0/10 on base.
    • Cause: reap_completed pops the submission from in_flight before finish_submission runs. If victory-finish is reaping at that moment, signal_late sees in_flight empty (target 0) and LATE empty, and signals at once. A possible fix: take the target from the last async fence value and compare it with FINISHED_FENCE, instead of checking whether in_flight is empty.
    • The same pop-before-finish window affects wait_in_flight on main when more than one thread reaps. With 3 title threads this test fails on base too (10/10). That part is older than this PR, but victory-finish adds another thread that reaps.
  3. A blocking wait right after a late signal fails.
    • With VICTORY_LATE_SIGNALS=1, SetEventOnCompletion(value, NULL) right after the queue's Signal, with host work still running, returns E_NOTIMPL ("blocking fence wait not implemented"). This happened in 10/10 runs on the 7900 XT and 5/5 on WARP.
    • On base and with late signals off it returns S_OK.
    • Cause: timeline::active() does not count signals still owed in LATE.

No run hung. No test hit its 10 s fence-wait timeout.

From reading the code only, not tested

  • timeline::deliver pops entries under LATE but signals them after unlocking. It is called both from reap_completed (with submitted held) and from signal_late and victory-finish (without it). Two callers can therefore signal values of one fence out of order, and fence::set stores the value rather than keeping the larger one. The stress test never saw this.

Together with #178 (6325dc1) and #179 (847dcbb)

  • Both merge onto 91a914e without conflicts, and the result builds.
  • Lib tests on the merge: 5 runs, plus 5 with VICTORY_LATE_SIGNALS=1. All 117 tests passed in each run, apart from the same known watch:: flakes.
  • The three tests above give the same results on the merge as on the PR alone.

Not tested

  • The game itself: no game runs and no frame times here. So I can't say how often the game hits any of the above.
  • Device removal and shutdown with fences still owed.
  • Clippy.

I have the tests and the test-only switch on a local branch, for both this PR and main, if they are useful.

**@⁠adrianmjim** on GitHub · 2026-11-26 19:52 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/215#issuecomment-7202052839) Tested 91a914e against its base 4f62c2a. Hardware: RX 7900 XT (RDNA3, driver 32.0.32029.2010), Windows 11 26300. Some tests also ran on WARP (diagnostics build). Other jobs were running on the machine at the same time. #178 and #179 were not included unless stated. **The lib tests do not reach the change** - `can_async` in `execute_inner` starts with `!cfg!(test)`, and `late()` has `!cfg!(test)` too. Under `cargo test` nothing is ever in flight, so `prewarm`, early fills, late signals and `victory-finish` never run. - `cargo test -p victory-gpu --lib` (debug), 8 interleaved runs each of base, PR, PR + `VICTORY_LATE_SIGNALS=1`, PR + late signals + `VICTORY_EARLY_FILLS=0`, and PR + late signals + `VICTORY_EARLY_PLAN=1`. - All 113 tests passed in every run, apart from known flaky tests. - `watch::` guard-page tests failed in some runs of every config, base included. - `frame::tests::waits_end_on_ticks_and_count_frames` failed once, in the PR + late signals + fills-off config. **Local tests with title submissions made async** I added a test-only switch that lets `can_async` and `late()` be true under test, plus three tests in `host.rs`. They drive real `HostList`s through `Host::execute_title` and a `Timeline`. Results: 1. Early fills (on by default) read memory before the submission in flight writes it. - Setup: list A has a bottom-of-pipe write of 0x22 to memory that starts as 0x11, and is submitted async. List B fills from that memory and is submitted while A is still in flight, with no `Signal` between them. - On base and with `VICTORY_EARLY_FILLS=0`, B's fill sees 0x22 in every run (10/10). - On the PR with default settings, B sees 0x11: 10/10 runs on the 7900 XT, 5/5 on WARP. - Cause: `owed` in `prewarm` only takes `Finish::back`. `finish_submission` also writes title memory through the in-flight lists' `deferred.writes` (bottom-of-pipe writes, timestamps) and `readbacks`. Those writes happen after the prewarm, so a fill from those ranges is stale. The test covers only the `deferred.writes` case. Adding those target ranges to `owed` would cover both. 2. A late signal can come before its submission is finished. - Setup: one title thread, 300 rounds. Each round submits a list with a bottom-of-pipe write of `i`, then signals `i`. After each signal the test checks that the fence never shows a value whose write is not done yet. - With `VICTORY_LATE_SIGNALS=1` it failed in 3/10 runs, and in 5/10 with fills also off. On WARP it failed 1/5 in each of those two configs. It failed 0/10 with late signals off and 0/10 on base. - Cause: `reap_completed` pops the submission from `in_flight` before `finish_submission` runs. If `victory-finish` is reaping at that moment, `signal_late` sees `in_flight` empty (target 0) and `LATE` empty, and signals at once. A possible fix: take the target from the last async fence value and compare it with `FINISHED_FENCE`, instead of checking whether `in_flight` is empty. - The same pop-before-finish window affects `wait_in_flight` on main when more than one thread reaps. With 3 title threads this test fails on base too (10/10). That part is older than this PR, but `victory-finish` adds another thread that reaps. 3. A blocking wait right after a late signal fails. - With `VICTORY_LATE_SIGNALS=1`, `SetEventOnCompletion(value, NULL)` right after the queue's `Signal`, with host work still running, returns `E_NOTIMPL` ("blocking fence wait not implemented"). This happened in 10/10 runs on the 7900 XT and 5/5 on WARP. - On base and with late signals off it returns `S_OK`. - Cause: `timeline::active()` does not count signals still owed in `LATE`. No run hung. No test hit its 10 s fence-wait timeout. **From reading the code only, not tested** - `timeline::deliver` pops entries under `LATE` but signals them after unlocking. It is called both from `reap_completed` (with `submitted` held) and from `signal_late` and `victory-finish` (without it). Two callers can therefore signal values of one fence out of order, and `fence::set` stores the value rather than keeping the larger one. The stress test never saw this. **Together with #178 (6325dc1) and #179 (847dcbb)** - Both merge onto 91a914e without conflicts, and the result builds. - Lib tests on the merge: 5 runs, plus 5 with `VICTORY_LATE_SIGNALS=1`. All 117 tests passed in each run, apart from the same known `watch::` flakes. - The three tests above give the same results on the merge as on the PR alone. **Not tested** - The game itself: no game runs and no frame times here. So I can't say how often the game hits any of the above. - Device removal and shutdown with fences still owed. - Clippy. I have the tests and the test-only switch on a local branch, for both this PR and main, if they are useful.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/215/head:github-bot/gh-215'
git switch 'github-bot/gh-215'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-215'
git switch 'github-bot/gh-215'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-215'
git switch 'github-bot/gh-215'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-215'
git switch 'main'
git merge --squash 'github-bot/gh-215'
git switch 'main'
git merge --ff-only 'github-bot/gh-215'
git switch 'main'
git merge 'github-bot/gh-215'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.