GPU: refresh placed buffer tables after backing registration #2158

Closed
github-bot wants to merge 5 commits from gh-pr/2158/head into gh-pr/2158/base
Owner

@⁠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 merging

Refs #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 da82e444ec46a162ca779c82d4cf191a69182971 still gave 0 from the existing placed descriptor after buffer registration. At 4803f2b3d38fcbeb446cc2420cabc1f4b854fc8f, based on 67e8ae1401df112248aed36d0024483181b718b7, 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

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 06:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2158) `andrewpozdnakov7-jpg:fix/850-refresh-placed-buffer` → `main` · +585 −27 · 7 files · 5 commits · closed without merging Refs #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](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12fence-seteventoncompletion) ## Verification The same synthetic Windows/WARP dispatch and texture readback on `da82e444ec46a162ca779c82d4cf191a69182971` still gave 0 from the existing placed descriptor after buffer registration. At `4803f2b3d38fcbeb446cc2420cabc1f4b854fc8f`, based on `67e8ae1401df112248aed36d0024483181b718b7`, 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](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/1676f3de8a242913f47d745bba1878609f732897)
Refs #850
Keep the old persistent descriptor while a recorded list can execute with its heap. Refresh only the placed buffer slots when an idle heap binds again after a buffer registration change.
The loose shadow outlives the draw test. Give it a mapped window for later memory submissions in the same process.
Serialize reset with the submission of the same list and retain title list objects for the call. Confirm the fence before copy-back and reuse, even when the blocking wait fails.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:56:39 +00:00
github-bot closed this pull request 2026-11-26 04:56:39 +00:00
Author
Owner

@⁠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 in lease_for_list once no recorded segment holds the heap. shadow::register/unregister bump 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.

  • The lease lives in Deferred::view_heaps, so main's HostList::reset (*self.deferred() = Deferred::default()) and segment recycling release it. A heap is rewritten only when no segment can still execute.
  • The new synthetic WARP dispatch test reads 0 on main and 1.25 with the fix.
  • CI check passes on this head, and the branch merges cleanly into current main.

Points to weigh:

  • It also reworks Host::execute (host.rs). It now waits with SetEventOnCompletion and a null event, which blocks per the D3D12 docs. When that wait fails, wait_for_fence_value polls GetCompletedValue. A failed Signal now goes through fail. 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_changed adds 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

**@⁠Marvisak** on GitHub · 2026-11-25 11:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2158#issuecomment-7161009531) · edited 2026-11-25 16:18 UTC <!-- victory-triage v1 head=4803f2b3d38fcbeb446cc2420cabc1f4b854fc8f verdict=merge-candidate at=2026-11-25T16:18:20Z --> 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 in `lease_for_list` once no recorded segment holds the heap. `shadow::register`/`unregister` bump 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.** - The lease lives in `Deferred::view_heaps`, so main's `HostList::reset` (`*self.deferred() = Deferred::default()`) and segment recycling release it. A heap is rewritten only when no segment can still execute. - The new synthetic WARP dispatch test reads 0 on main and 1.25 with the fix. - CI `check` passes on this head, and the branch merges cleanly into current `main`. **Points to weigh:** - It also reworks `Host::execute` (`host.rs`). It now waits with `SetEventOnCompletion` and a null event, which blocks per the D3D12 docs. When that wait fails, `wait_for_fence_value` polls `GetCompletedValue`. A failed `Signal` now goes through `fail`. 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_changed` adds 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](https://claude.ai/code)_
Author
Owner

@⁠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 head 1bccc4fa05, 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 12:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2158#issuecomment-7161796282) Thanks for the review. [f325f85](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/f325f850e292c856a374f6a20f4b7ab9af6c2b89) 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 940d32f69b22265690a0b5a15d6ded572ba33baf, the existing slot read 0 after registration. On the previous PR head 1bccc4fa051ddc10f5d13877b0da62256af561eb, it read 1.25 through a temporary table even after the old lists retired. At [f346d1d](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/f346d1d11b264fbd0ccbe72e5664e0c7bf9c3bc0), 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]>
Author
Owner

@⁠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 reset

1676f3d 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 13:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2158#issuecomment-7164349481) I checked the remaining reset and fence question on f346d1d11b264fbd0ccbe72e5664e0c7bf9c3bc0. 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 reset](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12commandallocator-reset) [1676f3d](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/1676f3de8a242913f47d745bba1878609f732897) 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](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12fence-getcompletedvalue) 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]>
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 16:00 UTC · original

I updated this branch to current main 67e8ae1401df112248aed36d0024483181b718b7, preserving 1676f3d in its history. The old test still read 0 on da82e44. 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 commit

The 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]

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 16:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2158#issuecomment-7167507175) I updated this branch to current main `67e8ae1401df112248aed36d0024483181b718b7`, preserving `1676f3d` in its history. The old test still read 0 on `da82e44`. 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 commit](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/4803f2b3d38fcbeb446cc2420cabc1f4b854fc8f) The 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]>
Author
Owner

@⁠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::execute rework is unrelated to placed buffers and changes the core submission path. If the bug is shown in the title, a smaller fix fits main: let mirror()/sync_slots make a placed-buffer slot again when its kept buffer is no longer the one view_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.

**@⁠Marvisak** on GitHub · 2026-11-25 22:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2158#issuecomment-7175935186) 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::execute` rework is unrelated to placed buffers and changes the core submission path. If the bug is shown in the title, a smaller fix fits `main`: let `mirror()`/`sync_slots` make a placed-buffer slot again when its kept buffer is no longer the one `view_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.
Author
Owner

@⁠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]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 23:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2158#issuecomment-7177540527) Thanks for suggesting the standalone fence change. #2899 carries that change and the WARP regression at [fde6a92](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/fde6a92694cd5b61891e17ca4100a526384a6e4f) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2158
No description provided.