GPU: keep view_addresses upload buffer alive on command lists #2541
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2543"
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 reeledMarek on 2026-11-25T15:33:46Z.
Summary
HostHeap::view_addressespreviously returned only the raw GPU virtual addressu64, so command lists bindingstage.view_addressesnever calledlist.keep(...)on the underlyingID3D12Resource. If theHostHeapis dropped while a command list usingview_addressesis still recording or executing, the GPU reads freed memory.Option<(&ID3D12Resource, u64)>fromHostHeap::view_addresses()and calllist.keep(table)incrates/victory-gpu/src/draw.rsbefore setting the root SRV.main(63bcca4, preserving #1906'saddress_slots()sizing andview_addresses_cover_tables_made_afreshinvariants) and added a COM refcount regression testview_addresses_buffer_stays_alive_on_list.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T18:34:52Z.
Automated triage for the maintainers.
Merge candidate. Narrowed after the rebase, now that #1906 handles
address_slots()sizing inmain.HostHeap::view_addresses(descriptor/host.rs) now returns the table buffer along with its GPU address. InState(draw.rs), the binding ofstage.view_addressescallslist.keep(table)beforeSet*RootShaderResourceView. That matches how the descriptor heaps themselves are kept on the list. The other callers (the warm-up call indraw.rsand a test's.is_some()) still compile unchanged. The refcount test is unusual but test-only.CI:
checkpassing; merges cleanly.Generated by Claude Code
[PR #2543] GPU: keep view_addresses upload buffer alive on command lists and size it to HEAP_VIEWSto [PR #2543] GPU: keep view_addresses upload buffer alive on command listsImported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T05:56:03Z.
Rebased cleanly onto current
main(63bcca4). Since #1906 (2bba792) now handlesaddress_slots()sizing for dynamic tables (and testsdesc.Width == 16 * end), this PR now focuses solely on keeping theview_addressesupload buffer alive on command lists vialist.keep(table). Updated the PR title/description and test accordingly.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T12:21:22Z.
Review: APPROVED
Reviewed and verified at head
5e5dcbc1againstorigin/main(63bcca43) on Windows 11 (RTX 5090 + WARP,VICTORY_D3D12_DEBUG=1):Option<(&ID3D12Resource, u64)>fromHostHeap::view_addresses(crates/victory-gpu/src/descriptor/host.rs:567-590) and callinglist.keep(table)incrates/victory-gpu/src/draw.rs:852-864beforeSetComputeRootShaderResourceView/SetGraphicsRootShaderResourceViewcloses the lifetime gap if aHostHeapis dropped while a command list referencing its view-address table is still recording or executing.view_addressescall site across the workspace (draw.rs:711-714,draw.rs:852-864,descriptor/host.rs:2151):draw.rs:862is the sole GPU binding site and matches the existinglist.keep(table)pattern used atdraw.rs:676, 818.HostList::reset()dropsself.deferred().keptcleanly with no leaks, verified byview_addresses_buffer_stays_alive_on_list(descriptor/host.rs:2467-2493).#2543and#2542have no production-code overlap (only a trivial test-append conflict at the bottom ofcrates/victory-gpu/src/descriptor/host.rs).git merge-treeagainstorigin/main(63bcca43);cargo xtask policy(191 files ok);cargo clippy -p victory-gpu --all-targets -- -D warningsclean with default features and--all-features.view_addresses_buffer_stays_alive_on_list1/1 passed.VICTORY_D3D12_DEBUG=1(--features diagnostics):descriptor::host::tests+draw::tests35/35 passed (skipping pre-existing NVIDIA 1M view-heap capdynamic_slots_are_held_until_released).VICTORY_D3D12_WARP=1) +VICTORY_D3D12_DEBUG=1:descriptor::host::tests+draw::tests36/36 passed.LGTM.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T18:49:10Z.
Review: APPROVED
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).(&ID3D12Resource, u64)fromHostHeap::view_addresses()and callinglist.keep(table)prevents use-after-free on the view-address upload buffer if the title releases the descriptor heap before the recorded command list executes.cargo test -p victory-gpu --lib descriptor::host::tests::view_addresses_buffer_stays_alive_on_list -- --test-threads=1: passed.cargo test -p victory-gpu --lib descriptor::host::tests::view_addresses_cover_tables_made_afresh -- --test-threads=1: passed.cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20 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).
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.