GPU: keep view_addresses upload buffer alive on command lists #2543
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!2543
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@reeledMarek on GitHub · 2026-11-25 15:33 UTC · original
reeledMarek:fix/gpu-view-addresses-lifetime-and-size→main· +36 −7 · 2 files · 1 commits · openSummary
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.GPU: keep view_addresses upload buffer alive on command lists and size it to HEAP_VIEWSto GPU: keep view_addresses upload buffer alive on command listsb451ae7e6dto5e5dcbc13a@Marvisak on GitHub · 2026-11-25 18:34 UTC · original · edited 2026-11-26 07:22 UTC
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
@reeledMarek on GitHub · 2026-11-26 05:56 UTC · original
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.@fuzeofficlal on GitHub · 2026-11-26 12:21 UTC · original · approved these changes
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.
@Dukestar69 on GitHub · 2026-11-26 18:49 UTC · original · approved these changes
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.