GPU: read-mark scans stop at the end of the view slots in use #3050
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3052"
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 0xkn0wh3r3 on 2026-11-26T05:35:23Z.
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.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T05:45:12Z.
Review: APPROVED
Reviewed head
4552cb4dline-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).shadow::take_readsandshadow::reads_sincebound their scans by(descriptor::view_slots().div_ceil(32) as usize).min(words)whileforgottenstill drains unconditionally.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.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T06:00:51Z.
Review: APPROVED
Verified: the truncation is conservative in the right direction — marks past
view_slotsare 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, andview_slots_reachfromHostHeap::dynamiccovers 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.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T06:32:08Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:18:16Z.
Automated triage for the maintainers.
Verdict: merge candidate. In
crates/victory-gpu/src/shadow.rs,take_readsandreads_sincenow stop atdescriptor::view_slots()instead ofHEAP_VIEWS. That value only grows. It is raised indescriptor::create_heapfor shader-visible CBV/SRV/UAV heaps (VIEWS_KIND) and inHostHeap::dynamicfor dynamic slots. I checked that this also covers our own view heap (memory::heap(), aHostHeapwith 0 title slots whose slots are all dynamic), and the dynamic slots used by tables made afresh. Marks past the limit stay set rather than being lost, and forgotten slots are still cleared over the whole bitmap. The updated test creates a 64-slot heap and checks three things: a dynamic slot past it is taken, the two title slots are taken, and a mark atHEAP_VIEWS - 1is not. The test leaves that heap alive, which is harmless.CI:
checkpassing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by MeMako on 2026-11-26T07:50:54Z.
Verified
#3052(4552cb4) on native Windows 11 (10.0.26200) + AMD Radeon RX 9070 XT (RDNA 4, driver32.0.32029.2010, Ryzen 9 7950X, 32 GB RAM).cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings: clean;cargo test -p victory-gpu --lib --locked -- --test-threads=1: 274/274 passed (includingread_marks_of_both_bitmaps_are_taken).main63bcca4+#2051+#2472+#2918+#1010+#2130with VRAM upload flags off +#3055+#2914+#2985+#2849+#3035+#2958, adding#2940+#3052+#3061together): 0 crashes, 0 regressions; localtake_readstimer dropped 2.10 → 1.70 ms across the first 26 heavy frames and 2.40 → 1.65 ms (-31%) across the last 8 heavy frames.Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity.
Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T16:24:49Z.
Windows 11,
63bcca4+ this PR:cargo test -p victory-gpu: 231 passed / 0 failed / 1 ignored — the same numbers as unpatched63bcca4here, with your modified read-mark, eviction and paged-heap tests included.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.Synthetic only. AI-assisted.
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.