Skip to content

GPU: refresh placed buffer tables after backing registration - #2158

Open
andrewpozdnakov7-jpg wants to merge 3 commits into
Marvisak:mainfrom
andrewpozdnakov7-jpg:fix/850-refresh-placed-buffer
Open

andrewpozdnakov7-jpg wants to merge 3 commits into
Marvisak:mainfrom
andrewpozdnakov7-jpg:fix/850-refresh-placed-buffer

Conversation

@andrewpozdnakov7-jpg

Copy link
Copy Markdown

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, make a command-list-owned table for the next dispatch and key it by the current backing. Earlier recorded work retains its original binding.

Verification

On upstream 940d32f, the same WARP regression read 0 from the existing descriptor after buffer registration and 1.25 from a newly created descriptor. With this commit, both read 1.25 through the usual VIctory dispatch and texture readback path.

GPU suite with the regression and diagnostics on WARP went from 146 passed, 1 failed and 2 ignored to 147 passed and 2 ignored. Strict GPU Clippy with diagnostics and staged asset policy passed.

This confirms the placed-buffer readback issue. Correlation with the black cutscene frame remains open.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --features diagnostics --lib placed_buffer_tests — passed on RTX 5090
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (184 files ok)

Clean refresh of placed buffer tables after backing registration with end-to-end GPU test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Placed buffer tables refreshed after backing registration — table-refresh ordering fix; relates to #2120/#2130's buffer copy placement.

RecompLive added a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
A descriptor table is made afresh only when its slot reaches past the host heap. A placed buffer view keeps the same slot, but its backing copy changes once the title registers a resource at that address. Draws that reuse that table then read through the stale loose shadow, so the synthetic read-and-store shader writes zeros.

The table-fresh path now also checks the slot when it holds a placed buffer view: if the copy the view would use now differs from the kept slot, the table is made afresh. The table key hashes the copy buffer too, so two tables with one record but different backing are distinct.

From Marvisak/VIctory#2158 (GPL-3.0-or-later, by andrewpozdnakov7-jpg). Cherry-picked from 1bccc4f. Here, hand_out takes the title bytecode pointers as an extra argument, so the test passes &[]; it skips on this PC, where the runtime reports no SM 6.6 device.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work (one point left). Thanks for f325f85 / f346d1d. Most of the last note is addressed:

  • Persistent slots are now refreshed. HostHeap (descriptor/host.rs) refreshes the placed-buffer slots when an idle heap is bound again after a registration change, driven by shadow::binding_generation. So the temporary-table workaround ends.
  • The per-draw check is narrower. It skips heaps with no placed buffers and looks at the tracked placed-slot set before decoding a view.
  • The test is in a better place. It now lives in draw/placed_buffer_tests.rs and uses writable pool memory.

What still needs fixing is when a heap counts as idle. Each HostList holds a lease (hold_view_heap, an Arc in Deferred::view_heaps) until the list is reset or released. In D3D12, though, a title may reset a command list right after ExecuteCommandLists, while the GPU is still running it. Only the allocator has to wait for the fence. So the lease can be dropped while submitted work still reads the old descriptor. Rewriting that slot then races with the GPU. Please tie the lease to submission completion (the fence or allocator the list was executed with, as Host::execute tracks), not to the list's reset. Or show that HostList reset already waits for the list's last submission.

Not blocking: there is still no frame-time measurement of the remaining per-draw check, and no run linking this to the black cutscene frame in #850. Either would help the maintainer. CI: passing on the previous head. It merges cleanly.


Generated by Claude Code

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.
@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Author

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 940d32f, the existing slot read 0 after registration. On the previous PR head 1bccc4f, 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 andrewpozdnakov7-jpg@users.noreply.github.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants