pool, ahead: route reused pooled textures through DIRECT aliasing barrier and fence-gate piece rest #4714
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4714
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4713"
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?
@nidea1 on GitHub · 2026-12-01 03:10 UTC · original
nidea1:fix/pool-reuse-aliasing-barrier→main· +281 −31 · 2 files · 2 commits · closed without mergingWhat it changes
Fixes two D3D12 placement-reuse hazards in
crates/victory-gpu/src/pool.rsandcrates/victory-gpu/src/texture/ahead.rs(keepingVICTORY_POOL_SMALLopt-in / unchanged by default):Reused pooled textures bypassed the DIRECT aliasing barrier via COPY-queue upload-ahead:
again == true) previously took theVICTORY_UPLOAD_AHEADCOPY-queue upload path (texture/ahead.rs), which cannot emitD3D12_RESOURCE_BARRIER_TYPE_ALIASINGand still markedstaging.uploaded = true/copy.ahead = DONE. As a result, neither the COPY queue nor the subsequent DIRECT queue emitted an aliasing barrier before shader sampling (unlike DIRECT uploads inhost.rsandtexture.rs, which do emit aliasing barriers).ReclaimCOM private data (reused: AtomicBool, populated fromagainingive_back_to) and exposespool::reused(&ID3D12Resource)(with balancedGetPrivateDataAddRef/drop handling).texture::ahead::claimnow checkspool_allows_ahead(pool::fresh, || pool::reused)so virgin placements keep using COPY-queue upload-ahead while reused placements fall back to DIRECT uploads where the aliasing barrier is emitted.Wall-clock-only
RESTcooldown could recycle in-flight ranges across long stalls:Pool::reclaim()previously gated recycled pieces solely on wall-clockREST = 2500 mswithout checking GPU submission retirement. During >2.5 s stalls (e.g., shader compilation), an in-flight range could become eligible for reuse before the GPU retired its submission.host::submissions().0when a piece is returned (give_at) and requires bothready <= nowandsubmission <= host::submissions().1inreclaim_atbefore recycling the range.How it was tested
--fg-type fsr --framegen 3), ray tracing off,VICTORY_SAMPLED_EVICT=1,VICTORY_WINDOW_GROW=1,VICTORY_AMBIENT=0.8,VICTORY_AMBIENT_SPECULAR=1.RESTuntil retired, andtexture::aheadskipping reused pooled textures while still claiming virgin placements.VICTORY_POOL_SMALL=1+VICTORY_SAMPLED_EVICT=1showed zero aliasing/foliage flicker across inspected frames (VICTORY_POOL_SMALLremains opt-in, as separate historical 4 KiB placement GPU fault risk on NVIDIA is out of scope here).720.7 sin-world,16,447frames) uncontested live soak withVICTORY_POOL_SMALL=0+VICTORY_RIPE_BLOCKS=12(as part of our 14-branch local stack on7d93ee0759) completed with0crashes,0device losses,0Victory errors,HERO LEAD = 0,UPLOAD OVER HOST WRITE = 0, and0>100 mshitches in the final8.7minutes.cargo testpassed for the crates it touches: yes (on4512766c, base7d93ee0759)cargo test -j 2 -p victory-gpu --locked --lib pool::tests: 33 passed, 0 failed, 3 ignored (new:reused_flag_tracks_virgin_and_recycled_placements,resting_pieces_wait_for_submission_retirement_even_after_rest,reused_private_data_tracks_again_without_leaking_references)cargo test -j 2 -p victory-gpu --locked --lib texture::ahead::tests: 9 passed, 0 failed (new:reused_pooled_textures_are_not_eligible_for_ahead_copy,reused_pooled_texture_is_skipped_by_ahead_claim)cargo clippy -j 2 -p victory-gpu --all-targets --locked -- -D warningsand--all-features: 0 warnings on7d93ee0759(note: currentmain5fabb46ehas 5 pre-existing clippy errors infont.rs/menu.rs/panel.rsfrom#4634, tracked in#4679/#4707).cargo xtask policy: 464 files ok (--staged: 2 files ok).Checked for overlap
#4654,#3069,#4581,#3711,#3766,#4636, and#4698; none route reused pooled textures offtexture::aheadfor the DIRECT aliasing barrier or fence-gatePool::reclaim()on submission retirement. Hunks inpool.rsandtexture/ahead.rswere kept minimal and disjoint from#4581/#4654.@Jesper-Andersson on GitHub · 2026-12-01 04:27 UTC · original
@nidea1 the new test
resting_pieces_wait_for_submission_retirement_even_after_restdepends on test order. It passes alone and withcargo test -p victory-gpu --lib pool::, but fails in the fullcargo test --locked -p victory-gpu --lib, also with--test-threads=1:That is the
assert_eq!(pool.free_bytes, 0)right after thetakethat should reusefirst:second(submission 6) was reclaimed too.Cause, from reading the code:
take→cut→rested(now)(pool.rs:391 and 487 on your head4512766c9) reclaims withcrate::host::submissions().1, the process-wide finished counter, not with thefinishedthe test passes toreclaim_at. Other tests in the same run move that counter past 6, so thetakefreessecondearly.A way out: give the test a
takepath that takesfinishedexplicitly (asreclaim_atdoes), or keep the test's submission numbers above anything the counter can reach in a test run.Tested on our fork's port of this PR (same code path), RTX 2070 SUPER 8 GB, Windows 11; only
cargo test, no game run for this.Drafted with AI assistance (Claude Code).
@nidea1 on GitHub · 2026-12-01 09:55 UTC · original
@Jesper-Andersson Thanks for catching this and pinning down the exact cause!
Reproduced the exact failure (
left: 33554432,right: 0) in fullcargo test --locked -p victory-gpu --lib -- --test-threads=1and fixed it in04f1c6b8:Pool::cut_at/Pool::rested_atand#[cfg(test)]Pool::take_at/Pool::take_sized_ataccepting an explicitfinished: u64(withcut,rested, andtake_sizeddelegating tocrate::host::submissions().1).resting_pieces_wait_for_submission_retirement_even_after_rest(andreused_flag_tracks_virgin_and_recycled_placements) to usetake_atwhere explicit submission counters are tested, while still exercising the livecut -> rested_at(now, host::submissions().1)path viapool.take(withu64::MAX) and checkingpool.giveagainsthost::submissions().0.Pool<u32>unit tests frompool.give(..., t)topool.give_at(..., t, 0)so they cannot flake under parallelcargo testif another GPU test is concurrently mid-submission (STARTED > FINISHED).Verification on
04f1c6b8:cargo test --locked -p victory-gpu --lib -- --test-threads=1: 1138 passed, 0 failed, 66 ignoredcargo test --locked -p victory-gpu --lib: 1138 passed, 0 failed, 66 ignoredcargo clippy -p victory-gpu --all-targets --locked -- -D warningsand--all-features: 0 warnings (keeping base7d93ee07while#4707is still open; PR remainsMERGEABLEonmain5fabb46e)cargo xtask policy: 464 files ok@Dukestar69 on GitHub · 2026-12-01 12:05 UTC · original · approved these changes
Reviewed crates/victory-gpu/src/pool.rs and crates/victory-gpu/src/texture/ahead.rs: fence-gating resting pieces with (ready_ms, submission, piece) (submission <= finished) prevents premature reuse while in-flight submissions may still reference the range, and tracking
eused (gain) on Reclaim (with proper IUnknown::from_raw release of the temporary GetPrivateData AddRef) cleanly excludes reused placed textures from COPY-queue exture::ahead uploads so they take the DIRECT-queue aliasing barrier path. Verified on Windows (RTX 5090): pool::tests (33 passed, 0 failed) and exture::ahead::tests (9 passed, 0 failed).
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@nidea1 on GitHub · 2026-12-01 12:33 UTC · original
Live runtime verification on updated head
04f1c6b8(RTX 3060 Ti 8 GB (ReBAR off, driver621.40), 32 GB RAM, Windows 11, Series S, DLSS Quality, FSR 3 FG, RT off,VICTORY_SAMPLED_EVICT=1,VICTORY_WINDOW_GROW=1,VICTORY_POOL_SMALL=0,VICTORY_RIPE_BLOCKS=12— 5-minute (300 sin-world,357 stotal) live validation on a combined 15-PR release build overorigin/main(5fabb46eaf).):300 sin-world (357 stotal) with0nvlddmkmevents (id153=0),00x887Adevice hangs,0HERO LEAD,0UPLOAD OVER HOST WRITE, and0Victory errors.52texture blocks,6,559 / 6,770 MBVRAM,5,980 MBShared GPU RAM,22.27 GBPrivateBytes).+31 s,+151 s,+285 s): clean rendering with0aliasing/corruption artifacts.Caveat: combined 15-PR release build over a 5-minute opening/cell sequence with
VICTORY_POOL_SMALL=0(not an isolated A/B orVICTORY_POOL_SMALL=1soak).@nidea1 on GitHub · 2026-12-01 14:39 UTC · original
Thanks @Dukestar69 for the review and RTX 5090 test verification (
pool::testsandtexture::ahead::tests) on04f1c6b8!@trustno1-coder on GitHub · 2026-12-01 18:34 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed