GPU: a buffer view slot follows the title buffer that holds its bytes #2893
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2895"
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-25T23:18:54Z.
What
A buffer view reads the copy of the innermost title buffer that holds its bytes (
shadow::for_view→find). A heap slot made from a view kept the copy it was first made on. Two things change which copy draws refresh for the view (view_copy, fromreadable):The copy the slot showed stayed the same either way. So shaders read a copy that was no longer brought up to date, or a released buffer's copy. The fresh tables a list reuses (
fresh_tables) held the same stale views.This PR adds three things:
shadowcounts title buffers made and released (owners()).HostHeap::mirror: a buffer view slot whose record hasn't changed is checked again only when that count has moved. It's made again when the copy it shows isn't the one its view reads now. Until buffers come or go, the cost is one comparison.fresh_tableskey includes the count, so a list makes a table again after buffers come or go.Where it came from
From DexNom's fork, DexNom/VIctory@5f4c3df (
buffer_owner_current,BUFFER_GENERATION, and the testplaced_buffer_slots_follow_new_and_released_owners). It's reworked for this tree'smirrorand compares againstview_copy, so views with copies of their own (shadow::exact) are handled too. Credited withCo-authored-by: DexNom.Tested
descriptor::host::tests::buffer_view_slots_follow_new_and_released_owners. It places a shader view and an unordered view in a 512-byte title buffer. The slots show its copy, then the copy of a 64-byte buffer placed inside it, then the outer copy again once the inner buffer is released, each time the copyview_copygives. With the check disabled, it fails at the second step (the slot still shows the outer copy).cargo test -p victory-gpu(Windows 11, RTX 5070 Ti): 230 passed. The 2 known NVIDIA failures are fixed by #2121.cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without--features diagnostics: clean.Not tested
fresh_tableskey change within one list.Changes after review
a71de13, race: the owner count now goes up after the buffer map changes, so amirrorthat read the old count looks again.a71de13, constant views: constant views in the heap are made raw views of the copy that holds their bytes, and they now follow it too (shown_copy). The test adds a constant view of the same bytes; without the change, slot 2 keeps the outer copy.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:32:28Z.
Review: COMMENTED
Verified head
b0e51ff3cleanly on top oforigin/main(842b0cb7) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP +VICTORY_D3D12_DEBUG=1).Findings
crates/victory-gpu/src/shadow.rs:1002-1019(register/unregister):OWNERS.fetch_add(1)is called beforeBUFFERSis updated. A concurrentmirror()thread can observe the incrementedowners(descriptor/host.rs:792), callview_copy(&view)before theBUFFERSinsert/remove completes (still seeing the old owner soheld == current), and cache the newownersinowners_seen(descriptor/host.rs:808), permanently missing the owner change. MovingOWNERS.fetch_add(1, Ordering::Release)(paired withAcquireload inshadow::owners()) after updatingBUFFERScloses that window.View::Constantheap slots skipped byowner_moved()(descriptor/host.rs:794):owner_moved()exits early whenbuffer_range(&view).is_none(), andbuffer_range(descriptor/host.rs:1154) returnsNoneforView::Constant. Becausemake()andreadable()both resolve and refresh heap CBV slots viashadow::find, a heap-residentView::Constantwhose backing title buffer is created or released won't be refreshed whenOWNERSchanges.sync_slotsonly re-checks slots whose dirty-page records changed, so a purely bindless buffer view whose backing buffer changes without a descriptor write won't refresh viasync_slotsalone (worth noting if intentional).#2885and#2873(owner_moved()reusesview_copy(&view)), though#2895and#2873touch the same area near the top ofdescriptor/host.rs'smod tests.Local Verification
shadow::tests9/9,draw::tests20/20,descriptor::host::tests15/16 (buffer_view_slots_follow_new_and_released_ownerspasses; the single failure is the pre-existingdynamic_slots_are_held_until_releasedNVIDIA 1M view cap baseline).VICTORY_D3D12_DEBUG=1:descriptor::host::tests16/16,shadow::tests9/9,draw::tests20/20.cargo clippy --locked -p victory-gpu --tests -- -D warnings&cargo xtask policy(191 files ok): clean.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:37:04Z.
Review: COMMENTED
Correct staleness epoch: owners() counts title-buffer make/release, so a slot whose innermost byte-owner changed since last view gets re-resolved through view_copy — the kept-pointer comparison then catches a shadow that moved. Only re-checked for buffer views and only when the owner count moved, so the per-draw cost stays near zero. LGTM.
upstream-sync referenced this pull request2026-11-26 04:06:08 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:30:23Z.
Automated triage for the maintainers.
Thanks, that answers the note.
draw::State::cutclearsfresh_tables, so an owner change only rebuilds tables within the current segment. A diagnostics counter can be a follow-up. Nothing else has changed (same head). One cross-PR point: #2821's lock-freereadypath inHostHeap::mirrorwould skipowner_moved, so whichever lands second needs to account for it.CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T05:49:34Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):shadow::owners()andHostHeap::owners_seenand comparing the slot's held host resource againstshown_copy(&view)ensures SRV/UAV/CBV buffer view slots rebind whenever an inner placed title buffer is created or released over the same address range.cargo test -p victory-gpu buffer_view_slots_follow_new_and_released_owners -- --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).
upstream-sync referenced this pull request2026-11-26 07:01:46 +00:00
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T07:06:37Z.
On the
fresh_tablesnote:fresh_tableslives in one host list segment (State::cutclears it). So a buffer create or release invalidates the tables already made in that segment only, and each is made again at most once, on its next use. The cost is that rebuild plus its dynamic slots, which stay held until the list is reset.I haven't added a counter, to keep this PR small. Telling an owner-change rebuild apart from an ordinary miss needs a second key without the count. If you'd like the number before merging, I can add a diagnostics counter here or as a follow-up.
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.