vkback: count whether partly-filled / contents-less textures are sampled #173

Open
github-bot wants to merge 3 commits from github-bot/gh-173 into main AGit
Owner

@⁠lordra9-svg on GitHub · 2026-12-02 00:02 UTC · original
lordra9-svg:fix/tex-parity-counter → main · +335 −30 · 11 files · 3 commits · open

What

Instrumentation (rule 5, counted) answering the repo's open parity question: are partly-filled textures (zeros where title memory is unmapped, VKB_FILL_PARTIAL) and contents-less textures (Source::None) actually sampled by the frame's draws? fill.rs/vram-3.md say this is open until such a counter exists.

How

  • New greenfield/vkback/src/texparity.rs: an image is marked Partial or NoContents(reason) at its fill/refresh/no-content point, and cleared when it gets full contents (fill from provider, refresh recovered, texwatch complete).
  • A slot that shows a marked image sets slotcache::FLAG_PARITY at its descriptor write; each read of that slot (slot_read_at / _index) counts one sampled use, split into Execute index-slots vs list calls, with first ids/shapes per reason.
  • The stats line prints textures without full contents sampled by draws: N read(s) … by reason: … when non-zero (live/present.rs), and vram-3.md records the counter.
  • No behaviour change — image contents are untouched; only counting.

Note for review

SlotFlags (per-slot flags) moves from packed 4-bit nibbles (1 MiB) to one byte/slot (2 MiB) so a 5th flag fits. This is temporary with the counter (removal once the parity question is answered: zeros match the console, or give way to what the console reads).

Verified

  • cargo test -p vkback --lib: 170 passed; policy 6 passed; clippy -D warnings clean; tools/build.sh exit 0.
**@⁠lordra9-svg** on GitHub · 2026-12-02 00:02 UTC · [original](https://github.com/vktory6/VKtory/pull/173) `lordra9-svg:fix/tex-parity-counter` → `main` · +335 −30 · 11 files · 3 commits · open ## What Instrumentation (rule 5, counted) answering the repo's open parity question: are **partly-filled** textures (zeros where title memory is unmapped, `VKB_FILL_PARTIAL`) and **contents-less** textures (`Source::None`) actually sampled by the frame's draws? `fill.rs`/`vram-3.md` say this is open until such a counter exists. ## How - New `greenfield/vkback/src/texparity.rs`: an image is marked `Partial` or `NoContents(reason)` at its fill/refresh/no-content point, and cleared when it gets full contents (fill from provider, refresh recovered, texwatch complete). - A slot that shows a marked image sets `slotcache::FLAG_PARITY` at its descriptor write; each read of that slot (`slot_read_at` / `_index`) counts one sampled use, split into Execute index-slots vs list calls, with first ids/shapes per reason. - The stats line prints `textures without full contents sampled by draws: N read(s) … by reason: …` when non-zero (`live/present.rs`), and `vram-3.md` records the counter. - **No behaviour change** — image contents are untouched; only counting. ## Note for review `SlotFlags` (per-slot flags) moves from packed 4-bit nibbles (1 MiB) to one byte/slot (2 MiB) so a 5th flag fits. This is temporary with the counter (removal once the parity question is answered: zeros match the console, or give way to what the console reads). ## Verified - `cargo test -p vkback --lib`: 170 passed; policy 6 passed; `clippy -D warnings` clean; `tools/build.sh` exit 0.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 00:04:47 +00:00
A render target or depth texture sampled after it was rendered is the normal
case, not a missing texture. The texparity mark is now cleared at the earliest
reliable GPU-write point: a draw touching the image as a target (the touched
set), a clear, and a copy destination (gpu_wrote). What the XOR
render-target/depth reason counts is then a sample before that first write, the
hazard named in docs/TASKS.md. UAV writes by compute dispatches are not tracked
(no per-image record), so those stay marked; noted in texparity's header and
vram-3.md.

Counting only, no image contents changed.
make_image zero-fills every live image no fill covers (a Source::None image
with no address, an XOR render target or depth, a refused first fill) right
after upload. Those images hold zeros, not garbage, so sampling them is not a
read before contents. Clear the parity mark at that one-time clear (color,
depth and clear_compressed alike), exactly as a landed fill does.

The counter now answers the real question: which marked images are sampled
before they have any contents at all — never filled, never zero-filled, never
GPU-written. Counting only; no image contents changed.
github-bot force-pushed github-bot/gh-173 from ff5c9dcbae to f281b89a6c 2026-12-02 19:51:18 +00:00 Compare
Author
Owner

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

Thanks. Counting the reads of slots that show a partly filled or contents-less image is the right way to settle the open question in fill.rs and vram-3.md, and it costs one flag test on a read that already loads the slot's flags.

Before a merge:

  1. The answer, not only the counter. The PR exists to answer a question, but it shows no game run. Please add one boat run (cutscenes kept, about 140 world s) and one house run with the stats line's new counts per reason, and the first ids/shapes. If the reads are zero or rare, the TASKS item can say so (with Seen on: the commit). If they are frequent, it can name the reasons that matter. Either result decides how long the counter lives, which is the removal condition its definition needs (rule 2).
  2. SlotFlags layout overlaps #172 (#172). That PR folds the dirty masks and the flags into one u16 per slot, with the four flags at bits 9-12. If it lands first, FLAG_PARITY takes bit 13 at no extra memory, and the move to a byte per slot (1 MiB -> 2 MiB) is not needed. Whichever lands second adapts; please don't widen the array beyond what the other one gives.
**@⁠vktory6** on GitHub · 2026-12-02 19:45 UTC · [original](https://github.com/vktory6/VKtory/pull/173#issuecomment-7356675408) Thanks. Counting the reads of slots that show a partly filled or contents-less image is the right way to settle the open question in fill.rs and vram-3.md, and it costs one flag test on a read that already loads the slot's flags. Before a merge: 1. **The answer, not only the counter.** The PR exists to answer a question, but it shows no game run. Please add one boat run (cutscenes kept, about 140 world s) and one house run with the stats line's new counts per reason, and the first ids/shapes. If the reads are zero or rare, the TASKS item can say so (with `Seen on:` the commit). If they are frequent, it can name the reasons that matter. Either result decides how long the counter lives, which is the removal condition its definition needs (rule 2). 2. **SlotFlags layout overlaps #172** (https://git.gtahub.st/github/vktory6--VKtory/pulls/172). That PR folds the dirty masks and the flags into one `u16` per slot, with the four flags at bits 9-12. If it lands first, `FLAG_PARITY` takes bit 13 at no extra memory, and the move to a byte per slot (1 MiB -> 2 MiB) is not needed. Whichever lands second adapts; please don't widen the array beyond what the other one gives.
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/173/head:github-bot/gh-173'
git switch 'github-bot/gh-173'

Merge

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