Repository navigation
Conversation
Port opt-in VICTORY_HEAP_WORKER=1 (off by default, gated by host::late()) into VIctory-NVIDIA while closing the descriptor-publication TOCTOU race and preserving bake, residency, prelude-upload, and relay guards: - Add crates/victory-gpu/src/heap_worker.rs (128 MiB / 80 ms flush, fast-core pinning, AtomicUsize urgent waiter guard with RAII decrement, Ready.list: Option<HostList> for same-only passes, take_ready_for_late and drain_for_bake with settle_for_fence). - Add resource::hold (reusing existing object::add_ref_alive and resource::Held) to pin live texture objects across worker execution including State::card_accounting. - Key-pin descriptor publication and flip helpers in descriptor/host.rs: publish_uploaded_slot_with re-verifies record_key(handle) == key under self.made.lock(index) and resolves View strictly from key without re-reading handle or calling mirror(); RAII PublishingGuard suppresses note_buffer re-queueing; publish_for_late preserves VICTORY_SHOW_AFTER=1, VICTORY_SHOW_NEW_LATER=1, and VICTORY_HELD_LEVELS=1 shows_other deferral (including list-less same-only batches and placed RT/DS/UAV slots). - Hook take_ready_for_late() in Host::send_late() with prepend_ahead_order() to shift VICTORY_JOIN_PARTS boundaries, and add Staging::refresh_ahead() preserving VICTORY_TEXTURE_ONCE=1, VICTORY_TEXTURE_GUARD=0, and VICTORY_PRELUDE_UPLOADS=1. - Add deterministic TOCTOU regression test publish_rejects_slot_replaced_between_reads plus unit tests for queue retention, show-after/mip-upgrade deferral, join-parts shifting, and urgent waiter handoff.
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on Windows (RTX 5090):
cargo test -p victory-gpu --lib heap_worker::(1/1) anddescriptor::(66/66, including all 4 newbake_flip_tests::) passed on RTX 5090- 0 new compiler warnings in touched files
cargo xtask policypassed (295 files ok)
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
A smoke test only: the scene barely reaches this path. RTX 3090 24 GB (driver 610.88), i9-14900K, 32 GB, Windows 11. A release build of this PR merged onto main at
A real test needs movement or a scene change that streams textures; I'll add one when I can drive one repeatably. Tested with an AI assistant (Claude Code); results are from this PC. |
Ports the opt-in
VICTORY_HEAP_WORKER=1background texture upload worker (off by default and gated onhost::late()) intoVIctory-NVIDIAwhile closing the descriptor-publication TOCTOU race and preserving bake, residency, prelude-upload, and relay guards (zero merge conflict with #693 or #704).Changes
victory-heapworker (heap_worker.rs): Opt-in viaVICTORY_HEAP_WORKER=1(off by default), 128 MiB / 80 ms batch flush, fast-core pinning (cores::keep_on_fast_cores),AtomicUsizeurgent waiter guard with RAII decrement,Ready.list: Option<HostList>sosame-only batches publish cleanly without allocating an empty list, plus splittake_ready_for_late()anddrain_for_bake(gpu)(settling in-flight GPU work viasettle_for_fence()even on list-less batches).descriptor/host.rs): Refactorspublish_uploaded_slotaroundpublish_uploaded_slot_with(index, handle, key, ...)which re-verifiesrecord_key(handle) == keyunderself.made.lock(index)and resolvesViewstrictly fromkey(view_at) without re-readinghandleor callingmirror(). Key-pins flip helpers (texture_slot_flip,texture_slot_show_after,show_later,texture_slot_show_ahead,mirror_after,flip), fixes the latentnote_bufferre-queue loop with a RAIIPublishingGuardchecked inqueue_texture(), restoresquick_isordering, and preservesVICTORY_SHOW_AFTER=1,VICTORY_SHOW_NEW_LATER=1, andVICTORY_HELD_LEVELS=1shows_othermip-upgrade deferral inpublish_for_late().resource.rs,draw.rs): Addsresource::hold(reusing existingobject::add_ref_aliveandresource::Held) to pin live texture objects across worker execution includingState::card_accounting; preservesTells/Told,-> boolbake return,bring_bake_sources,is_aliased, and placed RT/DS/UAV publication on the worker path.VICTORY_JOIN_PARTS,VICTORY_PRELUDE_UPLOADS, &VICTORY_TEXTURE_ONCEcompatibility (host.rs,list.rs,texture.rs): Hookstake_ready_for_late()inHost::send_late()viaprepend_ahead_order()so joined-part split indices shift cleanly; addsStaging::refresh_ahead()preservingVICTORY_TEXTURE_ONCE=1,VICTORY_TEXTURE_GUARD=0, andVICTORY_PRELUDE_UPLOADS=1.Verification
cargo test --locked -p victory-gpu --lib -- publish_rejects_slot_replaced_between_reads published_slot_stays_out_of_texture_queue publish_for_late_ prepend_ahead_lists_shifts_join_parts urgent_stops_worker_and_ready_drains_cleanly descriptor::host::tests -- --test-threads=1(53 passed, 0 failed) and--features diagnostics(6 passed, 0 failed):descriptor::host::bake_flip_tests::publish_rejects_slot_replaced_between_readsdescriptor::host::bake_flip_tests::published_slot_stays_out_of_texture_queuedescriptor::host::bake_flip_tests::publish_for_late_same_after_combines_show_after_and_new_laterdescriptor::host::bake_flip_tests::publish_for_late_defers_shows_other_mip_upgradehost::submission_tests::prepend_ahead_lists_shifts_join_partsheap_worker::tests::urgent_stops_worker_and_ready_drains_cleanly--all-features) andcargo test --locked -p xtaskpassed (6 passed, 0 failed, including asset policy).