GPU: refresh placed buffer tables after backing registration #2158
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2158
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2158/head"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 06:34 UTC · original
andrewpozdnakov7-jpg:fix/850-refresh-placed-buffer→main· +585 −27 · 7 files · 5 commits · closed without mergingRefs #850
A placed buffer SRV can already be mirrored against a loose shadow when the title registers a buffer for the same range. VIctory then refreshes the registered buffer, but the table still points at the loose shadow.
When the backing changes while an older recorded segment holds the heap, the next dispatch uses a temporary table keyed by the current backing. Once all recorded segments release the heap, its next bind refreshes the persistent slot.
Submission and reset
Current main keeps a queue-owned reference to each submitted host segment and gives a reset title list a fresh segment when the old one is held. The descriptor-heap lease lives in the old segment, with its recorded commands. Submission confirms the fence value before copy-back. A failed wait registration falls back to polling the completed value. Signal failure or device removal stops the submission before copy-back. D3D12 fence wait
Verification
The same synthetic Windows/WARP dispatch and texture readback on
da82e444ec46a162ca779c82d4cf191a69182971still gave 0 from the existing placed descriptor after buffer registration. At4803f2b3d38fcbeb446cc2420cabc1f4b854fc8f, based on67e8ae1401df112248aed36d0024483181b718b7, a new dispatch reads 1.25 through a temporary table while older segments retain the heap. The persistent slot then reads 1.25 after they retire, matching the fresh-descriptor control. The intervening upstream commit changes the shader test harness.The queued-reset test keeps the old segment's lease until that segment executes and is recycled. The failed-wait test confirms actual completion before returning. Full GPU suite on WARP passed with 201 passed and 1 ignored under both D3D12 debug flag settings. Strict GPU Clippy passed with default and all features, and the asset policy passed.
The placed-buffer readback is confirmed. The relationship to the cutscene symptom in #850 and the frame-time cost of the per-draw check remain open. Previous verified head
@Marvisak on GitHub · 2026-11-25 11:24 UTC · original · edited 2026-11-25 16:18 UTC
Automated triage for the maintainers.
Merge candidate, with two points for the maintainer to weigh.
What it fixes. A placed-buffer view mirrored against a loose shadow kept that copy after the title registered a buffer over the same range.
HostHeap(descriptor/host.rs) now tracks placed-buffer slots and refreshes them inlease_for_listonce no recorded segment holds the heap.shadow::register/unregisterbump the new binding generation. Until the refresh,State(draw.rs) gives an affected table fresh slots and keys the fresh-table cache by the backing buffer.What I checked.
Deferred::view_heaps, so main'sHostList::reset(*self.deferred() = Deferred::default()) and segment recycling release it. A heap is rewritten only when no segment can still execute.checkpasses on this head, and the branch merges cleanly into currentmain.Points to weigh:
Host::execute(host.rs). It now waits withSetEventOnCompletionand a null event, which blocks per the D3D12 docs. When that wait fails,wait_for_fence_valuepollsGetCompletedValue. A failedSignalnow goes throughfail. Main logged a failed wait and went on to copy-back without waiting, so this is a real fix, but it touches the core submission path in the same PR.placed_buffer_binding_changedadds a mutex lookup and a view decode per table per draw on heaps that hold placed buffers. The frame-time cost is not measured, and the link to the #850 cutscene symptom is unconfirmed (both stated by the author).Generated by Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 12:00 UTC · original
Thanks for the review. f325f85 refreshes the persistent placed-buffer slots when the first command list binds the idle heap after a buffer registration change. Earlier recorded lists keep the binding until reset or release, including a closed list that has yet to be submitted. Table arrays and bindless shaders can index beyond the explicitly named table entries, so this tracks the lifetime of the bound heap. A heap that stays continuously referenced still uses the temporary table for an affected draw until the heap becomes idle.
The draw-time backing check now skips heaps with no placed buffers. On the remaining heaps, it checks the tracked placed slot set before decoding a view or looking up a shadow. Fresh tables retain backing identity in their cache key, including tables beyond the native heap limit.
The same Windows/WARP test records a VIctory dispatch and reads the resulting texel. On main
940d32f69b, the existing slot read 0 after registration. On the previous PR head1bccc4fa05, it read 1.25 through a temporary table even after the old lists retired. At f346d1d, it reads 1.25 through a temporary table while the older list can run, then reads 1.25 through the refreshed permanent slot.The test now lives under draw and uses writable pool memory. Its source keeps a complete loose-shadow window mapped for later tests. The full GPU suite passed on WARP with 147 passed and 2 ignored, including a run with the D3D12 debug layer enabled. Strict GPU Clippy in both configurations and the staged asset policy passed. The link to the cutscene in #850 remains open.
If these changes are folded into another author's commit, please preserve attribution with this trailer:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 13:49 UTC · original
I checked the remaining reset and fence question on
f346d1d11b. Host::execute serialized submissions, while HostList::reset could independently clear Deferred and reset the host allocator. The fence path also logged a failed wait and continued. Direct3D permits resetting the command list during execution, while VIctory reuses its paired allocator and must wait for that allocator safely. D3D12 allocator reset1676f3d makes Host::execute hold the submitted lists' guards from preparation through confirmed fence completion and copy-back. HostList::reset takes the same guard before clearing its lease or reusing the allocator. The guest queue also retains each title list object through the call, so a concurrent Release of the caller's reference leaves the submission's reference alive.
After the queue signals, the synchronous wait is followed by a check of GetCompletedValue. A failed wait falls back to polling the fence while the list guards remain held. A failed signal or removed device follows the host failure path before copy-back. D3D12 fence completion
On Windows/WARP, a queued test fence held a native submission pending. The concurrent reset waited, the heap lease was live while it waited, and reset released it after the fence. The injected wait error also waited for the native fence. The guest Release check kept one submission reference. All three checks fail in a control build with their respective safeguards disabled. The existing readback test still reads 1.25 through a temporary table while older lists can execute and 1.25 through the permanent slot after retirement. Four focused tests passed. The full GPU suite passed with 150 passed and 2 ignored, both with and without the debug layer. The reset and wait checks passed 12 of 12 repeats. Both strict GPU Clippy modes and staged asset policy passed.
If this work is folded into another author's commit, please preserve attribution with this trailer:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 16:00 UTC · original
I updated this branch to current main
67e8ae1401df112248aed36d0024483181b718b7, preserving1676f3din its history. The old test still read 0 onda82e44. The updated head reads 1.25 from a temporary table while an older segment keeps the heap, then reads 1.25 from the persistent slot after retirement. Updated commitThe queue on current main owns the recorded host segments across title-list reset. I kept the lease with that segment and checked that it survives reset until the old segment runs and is recycled. The injected fence-wait failure still waits for the actual completed value. Full WARP GPU suite 201 passed and 1 ignored in both D3D12 debug flag settings. Strict GPU Clippy and asset policy passed. I updated the description to reflect these paths.
Please preserve Git authorship if carrying the fix or test into another branch. If folding it into another commit, please include the trailer below.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@Marvisak on GitHub · 2026-11-25 22:06 UTC · original
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because nothing shows the stale copy occurs in the title, and the mechanism is large with no measured cost: a lease per view heap per list, temporary fresh tables on hosts that make none today, a mutex and a set lookup per used table entry on every draw, and an idle-heap refresh that walks every placed-buffer slot whenever a title buffer was registered or released, which the title does every frame. The
Host::executerework is unrelated to placed buffers and changes the core submission path. If the bug is shown in the title, a smaller fix fitsmain: letmirror()/sync_slotsmake a placed-buffer slot again when its kept buffer is no longer the oneview_copy(view)returns. The fence change can be its own PR.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 23:25 UTC · original
Thanks for suggesting the standalone fence change. #2899 carries that change and the WARP regression at fde6a92 on
842b0cb76f8f5fa9289bd779783c51ec24d75302.The same test returned while the queue was still gated, with fence value 0 on main. In all six paired runs the patch waited until the queue reached 1. The full suite passed under both D3D12 debug settings and with GPU timing enabled.
Please preserve the Git author if cherry-picking the fix or test. If folded into another commit, please include
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.Pull request closed