descriptor: write-back strides/view-addresses table and lock-free placed address lookup in sync_heaps #2174
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2174"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-29T10:14:21Z.
What it changes
Fixes a major
sync_heapsCPU regression introduced by920e4eef("Translate bindless buffer address reads in ray-tracing shaders"), wheresync_heaps()callsHostHeap::copied_view_address~23,000–35,000 times per frame across 6 concurrentvictory-recordsthreads:HostHeap::strides/VIEW_ADDRESSESbuffer (crates/victory-gpu/src/descriptor/host.rs,crates/victory-gpu/src/host.rs): Allocates the ~8 MiBstrides+VIEW_ADDRESSESmetadata buffer viahost.upload_buffer_maybe_wb(bytes, crate::host::scratch_wb(host))(falling back automatically toupload_bufferwhere unsupported or whenVICTORY_SCRATCH_WB=0). Previously it used a write-combinedD3D12_HEAP_TYPE_UPLOADheap, so tens of thousands of scattered 8-bytewrite_volatileupdates per frame — each followed byself.made.lock(index)unlock — forced partial write-combining buffer flushes across 6 threads. When write-back (strides_wb == true),write_view_addressuses pairedAtomicU64::store(Release)andcopied_view_address_synccan also skip the slot lock when the cached entry already matches.PLACEDshape address side table (crates/victory-gpu/src/descriptor.rs,crates/victory-gpu/src/descriptor/host.rs): Populates an append-only pagedAtomicU64table (SHAPE_ADDR_CACHE) whenViewShapes::shape()inserts a new placed shape, encoding non-addressable shapes (placed textures), buffer byte offsets, orSTRUCTUREfallback.view_address_at(i, generation)resolvesCONSTANTand 99.9%+ ofPLACEDviews without takingshapes_read()or constructing a temporaryView::Placed.safecopy::copyincopied_view_address_sync: Uses the already-read[VIEW_TAG, word(1), word(2)]record fromsync_heapsto skip lockingmadeand re-reading title memory when the view is non-addressable (e.g. placed textures) with no stalequickkey and no prior published address; uses leafsafecopy::copyinstead ofhost::read_into(soft_readbypass) on thein_placepath; skips redundantquick.store(0)when already0and skipsSlots::putfetch_orwhen the bit is already set.copied_view_address_sync_matches_view_address_across_placed_and_constant_viewsverifying placed SRV/UAV buffers, placed textures, placed acceleration structures, constant views,addressedclearing, andquickkey invalidation.How it was tested
VICTORY_PORT_CONSTANTS=1,VICTORY_WAIT_RESIDENT=textures), clean 90s A/B gameplay runs on829188e9(0 WARNs / 0 ERRORsin both runs):origin/main829188e9,victory-nvidia-20261129-120600.log):16.80(mean17.76), frame time median59.65 ms(frame_times: med56.4 ms, p9591.3, p99103.8,>50ms55.5%)sync_heaps: total med16.92 ms(mean15.28),read+cmpmed7.50 ms(mean6.74),makemed3.59 ms,waitedmed1.83 msVICTORY_THIN:224.45 ms829188e9,victory-nvidia-20261129-123819.log):18.90(+2.10 FPS/+12.5%; mean18.03), frame time median52.80 ms(-6.85 ms;frame_times: med54.2, p9584.8-6.5 ms, p9998.3-5.5 ms,>50ms46.7%-8.8%)sync_heaps: total med12.89 ms(-4.03 ms/-24%; mean11.52),read+cmpmed4.58 ms(-2.92 ms/-39%; mean4.22),makemed2.73 ms(-0.86 ms),waitedmed0.96 ms(-48%)VICTORY_THIN:206.40 ms(-18.05 ms)cargo testpassed for the crates it touches: yes (cargo test -p victory-gpu --lib --locked -- --test-threads=1— 916 passed, 0 failed;cargo clippy -p victory-gpu --lib --tests --locked— exit 0, 0 new warnings).Checked for overlap
copied_view_address,ViewShapes, orHostHeap::stridesallocation.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-30T03:37:07Z.
We ran a test of this PR on a CPU-bound machine (about 66 ms of CPU preparation per frame), a setup close to yours (Ryzen 7, 12 GB card, Series X 1440p, frame generation off).
No gain we can measure on top of current main: the controls alone spread over 9 ms. The picture was clean (0 defects in 160 frames).
Setup:
41adb551(only its own commits on top), against41adb551itself;41adb551spread through the session;Picture check: a burst of 10 captures a second at the end of each run (80 frames), looked at frame by frame.
AI Assisted