victory-gpu: honor on-demand level bounds when staging textures #17

Merged
Androtim merged 1 commit from upstream-pr/17 into main 2026-11-29 02:05:24 +00:00
Androtim commented 2026-11-28 05:56:18 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T05:56:18Z.


Summary

Honor VICTORY_LEVELS_ON_DEMAND mip bounds and VICTORY_LEVELS_MAX_DIM caps when sizing and copying staging buffers in crates/victory-gpu/src/texture.rs:

  • Preserve the requested first mip in upload_listed and upload_from whenever crate::tiles::wanted() is active (not only resource::held_only()).
  • Extract judgement_at, held_levels_of, and on_demand_first so staging() computes the lowest held/capped mip before locking STAGING (preserving lock ordering), skipping unheld/capped coarse mips and falling back to the smallest mip when held == 0.
  • Mask held in Staging::detile by !0u32 << self.first before storing detiled.
  • Skip unheld subresource CopyTextureRegion calls in PreludeUpload::record when self.staging.on_demand is enabled (after detile() populates detiled).
  • Add on_demand_staging_tests::on_demand_first_tracks_committed_levels_and_max_dim over VirtualAlloc (MEM_RESERVE / partial MEM_COMMIT / max_dim = Some(512)).

Note: PR #17 eliminates the staging bloat introduced under VICTORY_LEVELS_ON_DEMAND=1 and depends on PR #12 (fc23fb3) to exercise tiled on_demand allocations cleanly.

Rig Specs Tested On

  • CPU: 13th Gen Intel(R) Core(TM) i7-13700F
  • GPU & VRAM: NVIDIA GeForce RTX 4060 Ti (8 GiB VRAM)
  • System RAM: 32 GiB
  • OS & GPU Driver: Windows 11 Home (Build 26300) / NVIDIA Driver 32.0.16.2124

Run Settings & Profile

  • Build & Commit SHA: --release --features victory-gpu/diagnostics A/B binary built on detached origin/main + PR #12 (fc23fb3) + PR #17 (f910dae), plus clean --release build @ f910daea4b34c9178f96336c2236e8a754b7f098 (0 non-system MinGW DLLs)
  • Console Profile & Internal Resolution / Scale: series-s
  • Ray Tracing: off
  • Upscaling: DLSS quality
  • Frame Generation: off
  • Launcher Command / Preset & Extra VICTORY_* Overrides: D:\victory-build\verify-tools\verify-world.ps1 with -LevelsOnDemand (VICTORY_LEVELS_ON_DEMAND=1), -GoldenDataDir 'D:\victory-data\golden-data-minivi', -WorldSeconds 75, -AutoNudgeMenu
  • Scene / Area & Session Length: Mission-1 golden autosave (dock -> balcony), 75s in-world telemetry (14 world windows, up to 11,659 draws/frame)

Measurements & Verification

  • Base FPS (without Frame Gen): 4.4 fps median / 5.76 fps mean across all 14 windows (9.1–10.0 fps on the steady balcony; dock streaming windows 2.2–2.9 fps while PSOs compiled).
    • vs pr12-lod (PR #12 alone, VICTORY_LEVELS_ON_DEMAND=1): median FPS 2.9 -> 4.4 fps (+52%), staging blocks 2,816 MB -> 256–320 MB, uploaded bytes 11,337 MB -> 2,264 MB, staging uploads 1,730 ms/5s -> 42–55 ms/5s, unmapped mips median 120.0 -> 75.0 MB, final_waiting 26,190 -> 11,252, 0 host memory pressure warnings.
    • Honest comparison vs baseline-main (VICTORY_LEVELS_ON_DEMAND=0, 8.9 fps median, 5,864 MB VRAM): dock windows still ran slower (2.2–2.9 fps vs 6.1–7.2 fps) and peak VRAM reached 6,266 MB (1,111 MB in tile heaps).
  • Frame-Gen FPS (if enabled): off
  • VRAM / RAM Usage: 5,886.5 MB median / 6,266 MB peak VRAM of 6,939 MB budget (over=0 MB, room_false=0.0%, 9,188 tiled alive max); visuals lit=18/24, luma=105.47, edge_energy=6.96, magenta=0.0% (inspected frame-8136.png & frame-8668.png)
  • Crashes / DRED Resets: 0 (crashes=0, no_host_texture_errors=0)
  • Automated Checks:
    • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy (294 files ok)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask (6 passed; 0 failed)
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings (0 warnings)
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features victory-gpu/diagnostics -- -D warnings (0 warnings)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu (449 passed; 0 failed; 36 ignored, including on_demand_staging_tests::on_demand_first_tracks_committed_levels_and_max_dim)
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu levels_on_demand -- --ignored (1 passed: tiles::tests::levels_on_demand_on_the_card)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5537254472 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/17). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T05:56:18Z. --- ## Summary Honor `VICTORY_LEVELS_ON_DEMAND` mip bounds and `VICTORY_LEVELS_MAX_DIM` caps when sizing and copying staging buffers in [`crates/victory-gpu/src/texture.rs`](https://github.com/Androtim/MiniVI/blob/f910daea4b34c9178f96336c2236e8a754b7f098/crates/victory-gpu/src/texture.rs): - Preserve the requested `first` mip in `upload_listed` and `upload_from` whenever `crate::tiles::wanted()` is active (not only `resource::held_only()`). - Extract `judgement_at`, `held_levels_of`, and `on_demand_first` so `staging()` computes the lowest held/capped mip before locking `STAGING` (preserving lock ordering), skipping unheld/capped coarse mips and falling back to the smallest mip when `held == 0`. - Mask `held` in `Staging::detile` by `!0u32 << self.first` before storing `detiled`. - Skip unheld subresource `CopyTextureRegion` calls in `PreludeUpload::record` when `self.staging.on_demand` is enabled (after `detile()` populates `detiled`). - Add `on_demand_staging_tests::on_demand_first_tracks_committed_levels_and_max_dim` over `VirtualAlloc` (`MEM_RESERVE` / partial `MEM_COMMIT` / `max_dim = Some(512)`). Note: PR #17 eliminates the staging bloat introduced under `VICTORY_LEVELS_ON_DEMAND=1` and depends on PR #12 (`fc23fb3`) to exercise tiled `on_demand` allocations cleanly. ## Rig Specs Tested On - **CPU:** `13th Gen Intel(R) Core(TM) i7-13700F` - **GPU & VRAM:** `NVIDIA GeForce RTX 4060 Ti` (`8 GiB` VRAM) - **System RAM:** `32 GiB` - **OS & GPU Driver:** `Windows 11 Home (Build 26300)` / NVIDIA Driver `32.0.16.2124` ## Run Settings & Profile - **Build & Commit SHA:** `--release --features victory-gpu/diagnostics` A/B binary built on detached `origin/main` + PR #12 (`fc23fb3`) + PR #17 (`f910dae`), plus clean `--release` build @ `f910daea4b34c9178f96336c2236e8a754b7f098` (`0` non-system MinGW DLLs) - **Console Profile & Internal Resolution / Scale:** `series-s` - **Ray Tracing:** `off` - **Upscaling:** `DLSS quality` - **Frame Generation:** `off` - **Launcher Command / Preset & Extra `VICTORY_*` Overrides:** `D:\victory-build\verify-tools\verify-world.ps1` with `-LevelsOnDemand` (`VICTORY_LEVELS_ON_DEMAND=1`), `-GoldenDataDir 'D:\victory-data\golden-data-minivi'`, `-WorldSeconds 75`, `-AutoNudgeMenu` - **Scene / Area & Session Length:** Mission-1 golden autosave (`dock` -> `balcony`), 75s in-world telemetry (`14` world windows, up to `11,659` draws/frame) ## Measurements & Verification - **Base FPS (without Frame Gen):** `4.4 fps` median / `5.76 fps` mean across all 14 windows (`9.1–10.0 fps` on the steady balcony; dock streaming windows `2.2–2.9 fps` while PSOs compiled). - vs `pr12-lod` (`PR #12` alone, `VICTORY_LEVELS_ON_DEMAND=1`): median FPS `2.9 -> 4.4 fps` (`+52%`), staging blocks **`2,816 MB -> 256–320 MB`**, uploaded bytes **`11,337 MB -> 2,264 MB`**, staging uploads **`1,730 ms/5s -> 42–55 ms/5s`**, unmapped mips median **`120.0 -> 75.0 MB`**, `final_waiting` **`26,190 -> 11,252`**, `0` host memory pressure warnings. - Honest comparison vs `baseline-main` (`VICTORY_LEVELS_ON_DEMAND=0`, `8.9 fps` median, `5,864 MB` VRAM): dock windows still ran slower (`2.2–2.9 fps` vs `6.1–7.2 fps`) and peak VRAM reached `6,266 MB` (`1,111 MB` in tile heaps). - **Frame-Gen FPS (if enabled):** `off` - **VRAM / RAM Usage:** `5,886.5 MB` median / `6,266 MB` peak VRAM of `6,939 MB` budget (`over=0 MB`, `room_false=0.0%`, `9,188` tiled alive max); visuals `lit=18/24`, `luma=105.47`, `edge_energy=6.96`, `magenta=0.0%` (inspected `frame-8136.png` & `frame-8668.png`) - **Crashes / DRED Resets:** `0` (`crashes=0`, `no_host_texture_errors=0`) - **Automated Checks:** - [x] `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` (`294 files ok`) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask` (`6 passed; 0 failed`) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings` (`0` warnings) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features victory-gpu/diagnostics -- -D warnings` (`0` warnings) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu` (`449 passed; 0 failed; 36 ignored`, including `on_demand_staging_tests::on_demand_first_tracks_committed_levels_and_max_dim`) - [x] `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu levels_on_demand -- --ignored` (`1 passed: tiles::tests::levels_on_demand_on_the_card`)
Androtim commented 2026-11-28 06:04:11 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T06:04:11Z.


Automated triage for the maintainers (not an approval).

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

Review Summary

PR #17 narrows VICTORY_LEVELS_ON_DEMAND texture staging buffers and PreludeUpload::record copies in crates/victory-gpu/src/texture.rs to the mip levels that are actually committed and within VICTORY_LEVELS_MAX_DIM.

What looks solid

  • Mip bound preservation (upload_listed, upload_from): Keeping the caller's first mip when crate::tiles::wanted() is active avoids forcing first = 0 for tiled on-demand textures.
  • Staging sizing & lock ordering (staging, staging_layout, judgement_at, held_levels_of, on_demand_first): Computing the lowest held/capped mip before locking STAGING preserves the existing lock order, falls back to the smallest mip when held == 0, and naturally re-stages when finer mips later become committed (s.first <= first.max(copy.base) fails and replaces the entry).
  • Tile/copy consistency (Staging::judge_levels, PreludeUpload::record): Masking held &= if self.first < 32 { !0u32 << self.first } else { 0 } prevents on_demand.uploaded(...) from backing finer mips that are not present in self.footprints, and skipping unheld subresources in PreludeUpload::record avoids redundant CopyTextureRegion calls into unbacked mips.
  • Security / Tests: The static VirtualAlloc/VirtualFree hits are confined to #[cfg(test)] mod on_demand_staging_tests using PAGE_READWRITE anonymous memory with proper Drop cleanup to verify on_demand_first across commit boundaries and max_dim.

Minor non-blocking note

  • In staging(), when on_demand is true, staging_layout + judgement_at + on_demand_first (including VirtualQuery calls in held_levels_of) now execute before the STAGING cache lookup on every upload_from call, even when a cached entry already satisfies s.first <= requested.max(copy.base). This is safe and preserves lock ordering, though a fast-path check could avoid repeated layout/query work if it shows up in hot command lists.

Verdict

needs-gpu-test — Logic, edge cases, security, and CI look clean; because this changes D3D12 texture staging and CopyTextureRegion behavior under VICTORY_LEVELS_ON_DEMAND, a local real-GPU smoke test is warranted before merging.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7235059812 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/17#issuecomment-7235059812). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T06:04:11Z. --- <!-- minivi-triage v1 head=54553eb04e64b8521b20b89859c7d54bec690d22 verdict=needs-gpu-test ci=passing at=2026-11-29T02:04:09Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary PR #17 narrows `VICTORY_LEVELS_ON_DEMAND` texture staging buffers and `PreludeUpload::record` copies in `crates/victory-gpu/src/texture.rs` to the mip levels that are actually committed and within `VICTORY_LEVELS_MAX_DIM`. #### What looks solid - **Mip bound preservation (`upload_listed`, `upload_from`)**: Keeping the caller's `first` mip when `crate::tiles::wanted()` is active avoids forcing `first = 0` for tiled on-demand textures. - **Staging sizing & lock ordering (`staging`, `staging_layout`, `judgement_at`, `held_levels_of`, `on_demand_first`)**: Computing the lowest held/capped mip before locking `STAGING` preserves the existing lock order, falls back to the smallest mip when `held == 0`, and naturally re-stages when finer mips later become committed (`s.first <= first.max(copy.base)` fails and replaces the entry). - **Tile/copy consistency (`Staging::judge_levels`, `PreludeUpload::record`)**: Masking `held &= if self.first < 32 { !0u32 << self.first } else { 0 }` prevents `on_demand.uploaded(...)` from backing finer mips that are not present in `self.footprints`, and skipping unheld subresources in `PreludeUpload::record` avoids redundant `CopyTextureRegion` calls into unbacked mips. - **Security / Tests**: The static `VirtualAlloc`/`VirtualFree` hits are confined to `#[cfg(test)] mod on_demand_staging_tests` using `PAGE_READWRITE` anonymous memory with proper `Drop` cleanup to verify `on_demand_first` across commit boundaries and `max_dim`. #### Minor non-blocking note - In `staging()`, when `on_demand` is true, `staging_layout` + `judgement_at` + `on_demand_first` (including `VirtualQuery` calls in `held_levels_of`) now execute before the `STAGING` cache lookup on every `upload_from` call, even when a cached entry already satisfies `s.first <= requested.max(copy.base)`. This is safe and preserves lock ordering, though a fast-path check could avoid repeated layout/query work if it shows up in hot command lists. #### Verdict `needs-gpu-test` — Logic, edge cases, security, and CI look clean; because this changes D3D12 texture staging and `CopyTextureRegion` behavior under `VICTORY_LEVELS_ON_DEMAND`, a local real-GPU smoke test is warranted before merging. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-11-29 01:01:39 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T01:01:39Z.


Rebased onto origin/main (6e935d7 -> 54553eb):

Changes

  • Resolved crates/victory-gpu/src/texture.rs conflicts in PreludeUpload::record and judge_levels/detile:
    • Preserved self.staging.detiled mip-masking alongside self.staging.cpu.get() in PreludeUpload::record.
    • Applied held &= if self.first < 32 { !0u32 << self.first } else { 0 } directly inside Staging::judge_levels so both CPU and GPU detiling paths honor on_demand level bounds.

Verification (54553eb)

  • Policy & Lints: cargo run -p xtask -- policy (301 files ok), cargo test -p xtask (6 passed), clippy --workspace --all-targets -- -D warnings (0 warnings, both plain and --features diagnostics).
  • Unit Tests: victory-gpu --lib texture:: (11 passed; 0 failed; 4 ignored, including on_demand_first_tracks_committed_levels_and_max_dim).
  • Release Builds & DLL Check: plain --release (2m 14s, objdump -p confirmed Windows system DLLs only, zero non-system MinGW runtime DLLs) and --release --features diagnostics (3m 48s).
  • Live 75s Open-World GPU Run (pr17-rebased) — 11/11 gates PASS:
    • 11.3 fps median (88.2 ms/frame, baseline 8.9 fps), 12323 max draws across 15 world windows
    • 5570 MB max VRAM / 6565 MB min budget (0 MB over, baseline 5864 MB)
    • 42660 textures uploaded, 2814 final waiting (baseline 7121), 0–1 ms making host copies / 7–14 ms making slots' views in the final 5s windows
    • mapped() rate 31.3 ms/s (32200 calls, 3117.8 ms total, longest 60.2 ms), 0 crashes
    • 19/24 lit PNGs (104.27 median luma vs 103.2 baseline, 1.43% near-black, 7.0 edge energy, 0.0% magenta); visually verified clean exterior geometry, lighting, textures, foliage, water, and UI.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7248509784 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/17#issuecomment-7248509784). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T01:01:39Z. --- Rebased onto `origin/main` (`6e935d7` -> `54553eb`): ### Changes - Resolved `crates/victory-gpu/src/texture.rs` conflicts in `PreludeUpload::record` and `judge_levels`/`detile`: - Preserved `self.staging.detiled` mip-masking alongside `self.staging.cpu.get()` in `PreludeUpload::record`. - Applied `held &= if self.first < 32 { !0u32 << self.first } else { 0 }` directly inside `Staging::judge_levels` so both CPU and GPU detiling paths honor `on_demand` level bounds. ### Verification (`54553eb`) - **Policy & Lints:** `cargo run -p xtask -- policy` (`301 files ok`), `cargo test -p xtask` (`6 passed`), `clippy --workspace --all-targets -- -D warnings` (`0` warnings, both plain and `--features diagnostics`). - **Unit Tests:** `victory-gpu --lib texture::` (`11 passed; 0 failed; 4 ignored`, including `on_demand_first_tracks_committed_levels_and_max_dim`). - **Release Builds & DLL Check:** plain `--release` (`2m 14s`, `objdump -p` confirmed Windows system DLLs only, zero non-system MinGW runtime DLLs) and `--release --features diagnostics` (`3m 48s`). - **Live 75s Open-World GPU Run (`pr17-rebased`) — 11/11 gates PASS:** - `11.3 fps` median (`88.2 ms/frame`, baseline `8.9 fps`), `12323` max draws across `15` world windows - `5570 MB` max VRAM / `6565 MB` min budget (`0 MB` over, baseline `5864 MB`) - `42660` textures uploaded, `2814` final waiting (baseline `7121`), `0–1 ms` making host copies / `7–14 ms` making slots' views in the final 5s windows - `mapped()` rate `31.3 ms/s` (`32200` calls, `3117.8 ms` total, longest `60.2 ms`), `0` crashes - `19/24` lit PNGs (`104.27` median luma vs `103.2` baseline, `1.43%` near-black, `7.0` edge energy, `0.0%` magenta); visually verified clean exterior geometry, lighting, textures, foliage, water, and UI.
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!17
No description provided.