GPU: a placed texture without a host texture gives back its slot #3198
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3198
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3198"
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?
@kotekompotek on GitHub · 2026-11-26 12:06 UTC · original
kotekompotek:gpu/placed-texture-gives-back-its-slot→main· +36 −1 · 1 files · 1 commits · openFixes VIC-BT-027 from the audit list in #1242.
HostList-side texture lookup:texture_atinserts the freshly made resource intoPLACED_TEXTURESbefore the host texture is known to exist. WhenCreateCommittedResourcefails (or there is no host), the entry stays — andcurrent()answers a cached resource whosehost()isNone(Some(None)passes the(_, Some(_))key check and returnstrue), so every latertexture_atfor that slot returns the host-less resource forever. The slot is poisoned by its first failed lookup.The fix gives the slot back: if
resource(out).host()came backNone, the map entry is removed (guarded against a racing inserter) so a later ask can try again.Regression test
a_placed_texture_without_a_host_texture_is_not_kept: a width-0 texture desc whose host texture cannot be made returnsNoneand leaves noPLACED_TEXTURESentry, while a good desc still caches.cargo clippy -p victory-gpu --all-targetsclean on the pinned toolchain; the new test passes.@AurumCarlos on GitHub · 2026-11-26 12:16 UTC · original · reviewed
The diagnosis is right:
Resource::host()stores a failedshared_textureasSome(None),current()returnstruefor it, and the slot then answers that host-less resource for good. The removal is keyed correctly too (descis the normalised copy with words 1 and 13 zeroed), and the== Some(&(out as usize))check avoids removing a racing inserter's entry.One concern about what happens on the next ask, though:
Each retry leaks a resource and adds to
PLACED_BYTESagain. When the slot is given back,outis only removed from the map. It is never released, and theplaced_sizeadded toPLACED_BYTESjust before is never subtracted. So the nexttexture_atfor the same address and description runscreate_at_addressagain (a newResource, refcount 1),shared_textureagain (a newCreateCommittedResourceattempt), andfetch_addagain.For a failure that is transient (memory pressure), that's the point of the change. But for one that is deterministic, like the width-0 description in the test, the host texture can never be made.
texture_atruns for the slots a submission's shaders read, so that becomes one leakedResource, one failed host creation and one morePLACED_BYTESincrement per draw that reads the slot, for the rest of the session. Before this change it cost one resource, once.PLACED_BYTESis only used in thehost.rsstats line, so that part is cosmetic, but the leak and the repeated D3D12 calls on the draw path are not.Some options:
outand subtract itsplaced_sizewhen the slot is given back. Note that another thread may have pickedoutup from the map betweendrop(map)and the removal (thecurrent()check passes for it until the host texture is stored), so releasing it there is only safe if every caller holds its own reference.(address, desc)that is retried only after the memory key's host texture changes, or after N frames, so a description that can never succeed doesn't retry on every draw.In both cases, a test that calls
texture_at(address, &bad)twice and checks that nothing grows (PLACED_BYTES, or the count of live resources) would pin down the behaviour you choose.A smaller point: the test returns early without a host, so on CI runners with no adapter it checks nothing. It might be worth noting that in the PR description next to the clippy/test line, so readers know which machine actually ran it.
@Dukestar69 on GitHub · 2026-11-26 13:08 UTC · original · approved these changes
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-gpu --lib resource:: -- --test-threads=1: passed.cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 14/14 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly releases the slot when a placed texture has no host texture.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@oni-swr on GitHub · 2026-11-26 14:43 UTC · original
WARP verification of head
a867f4fc(base = current main63bcca4).Setup: Windows 11,
VICTORY_WARP=1+VICTORY_D3D12_WARP=1,--features diagnostics(software adapter only, no physical GPU), Windows SDKdxil.dll, synthetic tests only.cargo test -p victory-gpu --lib: 247 passed, 0 failed, 1 ignoredresource::tests::a_placed_texture_without_a_host_texture_is_not_kept: passthe failed texture is not kept)Verified with Claude Code (Claude Sonnet 5.5).
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.