gpu(fence,queue): block on null-event fence waits and wake events on bottom-of-pipe writes #88

Manually merged
github merged 1 commit from gh-pr/88/head into gh-pr/88/base 2026-12-01 20:08:06 +00:00
Owner

@⁠Androtim on GitHub · 2026-11-29 08:18 UTC · original
Androtim:feat/iter89-fence-blocking-and-bop-events → main · +182 −42 · 2 files · 1 commits · merged 2026-11-29 14:32 UTC

Summary

Adapted from upstream VIctory-NVIDIA PRs #905 (81b3653) and #906 (1841d59) (GPL-3.0), extracted cleanly off origin/main (7fe6886) with zero overlap against open PRs:

  • Blocking null-event fence waits (crates/victory-gpu/src/fence.rs, crates/victory-gpu/src/queue.rs): ID3D12Fence::SetEventOnCompletion with a null event now waits in 10 ms WaitOnAddress slices until the target fence value is reached instead of returning E_NOTIMPL after 250 ms, settling late flights and releasing held queue work (queue::release_forced() after 2 s).
  • Bottom-of-pipe fence write event wakeups (crates/victory-gpu/src/fence.rs, crates/victory-gpu/src/queue.rs): Registers live Fence instances by value address and calls fence::written from queue::Written::write so 4-byte and 8-byte bottom-of-pipe GPU writes into a fence's address wake registered SetEventOnCompletion events just like Signal.

Verification

  • cargo xtask policy: asset policy: 303 files ok
  • cargo test -p victory-gpu --lib --locked -- fence:: queue::: 14 passed; 0 failed (including a_null_event_blocks_until_the_value_is_reached and a_write_at_the_fence_address_sets_waiting_events)
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo clippy --workspace --all-targets --features diagnostics -- -D warnings: 0 warnings
  • Plain --release + objdump -p: standard Windows system DLLs only
  • Live 75s Series S GPU verification (pr89-fence-blocking-bop): 11/11 gates PASS
    • Median FPS: 12.3 fps (81.2 ms, vs 8.9 fps baseline, +3.40 fps)
    • Max VRAM: 5869 MB / 6961 MB budget (over=0 MB)
    • Waiting textures: 2281 (vs 7121 baseline) | mapped() stall rate: 6.1 ms/s
    • Shader translation: untranslated=1 | Crashes / host texture errors: 0 / 0
    • Visually inspected 24 captured frames (frame-8478.png, frame-8518.png, median luma 103.93, edge energy 7.11, 0.0% near-black/magenta): clean daylight rendering with no hangs or artifacts.
**@⁠Androtim** on GitHub · 2026-11-29 08:18 UTC · [original](https://github.com/Androtim/MiniVI/pull/88) `Androtim:feat/iter89-fence-blocking-and-bop-events` → `main` · +182 −42 · 2 files · 1 commits · merged 2026-11-29 14:32 UTC ## Summary Adapted from upstream `VIctory-NVIDIA` PRs #905 (`81b3653`) and #906 (`1841d59`) (GPL-3.0), extracted cleanly off `origin/main` (`7fe6886`) with zero overlap against open PRs: - **Blocking null-event fence waits (`crates/victory-gpu/src/fence.rs`, `crates/victory-gpu/src/queue.rs`):** `ID3D12Fence::SetEventOnCompletion` with a null event now waits in 10 ms `WaitOnAddress` slices until the target fence value is reached instead of returning `E_NOTIMPL` after 250 ms, settling late flights and releasing held queue work (`queue::release_forced()` after 2 s). - **Bottom-of-pipe fence write event wakeups (`crates/victory-gpu/src/fence.rs`, `crates/victory-gpu/src/queue.rs`):** Registers live `Fence` instances by `value` address and calls `fence::written` from `queue::Written::write` so 4-byte and 8-byte bottom-of-pipe GPU writes into a fence's address wake registered `SetEventOnCompletion` events just like `Signal`. ## Verification - `cargo xtask policy`: `asset policy: 303 files ok` - `cargo test -p victory-gpu --lib --locked -- fence:: queue::`: **14 passed; 0 failed** (including `a_null_event_blocks_until_the_value_is_reached` and `a_write_at_the_fence_address_sets_waiting_events`) - `cargo clippy --workspace --all-targets -- -D warnings`: **0 warnings** - `cargo clippy --workspace --all-targets --features diagnostics -- -D warnings`: **0 warnings** - Plain `--release` + `objdump -p`: standard Windows system DLLs only - Live 75s Series S GPU verification (`pr89-fence-blocking-bop`): **11/11 gates PASS** - Median FPS: `12.3 fps` (`81.2 ms`, vs `8.9 fps` baseline, `+3.40 fps`) - Max VRAM: `5869 MB` / `6961 MB` budget (`over=0 MB`) - Waiting textures: `2281` (vs `7121` baseline) | `mapped()` stall rate: `6.1 ms/s` - Shader translation: `untranslated=1` | Crashes / host texture errors: `0` / `0` - Visually inspected 24 captured frames (`frame-8478.png`, `frame-8518.png`, median luma `103.93`, edge energy `7.11`, `0.0%` near-black/magenta): clean daylight rendering with no hangs or artifacts.
Adapt VIctory-NVIDIA #905 (81b3653) and #906 (1841d59) (GPL-3.0):
- Block without timeout on ID3D12Fence::SetEventOnCompletion(value, NULL) using
  WaitOnAddress in 10 ms slices, flushing held queue submissions via
  queue::release_forced() after two seconds.
- Track live fences by value address so bottom-of-pipe writes landing at a
  fence GPU VA wake matching SetEventOnCompletion events as signals do.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:08:04 +00:00
github manually merged commit bdb094cff3 into gh-pr/88/base 2026-12-01 20:08:06 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-11-29 09:03 UTC · original

Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Review Summary

Changes in crates/victory-gpu/src/fence.rs and crates/victory-gpu/src/queue.rs are clean, well-scoped, and CI is passing.

What was verified:

  • Blocking null-event waits (fence::set_event_on_completion / fence::block_until, queue::release_forced): Replacing the 250 ms E_NOTIMPL timeout with a 10 ms WaitOnAddress loop matches ID3D12Fence::SetEventOnCompletion(value, NULL) semantics. Settling late flights (queue::before_sync + host::settle_for_fence) and calling queue::release_held(false) per slice avoids missing work submitted while blocked, and queue::release_forced() (gated on !behind::on() and forces()) mirrors present-time fallback after BLOCKED_LONG (2 s).
  • Bottom-of-pipe write wakeups (fence::LIVE, Fence::drop, fence::written, queue::Written::write): Fence is heap-pinned in a Box<Fence>, registered by &raw const fence.value in create, and unregistered in Drop::drop under LIVE. fence::written holds LIVE while dereferencing the Fence pointer and locking fence.waiters, preventing use-after-free during concurrent Drop with a consistent LIVE -> waiters lock order (no lock-order inversion with create, Drop, set, or set_event_on_completion).
  • Tests: a_null_event_blocks_until_the_value_is_reached and a_write_at_the_fence_address_sets_waiting_events cover both signal and 4/8-byte bottom-of-pipe write wakeups past the previous 250 ms cutoff.

Minor notes (non-blocking):

  • If a 4-byte bottom-of-pipe write hits the high half (start + 4), fence::written correctly detects the overlap and signals registered events, while WakeByAddressAll(at.cast()) in Written::write wakes start + 4 rather than &fence.value; block_until still wakes within its 10 ms WaitOnAddress slice, so it will not deadlock.
  • Removing the 250 ms timeout means an unsignaled null-event wait now blocks indefinitely by design (D3D12 behavior); worth confirming no title thread hangs on real GPU workloads.

Next step: Ready for a local real-GPU smoke test to confirm no deadlocks or frame-pacing regressions under live host submissions.


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-11-29 09:03 UTC · [original](https://github.com/Androtim/MiniVI/pull/88#issuecomment-7253507265) <!-- minivi-triage v1 head=bdb094cff35b7663e29cc43791ac6a181e835d98 verdict=needs-gpu-test ci=passing at=2026-11-29T09:04:01Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary Changes in `crates/victory-gpu/src/fence.rs` and `crates/victory-gpu/src/queue.rs` are clean, well-scoped, and CI is passing. **What was verified:** - **Blocking null-event waits (`fence::set_event_on_completion` / `fence::block_until`, `queue::release_forced`):** Replacing the 250 ms `E_NOTIMPL` timeout with a 10 ms `WaitOnAddress` loop matches `ID3D12Fence::SetEventOnCompletion(value, NULL)` semantics. Settling late flights (`queue::before_sync` + `host::settle_for_fence`) and calling `queue::release_held(false)` per slice avoids missing work submitted while blocked, and `queue::release_forced()` (gated on `!behind::on()` and `forces()`) mirrors present-time fallback after `BLOCKED_LONG` (2 s). - **Bottom-of-pipe write wakeups (`fence::LIVE`, `Fence::drop`, `fence::written`, `queue::Written::write`):** `Fence` is heap-pinned in a `Box<Fence>`, registered by `&raw const fence.value` in `create`, and unregistered in `Drop::drop` under `LIVE`. `fence::written` holds `LIVE` while dereferencing the `Fence` pointer and locking `fence.waiters`, preventing use-after-free during concurrent `Drop` with a consistent `LIVE` -> `waiters` lock order (no lock-order inversion with `create`, `Drop`, `set`, or `set_event_on_completion`). - **Tests:** `a_null_event_blocks_until_the_value_is_reached` and `a_write_at_the_fence_address_sets_waiting_events` cover both signal and 4/8-byte bottom-of-pipe write wakeups past the previous 250 ms cutoff. **Minor notes (non-blocking):** - If a 4-byte bottom-of-pipe write hits the high half (`start + 4`), `fence::written` correctly detects the overlap and signals registered events, while `WakeByAddressAll(at.cast())` in `Written::write` wakes `start + 4` rather than `&fence.value`; `block_until` still wakes within its 10 ms `WaitOnAddress` slice, so it will not deadlock. - Removing the 250 ms timeout means an unsignaled null-event wait now blocks indefinitely by design (D3D12 behavior); worth confirming no title thread hangs on real GPU workloads. **Next step:** Ready for a local real-GPU smoke test to confirm no deadlocks or frame-pacing regressions under live host submissions. --- _Generated with Antigravity CLI (`agy`)._
Author
Owner

@⁠Androtim on GitHub · 2026-11-29 10:41 UTC · original

Completed live 75s Series S GPU verification on bdb094cf (D:\victory-data\verify-runs\pr89-fence-blocking-bop):

  • Result: 11/11 gates PASS (crashes=0, no_host_texture_errors=0, untranslated=1, world_windows=15, max_draws=11549)
  • Performance & Memory: median 12.3 fps (+3.40 vs baseline 8.9 fps), max VRAM 5869 MB / budget min 6961 MB (over=0 MB), final waiting textures 2281 (-4840 vs baseline 7121), mapped() rate 6.1 ms/world_sec, pipeline drops 271 vs 261.0 (PASS)
  • Visuals: 24 captures, lit=20/24, median luma 103.93, near_black=0.0%, magenta=0.0%, edge_energy=7.11
**@⁠Androtim** on GitHub · 2026-11-29 10:41 UTC · [original](https://github.com/Androtim/MiniVI/pull/88#issuecomment-7254602577) Completed live 75s Series S GPU verification on `bdb094cf` (`D:\victory-data\verify-runs\pr89-fence-blocking-bop`): - **Result:** **11/11 gates PASS** (`crashes=0`, `no_host_texture_errors=0`, `untranslated=1`, `world_windows=15`, `max_draws=11549`) - **Performance & Memory:** median `12.3 fps` (+3.40 vs baseline `8.9 fps`), max VRAM `5869 MB` / budget min `6961 MB` (`over=0 MB`), final waiting textures `2281` (-4840 vs baseline `7121`), `mapped()` rate `6.1 ms/world_sec`, pipeline drops `271` vs `261.0` (PASS) - **Visuals:** `24` captures, `lit=20/24`, median luma `103.93`, `near_black=0.0%`, `magenta=0.0%`, `edge_energy=7.11`
Author
Owner

@⁠Androtim on GitHub · 2026-11-29 14:32 UTC · original

Automated RTX 4060 Ti 8 GB Wave 3 A/B hardware verification passed (playtest/wave3 vs origin/main c7ed150 — 5/5 A/B gates PASS):

  • Hardware cargo test (RTX 4060 Ti): victory-gpu 542 passed, 0 failed (36 ignored); victory-shader 323 passed, 0 Wave 3 regressions (the 3 PSV0 validation failures in emit::rect::tests and emit::barycentric_tests also fail identically on origin/main c7ed150).
  • Automated 45s in-world A/B (scripts/verify-world.ps1, DLSS Quality + golden autosave):
    • FPS: median 10.25 fps vs 10.7 fps baseline (min FPS improved 6.9 vs 4.2, preparing 45.35 ms vs 50.3 ms)
    • Stability: 0 crashes / 0 DRED / 0 untranslated shaders
    • VRAM: max 5948 MB vs 6073 MB (-125 MB, 0 MB over budget)
    • Texture backlog: final_waiting=5487 vs 7350 (-1863); no room for new ones 38 vs 43
    • Residency stalls: mapped_rate=20.95 ms/s vs 37.22 ms/s (-44%)
    • Visual check: Clean rendered frames (frame-10645.png, frame-10669.png), luma 82.77 vs 23.2, edge energy 2.27 vs 1.81, magenta 0.0%.
**@⁠Androtim** on GitHub · 2026-11-29 14:32 UTC · [original](https://github.com/Androtim/MiniVI/pull/88#issuecomment-7257379211) Automated RTX 4060 Ti 8 GB Wave 3 A/B hardware verification passed (`playtest/wave3` vs `origin/main` `c7ed150` — **5/5 A/B gates PASS**): - **Hardware `cargo test` (RTX 4060 Ti):** `victory-gpu` **542 passed, 0 failed** (36 ignored); `victory-shader` **323 passed, 0 Wave 3 regressions** (the 3 PSV0 validation failures in `emit::rect::tests` and `emit::barycentric_tests` also fail identically on `origin/main` `c7ed150`). - **Automated 45s in-world A/B (`scripts/verify-world.ps1`, DLSS Quality + golden autosave):** - **FPS:** median `10.25 fps` vs `10.7 fps` baseline (min FPS improved **`6.9`** vs `4.2`, preparing **`45.35 ms`** vs `50.3 ms`) - **Stability:** **0** crashes / **0** DRED / **0** untranslated shaders - **VRAM:** max **`5948 MB`** vs `6073 MB` (**-125 MB**, `0 MB` over budget) - **Texture backlog:** `final_waiting=5487` vs `7350` (**-1863**); `no room for new ones` `38` vs `43` - **Residency stalls:** `mapped_rate=20.95 ms/s` vs `37.22 ms/s` (**-44%**) - **Visual check:** Clean rendered frames (`frame-10645.png`, `frame-10669.png`), luma `82.77` vs `23.2`, edge energy `2.27` vs `1.81`, magenta `0.0%`.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Androtim--MiniVI!88
No description provided.