gpu(draw,host): scan root views for bake sources and pin copies on bake list #156

Merged
Androtim merged 1 commit from upstream-pr/156 into main 2026-11-29 21:27:21 +00:00
Androtim commented 2026-11-29 19:14:09 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T19:14:09Z.


Addresses #150

Prevents bindless decoration bake sources from being missed or evicted between bake recording and GPU execution:

Changes

  • crates/victory-gpu/src/draw.rs (State::bake_sources, bake_srv_slice):
    • Scan root descriptor CBVs (RootType::Descriptor, reading up to 4096 bytes) and root descriptor pixel-stage SRVs (RootType::Descriptor, narrowed by bake_srv_slice when record range + stride apply) alongside descriptor-table CBVs/SRVs.
  • crates/victory-gpu/src/host.rs & crates/victory-gpu/src/draw.rs (HostList::keep_copies, bring_bake_sources, early_textures):
    • Added Deferred::kept_copies and HostList::keep_copies (cleared on HostList::reset and included in untouched()).
    • Retained Arc<HostTexture> copies in bring_bake_sources across all valid source branches (is_aliased, host-written, unchanged, upload_listed, and uploaded) and pinned them onto the bake draw's HostList in early_textures instead of dropping sync.keep right after BAKE_UPLOAD, keeping Arc::strong_count > 1 until GPU execution finishes so let_go_idle / slot_evict cannot evict active bake sources mid-flight.
  • Added bake_srv_slice_respects_range_for_bounded_and_root_buffers unit test.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu run --locked -p xtask -- policy
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- draw::
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- host::
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --locked --all-targets -- -D warnings (default features and --all-features)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5554149055 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/156). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T19:14:09Z. --- Addresses #150 Prevents bindless decoration bake sources from being missed or evicted between bake recording and GPU execution: ### Changes - **`crates/victory-gpu/src/draw.rs` (`State::bake_sources`, `bake_srv_slice`):** - Scan root descriptor CBVs (`RootType::Descriptor`, reading up to 4096 bytes) and root descriptor pixel-stage SRVs (`RootType::Descriptor`, narrowed by `bake_srv_slice` when record range + stride apply) alongside descriptor-table CBVs/SRVs. - **`crates/victory-gpu/src/host.rs` & `crates/victory-gpu/src/draw.rs` (`HostList::keep_copies`, `bring_bake_sources`, `early_textures`):** - Added `Deferred::kept_copies` and `HostList::keep_copies` (cleared on `HostList::reset` and included in `untouched()`). - Retained `Arc<HostTexture>` copies in `bring_bake_sources` across all valid source branches (`is_aliased`, host-written, unchanged, `upload_listed`, and uploaded) and pinned them onto the bake draw's `HostList` in `early_textures` instead of dropping `sync.keep` right after `BAKE_UPLOAD`, keeping `Arc::strong_count > 1` until GPU execution finishes so `let_go_idle` / `slot_evict` cannot evict active bake sources mid-flight. - Added `bake_srv_slice_respects_range_for_bounded_and_root_buffers` unit test. ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu run --locked -p xtask -- policy` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- draw::` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- host::` - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --locked --all-targets -- -D warnings` (default features and `--all-features`)
Androtim commented 2026-11-29 19:23:55 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T19:23:55Z.


Live RTX 4060 Ti 8 GB verification (scripts/verify-world.ps1 with --features diagnostics for VICTORY_CAPTURE, VICTORY_SLOT_EVICT=1, 86/80% eviction thresholds, VICTORY_TEXTURE_ROOM_PERCENT=88, Series S 60s warm run b701929a):

  • Decoration bake sync & retention (stderr.log):
    • decoration bakes' sources, since the start bakes=16 sources=185 current=144 showed_another_view=3 no_host_copy=0 other_bytes=31 host_written_published=7 not_mapped=0 failed=0
    • flushed deferred texture stand-ins before decoration bake: settled=true
  • World rendering & visual gate (PASS):
    • pngs=24, lit=15/24, median luma 103.41, near-black 1.49%, edge energy 7.4, max magenta 0.0%
    • Visual inspection of late world captures (frame-4449.png, frame-4481.png) confirms clean skin, clothing, foliage, water, lighting, and UI with zero colored-square artifacts.
  • Runtime & telemetry notes:
    • Passed: Reached real 3D world (world_windows=15, max_draws=11157), Zero crashes / DRED / panics (crashes=0, no_host_texture_errors=0), Residency stalls bounded (mapped_rate=4.35 ms/world_sec), Visual lighting & texture detail. (median 10.6 fps)
    • Expected base-branch VRAM note: because this PR branches from origin/main without PR #153's pool-hole reuse (reuse_pool_when_full), running VICTORY_SLOT_EVICT=1 at 86/80% while used=5467 MB + buffers (127 MB) + pending render targets (559 MB) exceeded the 5963 MB (88%) room line left room_false=83.3% and final_waiting=8206 (which is already solved on PR #153).
<!-- greyfinch-sync:Androtim/MiniVI:comment:7261247481 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/156#issuecomment-7261247481). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T19:23:55Z. --- Live RTX 4060 Ti 8 GB verification (`scripts/verify-world.ps1` with `--features diagnostics` for `VICTORY_CAPTURE`, `VICTORY_SLOT_EVICT=1`, `86/80%` eviction thresholds, `VICTORY_TEXTURE_ROOM_PERCENT=88`, Series S 60s warm run `b701929a`): - **Decoration bake sync & retention (`stderr.log`):** - `decoration bakes' sources, since the start bakes=16 sources=185 current=144 showed_another_view=3 no_host_copy=0 other_bytes=31 host_written_published=7 not_mapped=0 failed=0` - `flushed deferred texture stand-ins before decoration bake`: `settled=true` - **World rendering & visual gate (`PASS`):** - `pngs=24`, `lit=15/24`, median luma `103.41`, near-black `1.49%`, edge energy `7.4`, max magenta `0.0%` - Visual inspection of late world captures (`frame-4449.png`, `frame-4481.png`) confirms clean skin, clothing, foliage, water, lighting, and UI with zero colored-square artifacts. - **Runtime & telemetry notes:** - Passed: `Reached real 3D world` (`world_windows=15`, `max_draws=11157`), `Zero crashes / DRED / panics` (`crashes=0`, `no_host_texture_errors=0`), `Residency stalls bounded` (`mapped_rate=4.35 ms/world_sec`), `Visual lighting & texture detail`. (`median 10.6 fps`) - Expected base-branch VRAM note: because this PR branches from `origin/main` without PR #153's pool-hole reuse (`reuse_pool_when_full`), running `VICTORY_SLOT_EVICT=1` at `86/80%` while `used=5467 MB` + buffers (`127 MB`) + pending render targets (`559 MB`) exceeded the `5963 MB` (`88%`) room line left `room_false=83.3%` and `final_waiting=8206` (which is already solved on PR #153).
Androtim commented 2026-11-29 20:03:14 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T20:03:14Z.


Automated triage for the maintainers (not an approval).

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

Review Summary

CI is passing, the diff is focused and clean, and the logic addresses both parts of the bindless decoration-bake source race:

  1. Root-descriptor bake source scanning (crates/victory-gpu/src/draw.rs):
    • State::bake_sources now scans RootType::Descriptor (Root::View(address)) for CBVs (up to ROOT_CBV_BYTES = 4096) and pixel-stage SRVs (passed through the new bake_srv_slice helper with len = u64::MAX, clamped to MOST_BYTES = 64 KiB in read), alongside existing RootType::Table entries.
    • bake_srv_slice is covered by the new unit test bake_srv_slice_respects_range_for_bounded_and_root_buffers.
  2. Pinning bake source textures until GPU execution (crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/host.rs):
    • State::bring_bake_sources now pushes crate::resource::host_copy(resource) into sync.keep across all valid source branches (is_aliased, host-written, shown && unchanged, upload_listed, and freshly uploaded).
    • State::early_textures transfers sync.keep to the bake draw's command list via list.keep_copies(sync.keep) instead of dropping it immediately after BAKE_UPLOAD.
    • HostList::keep_copies, Deferred::kept_copies, Deferred::clear, and HostList::untouched are wired consistently so pinned Arc<HostTexture> copies stay alive until the bake list resets.

Minor Non-Blocking Notes

  • In bake_srv_slice, checking end > first (in addition to stride > 0 && u64::from(end) * stride <= len) and using address.checked_add(...) would harden the helper against reversed ranges or address wrap if ever called outside bake_record_range.
  • Because this changes GPU texture lifetime pinning and decoration-bake source scanning on the D3D12 host, a quick local real-GPU smoke test is warranted before merging (especially to confirm no VRAM-pressure regressions from kept_copies and that root CBV/SRV read_into scans behave cleanly near allocation boundaries).

Verdict

needs-gpu-test — Logic and tests look solid with CI passing; ready for a local real-GPU smoke test.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7261768340 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/156#issuecomment-7261768340). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T20:03:14Z. --- <!-- minivi-triage v1 head=b701929a2d91d0bb8f037995b5b2622f768738dd verdict=needs-gpu-test ci=passing at=2026-11-29T20:03:48Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary CI is **passing**, the diff is focused and clean, and the logic addresses both parts of the bindless decoration-bake source race: 1. **Root-descriptor bake source scanning (`crates/victory-gpu/src/draw.rs`):** - `State::bake_sources` now scans `RootType::Descriptor` (`Root::View(address)`) for CBVs (up to `ROOT_CBV_BYTES = 4096`) and pixel-stage SRVs (passed through the new `bake_srv_slice` helper with `len = u64::MAX`, clamped to `MOST_BYTES = 64 KiB` in `read`), alongside existing `RootType::Table` entries. - `bake_srv_slice` is covered by the new unit test `bake_srv_slice_respects_range_for_bounded_and_root_buffers`. 2. **Pinning bake source textures until GPU execution (`crates/victory-gpu/src/draw.rs`, `crates/victory-gpu/src/host.rs`):** - `State::bring_bake_sources` now pushes `crate::resource::host_copy(resource)` into `sync.keep` across all valid source branches (`is_aliased`, host-written, `shown && unchanged`, `upload_listed`, and freshly uploaded). - `State::early_textures` transfers `sync.keep` to the bake draw's command list via `list.keep_copies(sync.keep)` instead of dropping it immediately after `BAKE_UPLOAD`. - `HostList::keep_copies`, `Deferred::kept_copies`, `Deferred::clear`, and `HostList::untouched` are wired consistently so pinned `Arc<HostTexture>` copies stay alive until the bake list resets. ### Minor Non-Blocking Notes - In `bake_srv_slice`, checking `end > first` (in addition to `stride > 0 && u64::from(end) * stride <= len`) and using `address.checked_add(...)` would harden the helper against reversed ranges or address wrap if ever called outside `bake_record_range`. - Because this changes GPU texture lifetime pinning and decoration-bake source scanning on the D3D12 host, a quick local real-GPU smoke test is warranted before merging (especially to confirm no VRAM-pressure regressions from `kept_copies` and that root CBV/SRV `read_into` scans behave cleanly near allocation boundaries). ### Verdict **`needs-gpu-test`** — Logic and tests look solid with CI passing; ready for a local real-GPU smoke test. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-11-29 21:27:18 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T21:27:18Z.


Automated RTX 4060 Ti 8 GB Open-World A/B hardware verification PASSED (playtest/wave5 vs origin/main b1b6dc1, VICTORY_LEVELS_ON_DEMAND=0 play-parity):

  • Hardware cargo test (RTX 4060 Ti): 645 passed, 0 failed (victory 39/39, victory-shader emit::wave64_tests 19/19 & lower 19/19, victory-gpu 568/568).
  • 45s Open-World A/B (scripts/verify-world.ps1, DLSS Quality + open-world save):
    • FPS: median 9.4 fps vs 7.5 fps (+1.90 fps / +25%), min 8.3 fps vs 0.8 fps, preparing 53.6 ms vs 60.0 ms
    • Stability: 0 crashes / 0 DRED / 0 untranslated shaders
    • VRAM / Issue #149: max 5760 MB vs 6005 MB (-245 MB, 0 MB over budget); no room for new ones halved (9,000 vs 18,000); max_waiting dropped (36,432 vs 41,431)
    • Decoration bakes / Issue #150: 0 mismatches (other_bytes=0, showed_another_view=0, failed=0 vs 5 and 2 on baseline)
    • Residency stalls: mapped_rate 1.63 ms/s vs 6.9 ms/s (-76%, max 12.9 vs 51.9 ms)
    • Visual check: Clean open-world safehouse frames (frame-5975.png, frame-5983.png), edge_energy=4.69 vs 3.88, near_black=0.02%, magenta=0.0% (and #141 2bf6800 showed zero visual artifacts).
<!-- greyfinch-sync:Androtim/MiniVI:comment:7262888426 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/156#issuecomment-7262888426). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T21:27:18Z. --- Automated RTX 4060 Ti 8 GB **Open-World** A/B hardware verification **PASSED** (`playtest/wave5` vs `origin/main` `b1b6dc1`, `VICTORY_LEVELS_ON_DEMAND=0` play-parity): - **Hardware `cargo test` (RTX 4060 Ti):** **645 passed, 0 failed** (`victory` 39/39, `victory-shader` `emit::wave64_tests` 19/19 & `lower` 19/19, `victory-gpu` 568/568). - **45s Open-World A/B (`scripts/verify-world.ps1`, DLSS Quality + open-world save):** - **FPS:** median **`9.4 fps`** vs `7.5 fps` (**+1.90 fps / +25%**), min **`8.3 fps`** vs **`0.8 fps`**, preparing `53.6 ms` vs `60.0 ms` - **Stability:** **0** crashes / **0** DRED / **0** untranslated shaders - **VRAM / Issue #149:** max **`5760 MB`** vs `6005 MB` (**-245 MB**, `0 MB` over budget); `no room for new ones` halved (**`9,000`** vs `18,000`); `max_waiting` dropped (`36,432` vs `41,431`) - **Decoration bakes / Issue #150:** **`0` mismatches** (`other_bytes=0, showed_another_view=0, failed=0` vs `5` and `2` on baseline) - **Residency stalls:** `mapped_rate` **`1.63 ms/s`** vs `6.9 ms/s` (**-76%**, max `12.9` vs `51.9 ms`) - **Visual check:** Clean open-world safehouse frames (`frame-5975.png`, `frame-5983.png`), `edge_energy=4.69` vs `3.88`, `near_black=0.02%`, `magenta=0.0%` (and `#141` `2bf6800` showed zero visual artifacts).
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!156
No description provided.