gpu(texback,host): fix readback coherency, cache footprints, and persist readback mappings #160

Closed
github-bot wants to merge 1 commit from gh-pr/160/head into gh-pr/160/base
Owner

@⁠Androtim on GitHub · 2026-11-29 20:03 UTC · original
Androtim:feat/iter158-texback-coherency-and-persistent-readback → main · +413 −120 · 4 files · 1 commits · closed without merging

## Summary

  • Fix 2 GPU-to-CPU texture readback coherency hazards:
    • card_steps::writers now emits Writer { shadow: None } for every range in flight.texture_back_ranges, preventing stale Shadow bytes from being served while a texture readback flight is still in flight.
    • host::joinable now includes deferred.texture_backs ranges in written, preventing later joined parts from preparing CPU reads ahead of a pending texture readback.
  • Persistently map pooled ReadbackPool buffers (MappedReadback):
    • Keep D3D12_HEAP_TYPE_READBACK buffers mapped once across reuse in Host::texture_readbacks, share the pool with list.rs::read_back (defer_read_back), add ReadbackPool::trim_all for host memory pressure, and retire any remaining readback leases through host::retire in Deferred::drop if a list is dropped unreset.
    • Remove per-frame Map/Unmap calls in texback::land and host::read_backs.
  • Cache footprints & thread-local scratch in texback:
    • Cache Arc<Footprints> by texture shape (Width, Height, DepthOrArraySize, MipLevels, Format) to eliminate per-readback GetCopyableFootprints COM calls and vector allocations.
    • Use 4 MiB-capped thread-local scratch buffers (TILED / TITLE) while preserving VICTORY_TEXBACK_SAME=1 diff-only landing and ReadbackStats telemetry.

Test plan

  • cargo run -p xtask -- policy: passed
  • cargo test -p victory-gpu texback::: passed
  • cargo test -p victory-gpu card_steps::: passed
  • cargo test -p victory-gpu readback_pool_tests: passed
  • cargo test -p victory-gpu host::: passed
  • Dual cargo clippy --workspace --all-targets (default and --features diagnostics) with -D warnings: passed
**@⁠Androtim** on GitHub · 2026-11-29 20:03 UTC · [original](https://github.com/Androtim/MiniVI/pull/160) `Androtim:feat/iter158-texback-coherency-and-persistent-readback` → `main` · +413 −120 · 4 files · 1 commits · closed without merging ## Summary - **Fix 2 GPU-to-CPU texture readback coherency hazards**: - `card_steps::writers` now emits `Writer { shadow: None }` for every range in `flight.texture_back_ranges`, preventing stale `Shadow` bytes from being served while a texture readback flight is still in flight. - `host::joinable` now includes `deferred.texture_backs` ranges in `written`, preventing later joined parts from preparing CPU reads ahead of a pending texture readback. - **Persistently map pooled `ReadbackPool` buffers (`MappedReadback`)**: - Keep `D3D12_HEAP_TYPE_READBACK` buffers mapped once across reuse in `Host::texture_readbacks`, share the pool with `list.rs::read_back` (defer_read_back), add `ReadbackPool::trim_all` for host memory pressure, and retire any remaining readback leases through `host::retire` in `Deferred::drop` if a list is dropped unreset. - Remove per-frame `Map`/`Unmap` calls in `texback::land` and `host::read_backs`. - **Cache footprints & thread-local scratch in `texback`**: - Cache `Arc<Footprints>` by texture shape (Width, Height, DepthOrArraySize, MipLevels, Format) to eliminate per-readback `GetCopyableFootprints` COM calls and vector allocations. - Use 4 MiB-capped thread-local scratch buffers (`TILED` / `TITLE`) while preserving `VICTORY_TEXBACK_SAME=1` diff-only landing and `ReadbackStats` telemetry. ## Test plan - `cargo run -p xtask -- policy`: passed - `cargo test -p victory-gpu texback::`: passed - `cargo test -p victory-gpu card_steps::`: passed - `cargo test -p victory-gpu readback_pool_tests`: passed - `cargo test -p victory-gpu host::`: passed - Dual `cargo clippy --workspace --all-targets` (default and `--features diagnostics`) with `-D warnings`: passed
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:14:15 +00:00
github-bot closed this pull request 2026-12-01 20:14:15 +00:00
Author
Owner

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

### Live GPU Verification (RTX 4060 Ti 8 GB, Series S, 60s In-World via verify-world.ps1)

  • Overall: PASS (all 6 gates passed, ok: true)
  • 3D World: world_windows=13, max_draws=10603, median 9.4 fps (106.0 ms)
  • Stability: crashes=0, no_host_texture_errors=0
  • VRAM: used_max=5612 MB / budget_min=6689 MB (over=0 MB, room_false=9.1%)
  • Texture Streaming: uploaded=44192, final_waiting=4852, max_waiting=29451
  • Residency Stalls: mapped_rate=6.65 ms/world_sec (15000 calls, longest=13.6 ms)
  • Texback Pool & Landings: copied=10880, created=1223, reused=12251 (~90.9% reuse), allocation_failures=0, peak_idle_bytes=17825792
  • Visual Gate: pngs=24, lit=17/24, median_luma=105.6, near_black=0.0%, edge_energy=7.02, magenta=0.0% (visually inspected frame-3599.png and frame-3657.png — clean daylight outdoor scene lighting and textures)
**@⁠Androtim** on GitHub · 2026-11-29 20:14 UTC · [original](https://github.com/Androtim/MiniVI/pull/160#issuecomment-7261919248) ### Live GPU Verification (RTX 4060 Ti 8 GB, Series S, 60s In-World via `verify-world.ps1`) - **Overall:** **PASS** (all 6 gates passed, `ok: true`) - **3D World:** `world_windows=13`, `max_draws=10603`, median `9.4 fps` (`106.0 ms`) - **Stability:** `crashes=0`, `no_host_texture_errors=0` - **VRAM:** `used_max=5612 MB` / `budget_min=6689 MB` (`over=0 MB`, `room_false=9.1%`) - **Texture Streaming:** `uploaded=44192`, `final_waiting=4852`, `max_waiting=29451` - **Residency Stalls:** `mapped_rate=6.65 ms/world_sec` (`15000` calls, `longest=13.6 ms`) - **Texback Pool & Landings:** `copied=10880`, `created=1223`, `reused=12251` (~90.9% reuse), `allocation_failures=0`, `peak_idle_bytes=17825792` - **Visual Gate:** `pngs=24`, `lit=17/24`, `median_luma=105.6`, `near_black=0.0%`, `edge_energy=7.02`, `magenta=0.0%` (visually inspected `frame-3599.png` and `frame-3657.png` — clean daylight outdoor scene lighting and textures)
Author
Owner

@⁠Androtim on GitHub · 2026-11-29 21:03 UTC · original · edited 2026-11-30 11:04 UTC

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** on GitHub · 2026-11-29 21:03 UTC · [original](https://github.com/Androtim/MiniVI/pull/160#issuecomment-7262564943) · edited 2026-11-30 11:04 UTC <!-- minivi-triage v1 head=51a29c9eb38af2eaf7d650246d4abc4a76fb194b verdict=needs-rebase ci=passing at=2026-11-30T11:05:26Z --> 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`)._
Author
Owner

@⁠Androtim on GitHub · 2026-12-01 01:38 UTC · original

Closing stale/conflicted backlog PR per #276. Superseded by the active root-architecture replacement pillars with isolated plain --release A/B verification.

**@⁠Androtim** on GitHub · 2026-12-01 01:38 UTC · [original](https://github.com/Androtim/MiniVI/pull/160#issuecomment-7297731191) Closing stale/conflicted backlog PR per #276. Superseded by the active root-architecture replacement pillars with isolated plain --release A/B verification.

Pull request closed

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!160
No description provided.