D3D12.X: an allocator put aside keeps its recordings' memory (#1358) #1412
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1422"
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 ivall/xcl. Originally posted by venglov on 2026-11-24T15:47:54Z.
Fixes #1358.
When the title resets a command allocator while the GPU still runs what was recorded on it,
alloc_pool(#897) puts that PC allocator aside and returnsS_OK.real::alloc_resettook theS_OKas "the GPU is done" and freed every unified-memory block that ended recordings had filed under the title's allocator: root argument tables, io andAllocateUploadMemoryblocks. Coherent blocks go back on the pool's LIFO stack, so the next translated draw can take one and write over arguments a submitted draw has not read yet; sparse ones are decommitted. #897 counted 240 such swaps in 60 s of a retail title's world. Filing the blocks under the title's allocator could not work either: since #897 it stands for PC allocators that change, so no one Reset could tell whether the GPU was done with all of them.Now a recording's blocks are filed under the PC allocator it is on, and
alloc_poolgives a PC allocator's blocks back at the title's Reset once the GPU has passed every submit on it (whether it is in use, was reset or was put aside).What is in it
One commit:
alloc_pool.rs:title_resetgives back the blocks of the title allocator's PC allocators whose submits the GPU has passed (done_with,Backing::idle); a PC allocator made here gives its blocks back when it is released. Testsended_recordings_keep_their_memory_until_the_gpu_passes_their_allocator(CPU) anda_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_reads(D3D12 device, through theResethook, with the queue held on a fence).real.rs:alloc_resetfrees the blocks itself only when it reset the title's allocator itself.list_x.rs:reset_x, the Wait64 mid-list split and KickoffX's split givebindthe PC allocator the new recording is on. Testa_recordings_memory_is_held_for_the_pc_allocator_it_is_on(CPU).bind.rs,console_list.rs: doc comments only.Tested
No Windows machine here: Apple M1 Pro, macOS 27.2, Wine 11.21 (Gcenx build) with Wine's D3D12 on MoltenVK 1.4.0, under Rosetta 2. Rust 1.100.0,
x86_64-pc-windows-gnu(mingw-w64 14.0.0), debug. Every test binary ofcargo test --workspace --no-runrun under Wine with--test-threads=1(with 4 threads the lib test binary exits with status 5 a few seconds in, onmaintoo).7901856: 745 passed, 9 failed, 41 ignored; SKIPPED: 89no GPU, 5no DXCmain,930e8b4: 742 passed, 9 failed, 41 ignored; the same skipsdisk_free_space_ex_reports_pls_quota,test_title_runs_and_game_folder_is_untouched,readable_answers_from_the_working_set_without_touching_pages,timestamps_outside_unified_memory_land_after_the_queue,write_buffer_immediate_on_open_existing_heap_visible_to_cpu,a_tile_decommitted_and_committed_again_keeps_its_video_memory,ensure_mapped_with_query_holes_skips_uncommitted_pages_on_readback,d32s8_targets_take_their_own_size_of_video_memory,reset_dxgi_device_manager_with_d3d12_device_and_token_validationreal.rsandlist_x.rsput back as onmain: the device test finds the blocks freed at the swap (left: []) and thelist_xtest finds the recording filed under the title's allocator. The CPU test inalloc_pool.rscallstitle_reset_withdirectly, so it fails only iftitle_resetalso frees the title allocator's blocks on success, asalloc_resetdid.main06c9f55(no conflicts; #1452's stand-in list for a Reset while the last submit runs goes throughreset_pc, which files the recording under the PC allocator it is on here as well): 1162 passed, 106 failed, 46 ignored;main06c9f55: 1159 passed, 106 failed, 46 ignored; the same 106 fail on both (Wine / MoltenVK; 86 of them aregpu::dxiltests, the rest include the 9 listed above). SKIPPED on both: 124no GPU, 23no GPU with 32-lane waves, 12no DXC, 6no wave32 GPU, 5Invalid parameter. (0x80070057), 2no GPU UMA, 1no GPU / DXC / mesh shaders, 1no d3d12SDKLayers.dll, 1no D3D12 debug layer, 1validator 0.0 < 1.87901856: 754 passed, 0 failed, 41 ignored, and the device test fails without thereal.rs/list_x.rschanges (report); RTX 3070, merged ontomain568e7db: 1156 passed, 1 failed (the end-to-end test: its title was not built), 46 ignored, the same asmain(report)Regression run
Run by Toons29 on a Radeon RX 9070 (RDNA4), release, 60 s of the retail title with
XCL_NETWORK=0; the blocks are copied from their comment as posted. 101 % ofmain's frames, 100 % of its peak commit, no crash, no device removal. It does not show whether the title reached the put-aside path.Not tested
XCL_CONSOLE_LISTS=1: its lists are not tracked byalloc_pool, so its allocators are never put aside; unchanged.alloc_pool, as before (#1071 registers them).AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by ySKELLETONX on 2026-11-24T16:00:03Z.
Test report on head
7901856, on Windows with a GPU (the description has Wine / MoltenVK only). AI-written (Claude Code, Claude Opus 5.5) from real runs; checked by me.Tested
stable-x86_64-pc-windows-msvc), debug build, DXC from Windows SDK 10.0.26100scripts/test.ps1(cargo test --workspace -- --test-threads=4): 754 passed, 0 failed, 41 ignored; noSKIPPEDlines (so the 9 Wine failures and theno GPU/no DXCskips in the description do not occur here)a_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_readsran on the D3D12 device (not skipped).real.rsandlist_x.rsput back as on the base930e8b4(alloc_pool.rskept as in this PR):a_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_readsfails at alloc_pool.rs:530,the memory of a recording the GPU had not run is held over the Reset(left: []).ended_recordings_keep_their_memory_until_the_gpu_passes_their_allocatorpasses in that state, since it callstitle_reset_withdirectly, not throughalloc_reset; I did not also maketitle_resetfree on success as the description did.Not tested
XCL_CONSOLE_LISTS=1; any retail title (no smoke runs).Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T17:21:24Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
upstream-sync referenced this pull request2026-11-24 19:06:45 +00:00
Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:29:58Z.
Regression run of
79018563on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T07:47:29Z.
NVIDIA test report for
7901856(part of #2057's stack). RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug. The PR is merged ontomain568e7db, withmainrun as a control on the same machine the same hour.cargo test --workspace --no-fail-fast -- --test-threads=4: 1156 passed, 1 failed, 46 ignored.main568e7db: 1153 passed, 1 failed, 46 ignored.test_title_runs_and_game_folder_is_untouchedin both, because my build step ran onlycargo build --workspace --tests, soxcl_testtitle.exeandtestgame_mw.dll, built from the repository'stests/testtitle, were missing (the panic says "build first: cargo build --workspace"). So the end-to-end test did not run here.no wave64(20), pluscannot disable the driver cacheandno heap windows.Added 16:35Z: whole workspace on this head, after
cargo build --workspace, so the test title is built this time. Head7901856as is (base930e8b4), RTX 3070 (616.56), Windows 11, debug,cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2:7901856: 745 passed, 0 failed, 41 ignored. The end-to-end title tests pass.main0829441on the same machine, same command: 1263 passed, 0 failed, 46 ignored (the PR's base is older, so it has fewer tests).hle::xaudio2, because its tests fail or hang on this machine onmaintoo. The PR doesn't touch it (its files are all inhle/d3d12x).no wave64on this card.AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:42:07Z.
Triage (#1607) – head
7901856This commit is already on main as
8d48907c("D3D12.X: an allocator put aside keeps its recordings' memory (#1358)", merged with #3203). The diff is identical except that main'sBacking::idlecallsreal::fence_completedinstead ofGetCompletedValue.The amd-dev drafts that share these lines (#3111, #3112, #3335, #3361, #3099) carry it as part of their base.
Recommendation: close (superseded by main commit
8d48907).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:45:44Z.
Closing as superseded: this change is already on
main(8d48907c). main8d48907c'an allocator put aside keeps its recordings memory (#1358)' (via #3203) has the same 197 added lines except fence_completed(f) instead of f.GetCompletedValue() in Backing::idleTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed