vkback: replace below-base placed images in hold_lower regardless of fill state #193

Open
github-bot wants to merge 1 commit from github-bot/gh-193 into main AGit
Owner

@⁠Mhyster on GitHub · 2026-12-02 07:03 UTC · original
Mhyster:fix/tex-hold-lower-non-gpu-filled → main · +91 −43 · 1 files · 1 commits · open

What

Fixes streamed placed textures getting stranded permanently black (null descriptor, infinite NoRange::BelowBase retries) when hold_lower lowers held_from on an image created at Img::base > 0 whose prior fill was not GPU_FILLED:

  • Previously, hold_lower (greenfield/vkback/src/placed.rs) lowered or removed self.held_from, then returned early if self.tex_keys.get(&id) did not match Some(&(k, GPU_FILLED)) (which is true for GPU_UNFILLED textures whose first fill was deferred while title memory was unmapped, CPU-detiled textures, or textures absent from tex_keys).
  • Because self.held_from was already lowered/removed while the Img::base > 0 image remained in self.images, every subsequent view starting at first < img.base failed view_range with Err(NoRange::BelowBase) and wrote a null slot, while subsequent hold_lower retries saw held_from == None and became no-ops.
  • Now hold_lower checks whether want < img.base regardless of fill state (hold_action) and always retires/removes the Img::base > want image (plus removes it from self.unnamed), so the caller (write_view) immediately creates a replacement image starting at want. In-place refill (want >= img.base) continues to run only for GPU_FILLED textures, and the common fast path (first >= img.base and first >= held) avoids calling the texture provider.

Reproduces console texture mip streaming: when a title starts sampling higher-resolution mip levels, the host image is always replaced with one that includes those levels.

The reference

  • crates/victory-gpu/src/resource.rs (REPLACED, base_level) and crates/victory-gpu/src/texture.rs (read_from): the D3D12 path replaces a host texture copy whenever a view starts below the copy's base_level, regardless of whether its prior upload had completed.

Evidence

  • Unit test in greenfield/vkback/src/placed.rs (hold_action_replaces_below_base_images_even_when_not_gpu_filled): verifies hold_action returns HoldAction::Replace whenever want < img_base even when gpu_filled == false or lower_held == false, and returns HoldAction::Refill only when want >= img_base && lower_held && gpu_filled.
  • Local CI checks passed (Linux x86_64):
    • cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked
    • (cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked) (169 passed, 3 ignored; 6/6 policy tests)
    • cargo clippy --all-targets --locked -- -D warnings on root native crates, greenfield, greenfield/wine, and greenfield/vkback/translate.
  • Not run: live game / AMD GPU screenshot check, Vulkan validation run (house scene), and A/B frame timing (frames.py) could not be run in this session (no live game run performed); cargo xwin clippy runs in GitHub Actions CI.

Checklist (docs/AGENTS.md)

  • One topic (rule 31); docs/TASKS.md not edited, the fixed item named above (rule 29)
  • "Allow edits by maintainers" on; after review, no force-push and no close-and-reopen (it drops the maintainers' commits)
  • No fallback or second path for a case that can't happen, in title data or in our own setup (rule 33); unexpected input fails loudly (rule 9)
  • Constants come from the console, the hardware or the title's data, not tuned by eye or ear (rule 9b)
  • Every switch is listed, read in one place, and a bad value stops the start (rule 2)
  • Queues and other externally synchronized Vulkan objects are used under their lock (rule 35)
  • Every unsafe block has a // SAFETY: comment; no raw pointer around the borrow checker (rule 36)
  • Clippy clean; tests call the production code; TRANSLATOR_VERSION bumped if the translator's output changes (rule 27)
  • Comments say what is true now and name functions, not line numbers (rule 3)
  • Nothing from the title, and no pointers to where non-free data can be found (hard constraints)
**@⁠Mhyster** on GitHub · 2026-12-02 07:03 UTC · [original](https://github.com/vktory6/VKtory/pull/193) `Mhyster:fix/tex-hold-lower-non-gpu-filled` → `main` · +91 −43 · 1 files · 1 commits · open ## What Fixes streamed placed textures getting stranded permanently black (null descriptor, infinite `NoRange::BelowBase` retries) when `hold_lower` lowers `held_from` on an image created at `Img::base > 0` whose prior fill was not `GPU_FILLED`: - Previously, `hold_lower` (`greenfield/vkback/src/placed.rs`) lowered or removed `self.held_from`, then returned early if `self.tex_keys.get(&id)` did not match `Some(&(k, GPU_FILLED))` (which is true for `GPU_UNFILLED` textures whose first fill was deferred while title memory was unmapped, CPU-detiled textures, or textures absent from `tex_keys`). - Because `self.held_from` was already lowered/removed while the `Img::base > 0` image remained in `self.images`, every subsequent view starting at `first < img.base` failed `view_range` with `Err(NoRange::BelowBase)` and wrote a null slot, while subsequent `hold_lower` retries saw `held_from == None` and became no-ops. - Now `hold_lower` checks whether `want < img.base` regardless of fill state (`hold_action`) and always retires/removes the `Img::base > want` image (plus removes it from `self.unnamed`), so the caller (`write_view`) immediately creates a replacement image starting at `want`. In-place refill (`want >= img.base`) continues to run only for `GPU_FILLED` textures, and the common fast path (`first >= img.base` and `first >= held`) avoids calling the texture provider. Reproduces console texture mip streaming: when a title starts sampling higher-resolution mip levels, the host image is always replaced with one that includes those levels. ## The reference - `crates/victory-gpu/src/resource.rs` (`REPLACED`, `base_level`) and `crates/victory-gpu/src/texture.rs` (`read_from`): the D3D12 path replaces a host texture copy whenever a view starts below the copy's `base_level`, regardless of whether its prior upload had completed. ## Evidence - Unit test in `greenfield/vkback/src/placed.rs` (`hold_action_replaces_below_base_images_even_when_not_gpu_filled`): verifies `hold_action` returns `HoldAction::Replace` whenever `want < img_base` even when `gpu_filled == false` or `lower_held == false`, and returns `HoldAction::Refill` only when `want >= img_base && lower_held && gpu_filled`. - Local CI checks passed (Linux x86_64): - `cargo test -p victory-shader -p victory-formats -p victory-core -p xtask --locked` - `(cd greenfield && cargo test -p umem -p frame -p vkback --lib --locked && cargo test -p vkback --test policy --locked)` (169 passed, 3 ignored; 6/6 policy tests) - `cargo clippy --all-targets --locked -- -D warnings` on root native crates, `greenfield`, `greenfield/wine`, and `greenfield/vkback/translate`. - **Not run**: live game / AMD GPU screenshot check, Vulkan validation run (house scene), and A/B frame timing (`frames.py`) could not be run in this session (no live game run performed); `cargo xwin clippy` runs in GitHub Actions CI. ## Checklist (docs/AGENTS.md) - [x] One topic (rule 31); `docs/TASKS.md` not edited, the fixed item named above (rule 29) - [x] "Allow edits by maintainers" on; after review, no force-push and no close-and-reopen (it drops the maintainers' commits) - [x] No fallback or second path for a case that can't happen, in title data or in our own setup (rule 33); unexpected input fails loudly (rule 9) - [x] Constants come from the console, the hardware or the title's data, not tuned by eye or ear (rule 9b) - [x] Every switch is listed, read in one place, and a bad value stops the start (rule 2) - [x] Queues and other externally synchronized Vulkan objects are used under their lock (rule 35) - [x] Every `unsafe` block has a `// SAFETY:` comment; no raw pointer around the borrow checker (rule 36) - [x] Clippy clean; tests call the production code; `TRANSLATOR_VERSION` bumped if the translator's output changes (rule 27) - [x] Comments say what is true now and name functions, not line numbers (rule 3) - [x] Nothing from the title, and no pointers to where non-free data can be found (hard constraints)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 07:08:42 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/193/head:github-bot/gh-193'
git switch 'github-bot/gh-193'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-193'
git switch 'github-bot/gh-193'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-193'
git switch 'github-bot/gh-193'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-193'
git switch 'main'
git merge --squash 'github-bot/gh-193'
git switch 'main'
git merge --ff-only 'github-bot/gh-193'
git switch 'main'
git merge 'github-bot/gh-193'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.