Repository navigation
GPU/draw+descriptor: prevent full-card queue starvation and support mip-stream reuploads - #676
Conversation
…ip-stream reuploads Three fixes for indexed texture updates when the card is full (targeting commit 310c6eb's `reupload_when_full` path): 1. `TextureQueue` starvation behind `refused > 256` (`descriptor/host.rs`, `draw.rs`): When `!room`, refused uncreated slots previously remained untouched in `again`/`fresh` with the same `due <= frame` and `write`. Once >256 uncreated slots accumulated in `again` (or at the ends of `fresh`), every pass hit `refused > 256` on the exact same 257 slots and broke out — permanently starving remapped (`changed`) slots, older `recheck` slots, and streamed-out (`mapped == 0`) slots needed to reclaim VRAM. Add `TextureQueue::due_for(frame, max, room)` and `TextureQueue::full()`: while `!room`, prioritize already-uploaded (`recheck`/`partly`) slots and fresh/remapped slots ahead of unuploaded `again` slots, and record a separate `refused_until` backoff on refused slots without altering `due` or `looks`. As soon as `room` becomes true, `refused_until` is ignored so waiting slots are immediately eligible. 2. `reupload_when_full` rejecting mip-streaming view rewrites (`draw.rs`): When a title streams in sharper mips and rewrites a slot with a new descriptor record (`key_new != key_old`), `keep_views()` leaves `made[index] == key_old`, so `texture_slot_made_from(index, handle)` returned false under `!room` even though the texture's `ID3D12Resource` is already alive on the card (zero new VRAM needed). Fall back to `view_has_live_host_texture` (`placed_known` / `View::Shader` with `copy_state == 2`) so mip-streaming updates and sibling views of live textures still refresh when full. 3. `same_placed_texture` comparing uninitialized filler words (`descriptor/host.rs`): Zero struct-padding words `[1]` and `[13]` before comparing resource descriptions (matching `resource::texture_at` and `placed_known`) so differing title stack garbage does not defeat `keep_views()`. Extend `views_of_one_placed_texture_are_told_by_address_and_description` and add `full_card_queue_does_not_starve_recheck_remapped_or_later_slots` and `draw::full_card_tests::mip_stream_view_rewrite_recognizes_existing_live_host_texture`.
|
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
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: Tested: the cell scene, 4 runs. Not tested: part 1, later scenes, the unit tests. AI use: tested and written with Claude Code. |
Adapt the low-VRAM scheduling goal of fxceless/victory-fork#676 to our on-demand placed resources. Existing backing stays available, genuine D3D12 OOM temporarily pauses new textures, and a refused placement or its null descriptor can retry after the bounded wait. Co-authored-by: ryotdev <360374475+ryotdev@users.noreply.github.com>
…to shared memory past the card's share From fxfork fxceless#601 (DiogoPCastelos) as PalmVIDev fxceless#185 took it: once the card's share is reached, host copies of textures picked by index may go on into the PC memory the system shares with the card, up to half of its budget; the reserve for card copies counts as used in both rules. On a 6 GB card the share was reached in the world's first frames and skin, walls and clothes sampled black; with the spill the same shots had their colours. On by default, as shipped there; VICTORY_TEXTURE_SPILL=0 turns it off. This tree has no render-target room (PalmVIDev fxceless#170's targets_room_kept), so the reserve here is shadow::card_reserve alone. Not taken from fxceless#185: the full-card texture queue starvation fix and mip stream reuse (fxfork fxceless#676, 256 lines in descriptor/host.rs and draw.rs, over the size limit; draw.rs is the fps thread's). Co-authored-by: DiogoPCastelos <100236600+DiogoPCastelos@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
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.)