GPU/descriptor: refresh tiled texture slots for tabled views and stale first_shown #764

Open
AscilCH wants to merge 1 commit from upstream-pr/764 into main
AscilCH commented 2026-11-25 06:44:55 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T06:44:55Z.


Problem

Under levels-on-demand (VICTORY_LEVELS_ON_DEMAND=1), make() shifts a tiled texture's host SRV to start at first_shown(), and OnDemand::uploaded()/card_wrote() records the texture's start address in RESHOWN for HostHeap::texture_views_remade(). Two gaps left tabled (and non-placed) tiled texture slots permanently stuck at unmapped MostDetailedMip = 0 (black) or stale mips:

  1. HostHeap::note_buffer() excludes tabled_lately slots from self.placed (Spans), so HostHeap::texture_views_remade() never found tabled slots when draining RESHOWN.
  2. HostHeap::mirror() only rebuilt a slot when made[index] != key. Once a draw mirrored a tabled tiled slot before its first upload (first_shown() == None -> MostDetailedMip = 0) or before finer mips arrived, every subsequent draw hit made[index] == key and skipped make().

Fix

  • Track slots backed by a tiled texture in HostHeap::tiled_shown (TiledSlots), storing the OnDemand handle, optional placed start address (including tabled slots excluded from self.placed), and the first_shown level baked into the slot, gated by a fast has_tiled: AtomicBool so non-tiled heaps incur no mutex overhead.
  • Include tiled_shown.slots_at(start) in HostHeap::texture_views_remade().
  • In HostHeap::mirror(), when made[index] == key and tiled_stale(index) is true (first_shown() changed since the slot was built), rebuild the host descriptor and update tiled_shown.

Verification

  • cargo test -p victory-gpu --locked -- descriptor::host::tests: 20 passed; 0 failed (including pure unit test tiled_slots_tracks_tabled_starts_and_detects_first_shown_changes).
  • VICTORY_LEVELS_ON_DEMAND=1 cargo test -p victory-gpu --locked -- descriptor::host::tests::tabled_tiled_slot_remakes_when_first_shown_changes: 1 passed; 0 failed (exercising a real tiled placed texture on D3D12 hardware through both texture_views_remade() and mirror()).
  • cargo clippy -p victory-gpu --all-targets --all-features --locked: 0 warnings in descriptor/host.rs (only pre-existing 8dd30ab warnings in draw.rs:2377 and indirect.rs:1322).
  • cargo xtask policy: 171 files ok.

(AI-assisted; synthetic unit tests only, no game data.)

<!-- greyfinch-sync:fxceless/victory-fork:issue:6598881030 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/764). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-25T06:44:55Z. --- ### Problem Under levels-on-demand (`VICTORY_LEVELS_ON_DEMAND=1`), `make()` shifts a tiled texture's host SRV to start at `first_shown()`, and `OnDemand::uploaded()`/`card_wrote()` records the texture's start address in `RESHOWN` for `HostHeap::texture_views_remade()`. Two gaps left tabled (and non-placed) tiled texture slots permanently stuck at unmapped `MostDetailedMip = 0` (black) or stale mips: 1. `HostHeap::note_buffer()` excludes `tabled_lately` slots from `self.placed` (`Spans`), so `HostHeap::texture_views_remade()` never found tabled slots when draining `RESHOWN`. 2. `HostHeap::mirror()` only rebuilt a slot when `made[index] != key`. Once a draw mirrored a tabled tiled slot before its first upload (`first_shown() == None` -> `MostDetailedMip = 0`) or before finer mips arrived, every subsequent draw hit `made[index] == key` and skipped `make()`. ### Fix - Track slots backed by a tiled texture in `HostHeap::tiled_shown` (`TiledSlots`), storing the `OnDemand` handle, optional placed start address (including tabled slots excluded from `self.placed`), and the `first_shown` level baked into the slot, gated by a fast `has_tiled: AtomicBool` so non-tiled heaps incur no mutex overhead. - Include `tiled_shown.slots_at(start)` in `HostHeap::texture_views_remade()`. - In `HostHeap::mirror()`, when `made[index] == key` and `tiled_stale(index)` is true (`first_shown()` changed since the slot was built), rebuild the host descriptor and update `tiled_shown`. ### Verification - `cargo test -p victory-gpu --locked -- descriptor::host::tests`: `20 passed; 0 failed` (including pure unit test `tiled_slots_tracks_tabled_starts_and_detects_first_shown_changes`). - `VICTORY_LEVELS_ON_DEMAND=1 cargo test -p victory-gpu --locked -- descriptor::host::tests::tabled_tiled_slot_remakes_when_first_shown_changes`: `1 passed; 0 failed` (exercising a real tiled placed texture on D3D12 hardware through both `texture_views_remade()` and `mirror()`). - `cargo clippy -p victory-gpu --all-targets --all-features --locked`: 0 warnings in `descriptor/host.rs` (only pre-existing `8dd30ab` warnings in `draw.rs:2377` and `indirect.rs:1322`). - `cargo xtask policy`: `171 files ok`. *(AI-assisted; synthetic unit tests only, no game data.)*
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/764:upstream-pr/764'
git switch 'upstream-pr/764'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/764'
git switch 'upstream-pr/764'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/764'
git switch 'upstream-pr/764'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/764'
git switch 'main'
git merge --squash 'upstream-pr/764'
git switch 'main'
git merge --ff-only 'upstream-pr/764'
git switch 'main'
git merge 'upstream-pr/764'
git push origin '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
fxceless/victory-fork!764
No description provided.