GPU/draw+descriptor: prevent full-card queue starvation and support mip-stream reuploads #676
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/fxceless--victory-fork!676
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-676"
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?
@AscilCH on GitHub · 2026-11-25 04:20 UTC · original
AscilCH:fix/gpu-heap-textures-full-card-starvation-and-mip-reupload→main· +310 −21 · 2 files · 1 commits · openSummary
Fixes three bugs in
crates/victory-gpu/src/draw.rsandcrates/victory-gpu/src/descriptor/host.rsaffecting indexed texture streaming when VRAM is full (targeting thereupload_when_fullpath added in310c6eb):Full-card queue starvation behind
refused > 256(descriptor/host.rs,draw.rs):!room, refused uncreated slots previously remained untouched at the front ofagain(or ends offresh) with unchangeddue <= frameandwrite. Once 257 uncreated slots accumulated, every pass hitrefused > 256on the exact same 257 slots andbreaked — permanently starving remapped (changed) on-card textures, olderrecheckslots, middle-of-freshslots, and streamed-out (mapped == 0) slots needed to reclaim VRAM viatexture_slot_gone.TextureQueue::due_for(frame, max, room)andTextureQueue::full()(via a separaterefused_untilfield that does not modifydueorlooks). While!room, already-uploaded (recheck/partly) and fresh/remapped slots are prioritized ahead of unuploadedagainslots, and refused slots yield with capped backoff (2..=mostframes) so passes advance through the queue. The instantroombecomes true,refused_untilis ignored so waiting slots are immediately eligible.reupload_when_fullrefusing mip-streaming updates and sibling slots (draw.rs):key_new != key_old);keep_views()intentionally leavesmade[index] == key_old, causingtexture_slot_made_from(index, handle)to returnfalseeven though the underlyingID3D12Resourceis already resident on the card (0 bytes of new VRAM needed).view_has_live_host_texture()checkingresource::placed_known/View::Shader+resource::copy_state == 2alongsidetexture_slot_made_fromso mip-streaming updates and sibling views of resident textures still refresh when full.same_placed_texturecomparing uninitialized stack garbage (descriptor/host.rs):[1]and[13]before comparingresource == other(matchingresource::texture_atandresource::placed_known) so differing stack garbage on a view rewrite does not defeatkeep_views().(Orthogonal to open PR
#632—texture_slot_goneis untouched.)Verification
cargo test -p victory-gpu --lib --locked descriptor::host::tests— 15 passed, 0 failed (including extendedviews_of_one_placed_texture_are_told_by_address_and_descriptionand newfull_card_queue_does_not_starve_recheck_remapped_or_later_slots)cargo test -p victory-gpu --lib --locked draw::full_card_tests— 1 passed, 0 failed (mip_stream_view_rewrite_recognizes_existing_live_host_texture)cargo clippy -p victory-gpu --all-targets --all-features --locked— 0 warnings in modified code (only pre-existing310c6ebwarnings in untoucheddraw.rs:2339andindirect.rs:1322)cargo xtask policy— asset policy: 169 files ok(AI-assisted; synthetic unit tests only, no game data.)
@cafeoh on GitHub · 2026-11-25 07:14 UTC · original
Tested parts 2 and 3 on an RTX 2080 Ti (11 GB) + Windows 10, in the prologue up to the prison cell scene (character at the window).
Setup: fork main
8dd30abplus #683, #644, #487, #606, #559, #701, #687. Part 1 did not merge cleanly with main's own full-card hold/room code, so I left it out and applied parts 2 and 3 by hand. The card is full (room=false) a few scenes earlier. Same switches in every run (VICTORY_DEBUG_NULL_VIEWS=1,VICTORY_SKIP_BINK=1).C and D gave the same picture, so it repeats. With part 2 on, a local counter also showed thousands of first uploads stuck for 32–128 frames, with only 40–190 slots handed out per frame (A/B: thousands per frame).
My guess, not checked:
placed_knownfinds a live host copy by address, but when memory is reused that copy can belong to a different texture than the one the new view describes. Part 2 then lets the slot refresh onto it, so it shows the wrong texture.Tested: the cell scene, 4 runs. Not tested: part 1, later scenes, the unit tests.
AI use: tested and written with Claude Code.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.