Repository navigation
Conversation
Slydock
approved these changes
Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
After #797 (
28f87ef) packedTextureQueueinto a dense 32-byteVec<Entry>,collect_due_and_census,census, andall_duestill linearly scan every queued entry underHostHeap::textures's mutex on every pass. During gameplay the queue holds ~25,000-33,000 entries (~800-1,060 KiB), even when only a fraction hasdue <= frame.On RTX 3060 12 GB (1440p release, warm cache, post-#797
main),held taking the slots duestill averaged 72.8 ms / 5 s (median 75 ms, max 100 ms), blocking other threads for 621.2 ms / 5 s (max 942 ms).Changes
All new behavior is opt-in behind
VICTORY_DUE_INDEX=1(off by default, read once). With it unset,TextureQueueandheap_texturesbehave identically tomain.crates/victory-gpu/src/descriptor/host.rs:pub(crate) fn due_index()(VICTORY_DUE_INDEX=1, off by default).DueBucketsstoring the same contiguous 32-byteEntryvalues grouped perdueframe inBTreeMap<u64, Vec<Entry>>, withFastMap<u32, (u64, u32)>for O(1) slot lookup and in-bucket swap-remove, O(1)-maintained global census counters ([c[2], c[3], c[5]]), and a single recycledsparebucket buffer to avoid steady-state re-allocations as frame buckets drain.collect_due_and_census,census, andall_dueiterate onlyby_due.range(..=frame)(O(|due|)instead ofO(|queue|)).Due::with_capacityhints outside the lock,Due::orderedpartial selection,QueueMarkslock-free shadows,QueueBatch, coldchecked/mapped/heldside maps).due_buckets_matches_flat_texture_queue: 4,000-step randomized equivalence test comparing flatTextureQueuevsDueBucketsacrosswritten,remove,done,later,hold,room,partly,recheck(print == 0and!= 0),changed, andQueueBatch::apply, verifying identicaldue_and_census,ordered,census,all_due,checked,mapped,was_uploaded,QueueMarks, and internal invariants.due_buckets_skips_future_and_recycles_spare: verifies zero-work future skips and empty-bucket capacity recycling.crates/victory-gpu/src/draw.rs:VICTORY_DUE_INDEX=1andVICTORY_TEXSPK_PASS_MSis configured, skipbefore(0)andtexture_slots_due_knownif the current frame's upper-boundtexspk_cap_msbudget is already exhausted, while still flipping finished uploads viatexture_views_remade()andtexture_slots_flip().Verification
Automated
cargo test -p victory-gpu --lib --locked descriptor::host::tests -- --test-threads=1: 61 passed, 0 failed (including all perf(gpu): reduce TextureQueue lock hold time, TELL fallbacks, and zero-work locks #797 tests and both newdue_buckets_*tests).cargo test -p victory-gpu --lib --locked texspk: 2 passed, 0 failed.cargo clippy -p victory-gpu --lib --tests --locked: 0 warnings in modified files.cargo build --release --locked: succeeded cleanly.In-game A/B benchmark
Same release binary (
pr/due-indexonmain923e38c, which already includes #797), RTX 3060 12 GB, 1440p, DLSS Performance, warm pipeline cache (0 being madethroughout 3D), identical flags (VICTORY_TEXTURE_STAGE_MS=16,VICTORY_POOL_SMALL=1), only togglingVICTORY_DUE_INDEX:main+ #797,DUE_INDEX=0)VICTORY_DUE_INDEX=1held taking the slots due(med / mean / max / 5 s)held taking the slots due(steady state, last 2 windows)before the passes' loops(mean / max / 5 s)Both runs exited cleanly with zero D3D12 errors.