vkback: keep aliased targets per address and never alias address 0 #194
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory!194
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-194"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Mhyster on GitHub · 2026-12-02 07:07 UTC · original
Mhyster:fix/tex-targets-alias-stack→main· +85 −33 · 3 files · 1 commits · openWhat
Fixes placed shader views reading black when multiple live GPU-written targets share a title address (208 of 1,188 targets in a boat run,
targets.rs) or when unrelated targets are registered at address0:targets.rsTargets,placed.rsalias_at,slotwrite.rswrite_view):Targets::atstored a singleu64per address. If targetB(e.g. a different size or a depth target) was created at the same address as live targetA,BoverwroteAso placed views ofA's shape missedalias_atand created an unfilled copy from title memory (black). Likewise, destroying transient targetBclearedat[address]toNoneeven thoughAremained live.Targets::atnow storesVec<u64>(oldest to newest),alias_atscanstargets.all_at(address)newest-first for the first shape/bpp/non-depth match, andTargets::removeremoves only the destroyed id (viaaddrs: HashMap<u64, Vec<u64>>, avoiding a fullBTreeMapscan) so earlier live targets at that address remain visible.0(targets.rsinsert/all_at,placed.rsalias_at): address0is no title memory (placed.rssupersede_placed), so targets at0are kept only inownfor diagnostics and never returned byall_at(0)/alias_at(0, _).Reproduces the console's aliased render-target/UAV memory pools: placed views of any live GPU-written surface at an address find the matching surface instead of reading black.
The reference
VkDeviceMemoryheaps). Mirrors vkback's ownplaced.rs(alias_at,supersede_placedaddress-0 rule) andtargets.rscensus (208 of 1,188displaced targets).Evidence
greenfield/vkback/src/targets.rs:aliased_targets_keep_newest_order_and_restore_on_removeaddress_zero_never_aliases_targetsonly_another_texture_at_the_address_counts_as_displaced(including re-insert promotion without duplication)removing_an_id_frees_every_address_it_holdsonly_textures_with_an_address_are_marked_boundcargo 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 warningson root native crates,greenfield,greenfield/wine, andgreenfield/vkback/translate.frames.py) could not be run in this session (no live game run performed);cargo xwin clippyruns in GitHub Actions CI.Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited, the fixed item named above (rule 29)unsafeblock has a// SAFETY:comment; no raw pointer around the borrow checker (rule 36)TRANSLATOR_VERSIONbumped if the translator's output changes (rule 27)@vktory6 on GitHub · 2026-12-02 15:28 UTC · original
Thanks. Never aliasing address 0 is sound. The per-address target stack is the open question in the TASKS item "Targets of one description over the same memory are separate images". On the console the memory holds the last writer's bytes, so picking the newest target of matching shape can show a stale target where the console shows the newer one. That item asks for a write-here/read-there count first: does the title read A after B took its address? #147 adds that probe. Holding this until #147's numbers are in. A counter for "alias picked a target that is not the newest" would let this PR answer it too.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.