perf(gpu/memory): targeted frame-boundary sync for BVH compacted-size queries (#339) #343

Merged
Androtim merged 2 commits from upstream-pr/343 into main 2026-12-02 22:33:13 +00:00
Androtim commented 2026-12-02 14:36:54 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T14:36:54Z.


Phase 1c of #339 — Eliminates the ~20 ms/frame full-pipeline stall of legacy \VICTORY_BVH_SIZES_WAIT=1\ while synchronizing dynamic BVH compacted-size readback queries without starving subsequent draw submissions:

Changes

  • Targeted SIZES flight landing (host/sizes.rs, host.rs):
    • Host::send_late records sent.number for submissions carrying BVH size queries (sks_size) without calling full-line Host::settle.
    • Added sizes::settle_until and sizes::settle_for_present: when
      elay() is enabled, waits only until FINISHED >= target_flight (keeping later draw submissions and late_free_present() in flight rather than draining line.line).
    • Upgraded opt-in VICTORY_BVH_SIZES_WAIT=1 to use settle_until instead of draining later flights.
  • Frame-boundary synchronization (queue.rs, queue/behind.rs):
    • Present drains any queued SIZES submissions in ehind::LANE (only when SIZES work was actually queued) and calls host::settle_sizes_for_present() before advancing to the next frame.
    • Zero runtime cost when BVH builder size queries are inactive (PENDING_FLIGHT == 0, SIZES_SEEN == false).
  • Compacted-size query detection & quiet wake (memory.rs, shadow.rs, quiet.rs):
    • Added VICTORY_BVH_SIZES_SYNC (deferred frame-boundary mode on by default for sks_size dispatches; =0 disables; VICTORY_BVH_SIZES_WAIT=1 keeps eager mode).
    • Checked all root UAV slots in sks_size and woke Quiet on queried small buffers (shadow::wake_quiet) so copybacks are never muted across idle frames.

Audit Note: \lobomfz/VIctory-xmem\ (\VICTORY_BVH_HARDWARE)

  • Audited \xmem's \OP_BVH64_INTERSECT_RAY\ (\
<!-- greyfinch-sync:Androtim/MiniVI:issue:5608616369 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/343). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T14:36:54Z. --- Phase 1c of #339 — Eliminates the ~20 ms/frame full-pipeline stall of legacy \VICTORY_BVH_SIZES_WAIT=1\ while synchronizing dynamic BVH compacted-size readback queries without starving subsequent draw submissions: ### Changes - **Targeted SIZES flight landing ([host/sizes.rs](crates/victory-gpu/src/host/sizes.rs), [host.rs](crates/victory-gpu/src/host.rs)):** - Host::send_late records sent.number for submissions carrying BVH size queries (sks_size) without calling full-line Host::settle. - Added sizes::settle_until and sizes::settle_for_present: when elay() is enabled, waits only until FINISHED >= target_flight (keeping later draw submissions and late_free_present() in flight rather than draining line.line). - Upgraded opt-in VICTORY_BVH_SIZES_WAIT=1 to use settle_until instead of draining later flights. - **Frame-boundary synchronization ([queue.rs](crates/victory-gpu/src/queue.rs), [queue/behind.rs](crates/victory-gpu/src/queue/behind.rs)):** - Present drains any queued SIZES submissions in ehind::LANE (only when SIZES work was actually queued) and calls host::settle_sizes_for_present() before advancing to the next frame. - Zero runtime cost when BVH builder size queries are inactive (PENDING_FLIGHT == 0, SIZES_SEEN == false). - **Compacted-size query detection & quiet wake ([memory.rs](crates/victory-gpu/src/memory.rs), [shadow.rs](crates/victory-gpu/src/shadow.rs), [quiet.rs](crates/victory-gpu/src/quiet.rs)):** - Added VICTORY_BVH_SIZES_SYNC (deferred frame-boundary mode on by default for sks_size dispatches; =0 disables; VICTORY_BVH_SIZES_WAIT=1 keeps eager mode). - Checked all root UAV slots in sks_size and woke Quiet on queried small buffers (shadow::wake_quiet) so copybacks are never muted across idle frames. ### Audit Note: \lobomfz/VIctory-xmem\ (\VICTORY_BVH_HARDWARE\) - Audited \xmem\'s \OP_BVH64_INTERSECT_RAY\ (\
Androtim commented 2026-12-02 15:04:11 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T15:04:11Z.


Holding merge (triage: needs work) per deep static audit routing (#282 comment 7349410307, P0/P1 findings #13, #14, #16, #17 routed to #339). Please resolve the flagged findings, re-verify CI, and run a paired plain---release RT-off A/B + --features diagnostics PNG check before merge.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7349658300 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/343#issuecomment-7349658300). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T15:04:11Z. --- Holding merge (`triage: needs work`) per deep static audit routing (`#282` comment `7349410307`, P0/P1 findings #13, #14, #16, #17 routed to `#339`). Please resolve the flagged findings, re-verify CI, and run a paired plain-`--release` RT-off A/B + `--features diagnostics` PNG check before merge.
Androtim commented 2026-12-02 15:05:21 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T15:05:21Z.


Automated triage for the maintainers (not an approval).

Verdict: needs-rebase · CI (check): passing

This PR no longer merges cleanly into main.

To change the verdict: Rebase onto current main and resolve conflicts; CI and triage will run again automatically.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7349696390 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/343#issuecomment-7349696390). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T15:05:21Z. --- <!-- minivi-triage v1 head=6b9c8435ed0e1d17ca6d9c8c24ed26447955d183 verdict=needs-rebase ci=passing at=2026-12-02T17:06:15Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-rebase` · **CI (`check`):** `passing` This PR no longer merges cleanly into `main`. **To change the verdict:** Rebase onto current `main` and resolve conflicts; CI and triage will run again automatically. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-12-02 16:29:04 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T16:29:04Z.


Rebased onto \main\ (\80d3ff4) and resolved #282\ P1 finding #17 (plus the \ehind.rs\ and \memory.rs\ triage notes):

  • Eliminated per-frame drains & load-order race (\pipeline.rs, \list/thin.rs, \queue/behind.rs, \memory.rs): Removed \SIZES_SEEN, \THIN_QUEUED, and \THIN_DONE. Added \Recording::has_sizes\ via \pipeline::maybe_size_query\ on thin \DISPATCH/\DISPATCH_X/\EXECUTE_INDIRECT\ calls and carried \had_sizes\ on \Job::Lists. \Job::unfold\ now calls
    ote_queued_sizes(&jobs)\ (publishing \SIZES_QUEUED) before incrementing \THIN_SIZES_DONE, and \has_pending_sizes()\ loads \THIN_SIZES_DONE\ before \SIZES_QUEUED.
  • Fixed \Quiet::wake\ near-threshold bypass (\quiet.rs): Always acquires \self.state\ and resets \streak = 0; audit = 0; range = None\ alongside \self.ready, even when \self.ready\ was still \ alse. Also filtered \wake_quiet\ in \memory.rs\ to small buffers matching \in_buffer(at, 1).is_some_and(|b| b.1 <= BACK).

Verified (\VICTORY_D3D12_WARP=1): \list::thin::tests\ (\13 passed; 0 failed), \queue::behind::tests\ (\9 passed; 0 failed), \quiet::tests\ (\8 passed; 0 failed), \host::sizes::tests\ (\2 passed; 0 failed), \memory::tests\ (\10 passed; 0 failed), workspace \clippy --all-targets\ (normal & --all-features), and \xtask policy --staged\ (\5 files ok). Ready for CI and maintainer GPU check.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7352012171 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/343#issuecomment-7352012171). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T16:29:04Z. --- Rebased onto \main\ (\80d3ff4\) and resolved \#282\ P1 finding #17 (plus the \ehind.rs\ and \memory.rs\ triage notes): - **Eliminated per-frame drains & load-order race (\pipeline.rs\, \list/thin.rs\, \queue/behind.rs\, \memory.rs\):** Removed \SIZES_SEEN\, \THIN_QUEUED\, and \THIN_DONE\. Added \Recording::has_sizes\ via \pipeline::maybe_size_query\ on thin \DISPATCH\/\DISPATCH_X\/\EXECUTE_INDIRECT\ calls and carried \had_sizes\ on \Job::Lists\. \Job::unfold\ now calls \ ote_queued_sizes(&jobs)\ (publishing \SIZES_QUEUED\) *before* incrementing \THIN_SIZES_DONE\, and \has_pending_sizes()\ loads \THIN_SIZES_DONE\ *before* \SIZES_QUEUED\. - **Fixed \Quiet::wake\ near-threshold bypass (\quiet.rs\):** Always acquires \self.state\ and resets \streak = 0; audit = 0; range = None\ alongside \self.ready\, even when \self.ready\ was still \ alse\. Also filtered \wake_quiet\ in \memory.rs\ to small buffers matching \in_buffer(at, 1).is_some_and(|b| b.1 <= BACK)\. Verified (\VICTORY_D3D12_WARP=1\): \list::thin::tests\ (\13 passed; 0 failed\), \queue::behind::tests\ (\9 passed; 0 failed\), \quiet::tests\ (\8 passed; 0 failed\), \host::sizes::tests\ (\2 passed; 0 failed\), \memory::tests\ (\10 passed; 0 failed\), workspace \clippy --all-targets\ (normal & \--all-features\), and \xtask policy --staged\ (\5 files ok\). Ready for CI and maintainer GPU check.
Androtim commented 2026-12-02 19:37:23 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T19:37:23Z.


Deep Static Logic Audit Pass #3 (#282 comment 7355749301) signed off 6b9c8435 as VERIFIED CLEAN (Green Light) — Pass #1 Finding #17 is cleanly resolved. Rebase onto current main to resolve merge conflicts and pass CI, and this is ready to merge immediately.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7356464635 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/343#issuecomment-7356464635). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T19:37:23Z. --- Deep Static Logic Audit Pass #3 (`#282` comment `7355749301`) signed off `6b9c8435` as **VERIFIED CLEAN (Green Light)** — Pass #1 Finding `#17` is cleanly resolved. Rebase onto current `main` to resolve merge conflicts and pass CI, and this is ready to merge immediately.
Androtim commented 2026-12-02 22:33:10 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T22:33:10Z.


Rebased cleanly onto main (a0ba51f8), Deep Static Audit Pass #3 & Pass #4 verified clean (Pass #1 #17 resolved), CI GREEN. Merging #339 Phase 1c targeted frame-boundary sync for BVH compacted-size queries to main.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7360847504 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/343#issuecomment-7360847504). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T22:33:10Z. --- Rebased cleanly onto `main` (`a0ba51f8`), Deep Static Audit Pass #3 & Pass #4 verified clean (Pass #1 `#17` resolved), CI **GREEN**. Merging `#339` Phase 1c targeted frame-boundary sync for BVH compacted-size queries to `main`.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Androtim/MiniVI!343
No description provided.