perf(gpu): add opt-in marked heap-slot refresh pass and async texture worker #3439
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3439"
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?
Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-27T02:20:20Z.
Summary
Adds opt-in dirty/marked descriptor-heap slot tracking (
VICTORY_MARKED_HEAP_PASS) to avoid full heap rescans across passes, alongside an opt-in async texture upload worker and direct constant upload path.Changes
Verification
cargo test --locked -p victory-gpu --libcargo clippy --locked -p victory-gpu --all-targets --all-features -- -D warningscargo xtask policyImported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T02:29:17Z.
Review: APPROVED
LGTM — verified on Windows (RTX 5090):
cargo test -p victory-gpu --libpassed (233/233, includingheap_pass::tests::andtexture_worker::tests::, skipping the 2 pre-existingorigin/mainRTX 5090 failures)cargo clippy -p victory-gpu --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (193 files ok)Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T02:40:17Z.
Review: CHANGES_REQUESTED
Default behavior (
VICTORY_MARKED_HEAP_PASS,VICTORY_TEXTURE_WORKER, andVICTORY_DIRECT_CONSTANTSall off) builds and passes cleanly, but all three opt-in features currently fail correctness checks (two break the existingbindless::tests::heap_views_are_currenttest immediately on discrete D3D12 hardware):Blocking Issues
VICTORY_MARKED_HEAP_PASS=1freezes all CPU writes to already-bound bindless buffers and textures for 255 consecutive submissions (crates/victory-gpu/src/heap_pass.rs:327-357,crates/victory-gpu/src/bindless.rs:248-265, 356-380)bindless::tests::heap_views_are_currentwithVICTORY_MARKED_HEAP_PASS=1: fails immediately on Round 1 (assertion left == right failed: round 1, dword 0: left: 1064, right: 5016) because the GPU still reads Round 0's stale bytes!Marked::note(slot)is only called when a descriptor slot is rewritten (Viewed::set/forget), andMarked::planclearsself.dirtyon every pass. On the next 255 submissions where the title updates buffer/texture memory without rewriting descriptor slots,plan()returns empty and skips both!crate::watch::clean_bit(*bit)and texture refresh checks completely.bindless.rs:251-263and359-364build fullmappedandallVecs of every slot/hull on every pass and perform anO(|dirty| * |slots|).iter().find(...)lookup insideplan().watch::clean_bit/ texture watch pages). Any heap-pass optimization must still refresh every live copy whose underlying title memory changed since the last submission.VICTORY_TEXTURE_WORKER=1renders with unuploaded textures and racestexture::recycle()against in-flight staging chunks (crates/victory-gpu/src/texture_worker.rs:535-583,crates/victory-gpu/src/bindless.rs:213-305)bindless::tests::heap_views_are_currentwithVICTORY_TEXTURE_WORKER=1: fails immediately on Round 0 (assertion left == right failed: round 0, dword 0: left: 1000, right: 1064), because Submission 0's draw executes before the background worker uploads its texture (sampling0instead of64).bindless::uploadscallstake_ready()(retrievingreadycommand lists that have not yet been submitted to the GPU), then immediately callscrate::texture::recycle(), resettingCHUNKSto(current=0, used=0)and returningBUFFERS.usedtoBUFFERS.free, and then callstexture_worker::submit(work)— allowing the worker thread to carveCHUNKS.all[0] + 0and overwrite the exact staging memory the GPU is about to copy from!prepare()creates a brand-newHostList(newID3D12CommandAllocator) for every job even when zero textures changed (dropped immediately after execution instead of recycled),Uploads::lists()chains an extra emptyself.held.0list, andtake_ready()removes keys fromPENDINGand dropsnext.workbefore the GPU finishes executingnext.list.PENDINGentries until submission/completion.VICTORY_DIRECT_CONSTANTS=1writes a CBV descriptor into an SRV descriptor table range and drops heap retention (crates/victory-gpu/src/draw.rs:271-292, 1375-1383,crates/victory-gpu/src/descriptor/host.rs:419-432)ByteAddressBufferSRV descriptors (D3D12_DESCRIPTOR_RANGE_TYPE_SRV, seedescriptor/host.rs:1471-1492andvictory-shader/src/emit/lower.rs:9495).HostHeap::constant_atinstead writes a CBV (CreateConstantBufferView) into that SRV slot (invalid under D3D12 specification / Debug Layer / GBV), callsself.keep(index, None)without keepingshadow.bufferalive in the heap slot, andcontinues pastreadable(...).SRVrange (a rawR32_TYPELESSbuffer SRV, just asmake()builds) and retain the backingID3D12Resourceviaself.keep(...).Minor Note
#[allow(clippy::undocumented_unsafe_blocks)]attributes (descriptor/host.rs:418,texture_worker.rs:449, 457, 534) and add explicit// SAFETY:comments matching the rest of the crate.Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-28T04:41:27Z.
Thanks @fuzeofficlal — pushed an updated commit normalizing the raw buffer SRV GPU-VA word in
descriptor::host::tests::direct_constants_are_raw_srvs_and_retain_their_buffer(crates/victory-gpu/src/descriptor/host.rs) so both slots compare at matching buffer offsets while verifying raw SRV layout and backing buffer retention.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.