vkback: keep the old view of a held new image (VKB_HOLD_NEW_KEEP, off) #266

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

@⁠lordra9-svg on GitHub · 2026-12-02 18:56 UTC · original
lordra9-svg:fix/hold-new-keep → main · +240 −28 · 7 files · 1 commits · open

What

docs/TASKS.md:626 "Newly made images show empty for a frame": behind VKB_HOLD_NEW_KEEP (default off), keep a held slot's old same-kind image descriptor and pin its image/view until the retry, instead of nulling the slot. This is victory-gpu's show_new_later keep (kin) idea; the counter merged as #236 showed 5,958 reads of held-null slots in a clean run, i.e. draws sample 0 where the console shows the old image.

Change

  • New holdkeep.rs: hold_keep_begin(addr, index) pins the old image (shown count) before slot_reset releases the slot, when the slot held a plain image view (no twin/exact hook); hold_keep_release drops the pin.
  • slotwrite: hold_new(..., keep) leaves the old descriptor bytes in place when kept; the pin is released at the end of a write that did not end in a hold, or on retry_dropped after write_null_slot (so a retry dropped by peek_small never leaves old bytes naming an unpinned image).
  • arena::take_retry_slots no longer releases the pin itself (it cannot know a retry will be written). Off: byte-identical old path.
  • The heldread stats line says "old view kept (VKB_HOLD_NEW_KEEP)" only when the switch is on.

Verified

  • cargo test -p vkback --lib: 176 passed (pin survives slot_reset, released once, dropped-retry nulls then releases); policy 6; clippy -D warnings; build exit 0.
  • A/B (b7fixed, foreground sequential, same binary):
    • off: 24.7 fps, reads of a slot held null ... 4115, 0 keep notes, 0 faults.
    • on: 27.1 fps, reads of a slot held ... old view kept ... 5240, 34 old view kept holds, 0 faults.
  • Validation (VK_LAYER_KHRONOS_validation, 200 s, switch on): only the four known VUIDs (06409 x4, 01687/01688/03428 x20), no device loss. Keep path exercised (25 holds, 155 held reads under the layer).

Caveats

  • Default off: the A/B does not prove the picture (the b7fixed save is an animated cutscene, so F9 frames are not comparable); this stays an experiment until the picture gates and a longer device-loss run pass.
  • "Same kind" is approximated as "old descriptor was a plain image view" because vkback does not store the old SRV/UAV kind; old twin/exact views still null. This is broader than victory-gpu's Same/Moved/Sized default.
  • Held slots still stay in arena.later and are retried as before; only what the slot shows in between changes.
**@⁠lordra9-svg** on GitHub · 2026-12-02 18:56 UTC · [original](https://github.com/vktory6/VKtory/pull/266) `lordra9-svg:fix/hold-new-keep` → `main` · +240 −28 · 7 files · 1 commits · open ## What `docs/TASKS.md:626` "Newly made images show empty for a frame": behind `VKB_HOLD_NEW_KEEP` (**default off**), keep a held slot's **old same-kind image descriptor and pin its image/view** until the retry, instead of nulling the slot. This is victory-gpu's `show_new_later` keep (`kin`) idea; the counter merged as #236 showed **5,958 reads of held-null slots** in a clean run, i.e. draws sample 0 where the console shows the old image. ## Change - New `holdkeep.rs`: `hold_keep_begin(addr, index)` pins the old image (`shown` count) **before** `slot_reset` releases the slot, when the slot held a plain image view (no twin/exact hook); `hold_keep_release` drops the pin. - `slotwrite`: `hold_new(..., keep)` leaves the old descriptor bytes in place when kept; the pin is released at the end of a write that did not end in a hold, or on `retry_dropped` **after `write_null_slot`** (so a retry dropped by `peek_small` never leaves old bytes naming an unpinned image). - `arena::take_retry_slots` no longer releases the pin itself (it cannot know a retry will be written). Off: byte-identical old path. - The `heldread` stats line says "old view kept (VKB_HOLD_NEW_KEEP)" only when the switch is on. ## Verified - `cargo test -p vkback --lib`: **176 passed** (pin survives `slot_reset`, released once, dropped-retry nulls then releases); policy 6; clippy `-D warnings`; build exit 0. - **A/B** (b7fixed, foreground sequential, same binary): - off: 24.7 fps, `reads of a slot held null ... 4115`, 0 keep notes, 0 faults. - on: 27.1 fps, `reads of a slot held ... old view kept ... 5240`, 34 `old view kept` holds, 0 faults. - **Validation** (`VK_LAYER_KHRONOS_validation`, 200 s, switch on): only the four known VUIDs (06409 x4, 01687/01688/03428 x20), no device loss. Keep path exercised (25 holds, 155 held reads under the layer). ## Caveats - Default **off**: the A/B does not prove the picture (the `b7fixed` save is an animated cutscene, so F9 frames are not comparable); this stays an experiment until the picture gates and a longer device-loss run pass. - "Same kind" is approximated as "old descriptor was a plain image view" because vkback does not store the old SRV/UAV kind; old twin/exact views still null. This is broader than victory-gpu's `Same`/`Moved`/`Sized` default. - Held slots still stay in `arena.later` and are retried as before; only what the slot shows in between changes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 19:38:49 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-02 19:35 UTC · original

Thanks. This is a clean piece of work: the pin is taken before slot_reset, it is released after write_null_slot on a dropped retry, and with the switch off the old path stays byte for byte. I read it against victory-gpu's show_new_later keep. Before we merge, three points:

  1. Default off is right. Neither path shows what the console shows: the console samples the new image straight away. Null is the gap we already count and track in TASKS ("Newly made images show empty for a frame"). Keeping the old view is a different deviation, because it shows stale content. So the accurate default does not exist yet. An experiment switch that defaults to the tracked gap, with your removal condition, fits rule 2.
  2. "Same kind" has to be checked, not approximated. victory-gpu keeps the old view only when its kind matches the new write (kin: Same/Moved/Sized). Here any plain image view counts. A sampled-image descriptor can then stay in a slot whose new write is a storage image, and the other way round. With descriptor buffers, those two descriptor types differ in size and layout, so a shader that reads the slot as the new kind reads bytes it does not expect. That can mean a wrong picture, or a device loss on stricter drivers. Please record the old descriptor's kind (SRV/UAV and dimension) next to FLAG_IMAGE, compare it with the held write, and keep only on a match. A unit test for the mismatch case would cover it.
  3. Old images whose memory the title rewrites. An image bound in place over title memory, or a placed image, can have its pages rewritten by the title with the very texture that is now held. The kept view then shows half-written data: the garbled textures from textures-garbled.md, only through another door. Please exclude in-place and placed images from the keep, or show why their pages cannot change while the slot is held.

On evidence: the A/B in the animated cutscene does not compare (as you say), so the fps difference does not count. Once 2 and 3 are in, one run at a fixed scene point with the switch on and off, plus the validation run you already did, is enough for an opt-in experiment.

On how this relates to the holdfrees branch (title frees in stream order, https://github.com/vktory6/VKtory/discussions/248): they touch different code. Holdfrees orders the title's frees behind GPU work; it does not change hold_new. The pin here keeps our image alive, though, not the title memory under it, which is one more reason for point 3. Holdfrees' failing boat gate turned out to be a run that never left the intro cutscene, not a picture difference, so it says nothing about this PR.

**@⁠vktory6** on GitHub · 2026-12-02 19:35 UTC · [original](https://github.com/vktory6/VKtory/pull/266#issuecomment-7356420929) Thanks. This is a clean piece of work: the pin is taken before `slot_reset`, it is released after `write_null_slot` on a dropped retry, and with the switch off the old path stays byte for byte. I read it against victory-gpu's `show_new_later` keep. Before we merge, three points: 1. **Default off is right.** Neither path shows what the console shows: the console samples the new image straight away. Null is the gap we already count and track in TASKS ("Newly made images show empty for a frame"). Keeping the old view is a different deviation, because it shows stale content. So the accurate default does not exist yet. An experiment switch that defaults to the tracked gap, with your removal condition, fits rule 2. 2. **"Same kind" has to be checked, not approximated.** victory-gpu keeps the old view only when its kind matches the new write (`kin`: Same/Moved/Sized). Here any plain image view counts. A sampled-image descriptor can then stay in a slot whose new write is a storage image, and the other way round. With descriptor buffers, those two descriptor types differ in size and layout, so a shader that reads the slot as the new kind reads bytes it does not expect. That can mean a wrong picture, or a device loss on stricter drivers. Please record the old descriptor's kind (SRV/UAV and dimension) next to `FLAG_IMAGE`, compare it with the held write, and keep only on a match. A unit test for the mismatch case would cover it. 3. **Old images whose memory the title rewrites.** An image bound in place over title memory, or a placed image, can have its pages rewritten by the title with the very texture that is now held. The kept view then shows half-written data: the garbled textures from textures-garbled.md, only through another door. Please exclude in-place and placed images from the keep, or show why their pages cannot change while the slot is held. On evidence: the A/B in the animated cutscene does not compare (as you say), so the fps difference does not count. Once 2 and 3 are in, one run at a fixed scene point with the switch on and off, plus the validation run you already did, is enough for an opt-in experiment. On how this relates to the holdfrees branch (title frees in stream order, https://github.com/vktory6/VKtory/discussions/248): they touch different code. Holdfrees orders the title's frees behind GPU work; it does not change `hold_new`. The pin here keeps our image alive, though, not the title memory under it, which is one more reason for point 3. Holdfrees' failing boat gate turned out to be a run that never left the intro cutscene, not a picture difference, so it says nothing about this PR.
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/266/head:github-bot/gh-266'
git switch 'github-bot/gh-266'

Merge

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