Repository navigation
GPU: read-mark scans stop at the end of the view slots in use - #3052
0xkn0wh3r3 wants to merge 1 commit into
Conversation
After every submission take_reads scanned the texture-view read marks of every slot a shader can index (HEAP_VIEWS, 2^21: 64 Ki words in each of two bitmaps, plus the record of slots seen), whatever the title's view heaps hold; reads_since (eviction stamps) did the same. Both now stop at the end of the view slots in use (descriptor::view_slots): the most slots any shader-visible view heap has had, raised to the end of the dynamic slots a host heap hands out (tables made afresh, whose texture views shaders read too and the eviction stamps look up). A mark past it names no slot make_read or the eviction stamps act on, and stays set for a larger heap to find. A host copy's pairs are buffer views, which take no read marks. read_marks_of_both_bitmaps_are_taken marks slots of a heap it makes and a dynamic slot past them, instead of the last two possible slots, and checks that a mark past every slot in use is not taken.
- `cargo demo` is a synthwave drive into the sunset: a neon car, the camera following, spinning shapes along the highway (the stress scale), and it reports where each frame's time in VIctory goes, by call and by submission phase (victory_gpu::submission_totals). - Read-mark scans stop at the end of the view slots in use, dynamic slots counted (as Marvisak#3052 on main). - Large graphics blocks get write-watched memory of their own, so their host copies refresh only the pages written (as Marvisak#3053 on main).
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed head 4552cb4d line-by-line (CI green):
VIEW_SLOTSgrows monotonically viafetch_maxon shader-visible view heap creation (desc.kind == VIEWS_KIND) and dynamic slot allocation (HostHeap::dynamic), covering every view-heap index that can hold a texture view (HostHeap::paironly allocates buffer views, which do not emit texture read marks).- Both
shadow::take_readsandshadow::reads_sincebound their scans by(descriptor::view_slots().div_ceil(32) as usize).min(words)whileforgottenstill drains unconditionally. - The updated
read_marks_of_both_bitmaps_are_takentest covers a mark pastview_slots(), a dynamic slot past the title heap's size, and both bitmaps.
Clean, surgical hot-path win.
kotekompotek
left a comment
There was a problem hiding this comment.
Verified: the truncation is conservative in the right direction — marks past view_slots are neither taken nor cleared, so a heap created later covering those slots still finds them; div_ceil(32).min(words) bounds to actual bitmap size, and view_slots_reach from HostHeap::dynamic covers tables made afresh (the doc's claim that buffer views take no read marks is consistent with the shadow code). The test exercises all three regions: inside the title heap, a dynamic slot past it, and a mark beyond every slot in use left untaken.
|
Automated triage for the maintainers. Verdict: merge candidate. In CI: Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):
- Diff review: Tracking the highest view slot in use via
descriptor::view_slots()(including dynamic overflow slots) and stopping read-mark scans there cleanly avoids scanning unused tail words of the read-mark bitmaps. cargo test -p victory-gpu read_marks_of_both_bitmaps_are_taken -- --test-threads=1(RTX 5090 & WARP): 1 passed, 0 failed on both.cargo test -p victory-gpu shadow::tests -- --test-threads=1(RTX 5090): 9 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
… onto upstream; already here, with demo's test fix)
|
Verified
Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity. |
… of the view slots in use
… of the view slots in use
|
Windows 11,
Synthetic only. AI-assisted. |
After every submission,
take_readsscans the texture-view read marks of every slot a shader can index:HEAP_VIEWSis 2^21 slots, so that's 64 Ki words in each of two bitmaps, plus the record of slots seen, whatever the title's view heaps actually hold.reads_since, which feeds the eviction stamps, does the same. This makes both scans stop at the end of the view slots in use.Changes
descriptor::view_slots(): the end of the view slots in use. It only grows. It's raised to a shader-visible view heap's size when the heap is created, and to the end of any dynamic slots a host heap hands out. Dynamic slots hold tables made afresh; shaders read texture views there too, and the eviction stamps look them up, so they have to be counted.take_readsandreads_sincescan only up to it. A mark past it names no slot thatmake_reador the eviction stamps act on, and it stays set, so a larger heap created later still finds it.Testing
read_marks_of_both_bitmaps_are_takennow marks slots of a heap it creates, plus a dynamic slot past them, instead of the last two possible slots. It also checks that a mark past every slot in use isn't taken.victory-gpu's read-mark, eviction and paged-heap tests pass: cross-compiled for Windows in release and run under Wine and CrossOver on macOS. Not run on Windows.demo):take_readsfell from 0.061 to about 0.001 ms a submission, and the copy-back phase from 0.070 to 0.030 ms. The gain in a game depends on the size of its view heap and how many dynamic slots it uses; a heap near 2^21 slots gains little.