D3D12.X: unmap a superseded texture only once the work before it is done #2270
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2270
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2270"
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?
@joeypercia on GitHub · 2026-11-25 11:55 UTC · original
joeypercia:d3d12x-held-unmaps→main· +184 −13 · 1 files · 1 commits · openvram::unmap_supersededNULL-maps a placed texture's tiles on the tile-mapping queue the moment a newer placement covers it. Nothing orders that against work already submitted that copies to or samples the texture. Changing a reserved texture's mappings under a copy that's running removes the device on at least one NVIDIA Blackwell card. With the probe, which copies on one queue while the mapping flips to NULL on another:0x887A0006after 1.8 s (Dezmonius).Title runs on #2057 on an RTX 5080 and an RTX 3080 Ti end in a DRED page fault on a live texture inside a run of
CopyTextureRegions (kanade333, dhillonjagdeep650-boop). This race is a cause that fits; whether it's the cause of those runs is not shown yet.Update: on an RTX 5080 (driver 621.40), @kanade333 ran #2057 with and without this PR, two runs each. One run with it was still removed by the same fault (
0x887a0006, DRED page fault at VA0x0inside a run ofCopyTextureRegions), and one without it reached the 420 s limit. So this race isn't, or isn't the only, cause of that in-world fault, and the probe passes on that card with that driver. What this PR fixes is the race the probe shows on the RTX 5070.Now
unmap_supersededputs a mark (a fence signal) on every queue the title submitted to and on XCL's upload queues. The unmap, with the return of the texture's tiles to the pool, waits in a list until the CPU sees every mark done.before_executemakes the ones that are. The mapping queue never waits for a title queue. That is the cycle found in #594: a title queue waiting for work submitted later on another queue, which waits behind the mapping queue. The design is @upipibi's from #594 and the variant @Ali-AbdulHadii ran there. #594 itself (@Abdellah-Khanani) waits on the GPU and conflicts withmainnow. This PR replaces that approach, and I'm happy to close it in favour of an update of #594 if its authors prefer.Part of #1773. Related: #475, #594.
What is in it (
crates/xcl/src/hle/d3d12x/vram.rs, one commit)Pages::mark(a reusable fence per queue),HeldUnmapandPages::release_held.unmap_supersededholds the unmap. If a mark can't be made, the texture stays mapped, as before any unmap.before_executemakes the held unmaps whose marks are done. Their textures are let go of afterPAGESis unlocked, because the last reference's release comes back toforget_pages.remap_if_unmappeddrops a held unmap: the texture never lost its tiles.a_superseded_texture_keeps_its_tiles_until_the_work_before_it_is_done. A title queue's submitted work is held behind a fence. The superseded texture keeps its tiles until that work is done and gets no NULL mapping before then, then the tiles go back. A texture mapped again before its unmap keeps its tiles, and its unmap is dropped. With the unmap made at once (as onmain), the test fails at "no unmap yet".Tested
XCL_ADAPTER=Radeon; Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.8.2502.11; debug for the tests, release for the runs.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4onb7f6b76:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, which fails the same way onmain1a0bbe3on this iGPU (#2115).d32s8_targets_take_their_own_size_of_video_memory, creates its device onEnumAdapters1(0)and ignoresXCL_ADAPTER, as @luckyteagirl and @GustavoEllwanger found. So in the "RDNA2" run it ran on the RTX 4070 Ti again. It has not run on AMD here. @oni-swr ran it on an RX 7800 XT (RDNA3) machine.SKIPPED: RTX 4070 Ti: the wave64 cases of thelower/lower_dxilGPU tests,gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64). RDNA2: the mesh-shader tests. Both:heap_window_out_of_memory_falls_back_to_the_switch_form,pso_measurement_compiles_an_exact_synthetic_record(no Developer Mode),test_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_state, and thelower_dxilf16 / f32 cases the direct backend refuses.Regression run
RTX 4070 Ti (driver 621.40), release builds, 60 s each,
scripts/smoke.ps1 -Game <folder> -Title retail-titleon the newer retail title, one after the other from the same shell with the same settings.main1a0bbe3(this PR's base) and this PR's head (no uncommitted changes):main:
PR:
Not tested
r_null_during_copyqturned into XCL calls, would settle it.title_texturesshadows it).AI use
@kanade333 on GitHub · 2026-11-25 13:12 UTC · original
RTX 5080 16 GB (Blackwell), driver 621.40: two runs with this PR and two without, on #2057's head. One of each was removed and one of each ran to the 420 s limit, so on this card these runs show no difference either way. The probe passes all 13 cases here.
@joeypercia, thanks for the probe and the fix. Numbers below.
Setup: NVIDIA GeForce RTX 5080 16 GB (driver 621.40), AMD Ryzen 9 9950X, 32 GB RAM, Windows 11 Pro 26200, release. Retail title of #505, 1.0.2.1,
XCL_NETWORK=0, scripted A presses.Trees
4df1e6e, unchanged.4df1e6e+ this PR's commitb7f6b76. It applies with one conflict invram::before_execute, wheremainhas since added the heap reclaim of5a515f0. I kept4df1e6e's body and added only this PR's part:release_held(now)underPAGES, and the released textures dropped after the lock.cargo test --release -p xcl --lib -- d3d12x::vram --test-threads=4on it: 12 passed, 0 failed, 1 ignored.Probe (
b39608e, release, one process per case, before the title runs): all 13 complete with no removal. The 10 fixed-mapping cases read every mapped word right and zeros from NULL tiles. The three concurrent cases finish their 20 rounds in 0.4 s (r_null_during_copyq, 1,258 remaps), 0.1 s (r_null_during_direct, 252) and 0.4 s (r_other_tiles_during_copyq, 820). The copies end so fast on this card that the remaps have little time to land in the middle of one, so this does not show the race is harmless here.Title runs, all with
XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_COHERENT_HEAPS=sparse:16 XCL_COHERENT_MB=512 XCL_LOOK_SKIP=1 XCL_WATCH_HOT=0 XCL_DRED=1 XCL_RUN_SECONDS=420, warm caches (all 2,689 compute pipelines built ahead with this driver), one after the other:0x887a0006at 379.3 s0x887a0006at 55.6 sDRED page fault at GPU VA 0x0; allocations there: []; recently freed: [], with the list in flight inside a run ofCopyTextureRegion(breadcrumbs8 8 8 >8 8 8; 6 of 19 and 15 of 39 operations done). On driver 610.88 this morning the same tree's two DRED runs faulted at an address inside a live resource instead (my comment on #2057), also inCopyTextureRegions.+0x221c3c2); I have not looked further.I could not tell from the log whether an unmap was actually held in runs 34 and 35: nothing logs it.
Not tested: more than two runs per tree; this PR on
main; another Blackwell card; whether an unmap was held.AI use: Claude Code (Claude Opus 5.5) built the trees, ran the probe and the title on this machine, and wrote this report.
@luckyteagirl on GitHub · 2026-11-25 13:12 UTC · original
Independent Windows verification of exact PR head
b7f6b760e2ce94f68a05ed7c5aeac0360abac1b0, with a paired owned-title smoke run against its base, main1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6.Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Isolated Cargo targets; clean PR worktree. No game files were copied or attached.GPU regression test:
XCL_ADAPTER=6800M XCL_REQUIRE_GPU=1 XCL_DIRECT_DXIL=1 cargo test --locked -p xcl --lib -j 2 a_superseded_texture_keeps_its_tiles_until_the_work_before_it_is_done -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored. The test emitted D3D12 device/queue/resource and sparse-VRAM setup logs, then completed the held-unmap assertions. This fixture callsEnumAdapters1(0)directly, soXCL_ADAPTERdoes not select its GPU; I did not verify the name of adapter 0. The result is a hardware-adapter test result, not a confirmed RX 6800M result.Release and title regression run:
cargo build --locked --workspace --release -j 2passed on the clean PR head. I ranscripts/smoke.ps1through a process and memory guard for 12 seconds per revision, with the same owned title andXCL_ADAPTER=6800M, default translation mode, and separate fresh data/cache directories. Neither run hit the guard.Main:
PR head:
Limits: These brief startup runs do not establish whether the title exercised the superseded-texture unmap path, and frame counts are not a performance comparison. I did not run the full workspace suite on this PR head; the author reports it separately. The focused fixture's exact GPU identity remains unverified because it hard-codes DXGI adapter 0.
AI use: OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows test and release build, monitored the paired title runs, checked the clean exact head, and drafted this report. No game data was uploaded.
@joeypercia on GitHub · 2026-11-25 13:12 UTC · original
@kanade333 thanks, that's the result that was missing. Run 35 shows the in-world copy fault still happens with this PR, so this race isn't, or isn't the only, cause of it. I've added your runs to the description and narrowed what the PR claims to the race the probe shows on the RTX 5070.
A held unmap isn't logged, as you found. A count of held and released unmaps under
XCL_ACTIVITY=1would answer that. I'll add it as its own diagnostic PR rather than here, so this one's smoke runs stay valid.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@oni-swr on GitHub · 2026-11-25 13:19 UTC · original
AMD RDNA3 (native wave64) test report for exact head
b7f6b760e2ce94f68a05ed7c5aeac0360abac1b0, as pushed (not merged onto currentmain).Tested
cargo build --workspace: oka_superseded_texture_keeps_its_tiles_until_the_work_before_it_is_done: 1 passed;vramfilter: 18 passed, 0 failed, 1 ignoredcargo test --workspace --no-fail-fast -- --test-threads=4: 1250 passed, 1 failed, 46 ignored (summed over all test binaries)1a0bbe3` with `cargo test -p xcl --lib fuzz_validate_and_gpu_1`, so it is pre-existing on RDNA3, not caused by this PR.Not tested
scripts/smoke.ps1regression run (synthetic GPU/unit tests only)main; other GPUs (NVIDIA / Intel / RDNA2 / RDNA4)AI use: Claude Code (Claude Sonnet 5.5) ran the build and tests and wrote this report; the numbers are from the runs above.
@DavidM1911 on GitHub · 2026-11-25 17:05 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@GustavoEllwanger on GitHub · 2026-11-25 13:13 UTC · original · edited 2026-11-25 17:53 UTC
Independent dual-GPU Windows verification on exact PR head
b7f6b760e2ce94f68a05ed7c5aeac0360abac1b0(parent1a0bbe3), including NVIDIA Blackwell hardware.Tested
1.95.0 (59807616e 2026-04-14), DXC1.8.2502.11, debug build.32.0.16.1088):XCL_ADAPTER=5060 cargo test -p xcl --lib hle::d3d12x::vram:: -- --nocapture --test-threads=1: 16 passed, 0 failed, 1 ignored (churn_update_tile_mappings_timing), 0 skipped —a_superseded_texture_keeps_its_tiles_until_the_work_before_it_is_donepassed with no device removal.XCL_ADAPTER=5060 cargo test -p xcl --lib hle::d3d12x:: -- --test-threads=4: 212 passed, 0 failed, 2 ignored, 0 skipped.XCL_ADAPTER=5060 cargo test --workspace -- --test-threads=4: 1251 passed, 0 failed, 46 ignored (27 runtimeSKIPPED: 20 native-wave64 tests on wave32 NVIDIA, 3 per-lane#1426refusals, 2 missing D3D12 debug layer, 1 Developer Mode cache-disable, 1 heap windows).32.0.21042.62):XCL_ADAPTER=Radeon cargo test -p xcl --lib hle::d3d12x::vram:: -- --nocapture --test-threads=1: 16 passed, 0 failed, 1 ignored, 0 skipped (note: the GPU fixtures invram::testsignoredXCL_ADAPTERand ran on adapter 0 / RTX 5060; see correction above).XCL_ADAPTER=Radeon cargo test -p xcl --lib hle::d3d12x:: -- --test-threads=4: 212 passed, 0 failed, 2 ignored, 1 runtimeSKIPPED(passthrough_mesh_stream_accepts_a_triangle_driver_blob: no mesh shaders).Not tested
hle::d3d12x::vram::testsGPU fixtures on AMD RDNA2 (blocked by hard-codedEnumAdapters1(0)in the test fixtures), retail title run (scripts/smoke.ps1), the separate#2057stress probe, full AMD workspace run, Intel GPUs, non-Windows hosts.AI use
b7f6b76, ran the focusedvram/d3d12xsuites plus the full RTX 5060 workspace suite, verified theEnumAdapters1(0)adapter selection invram.rs, and wrote/corrected this report from the raw logs.@Dezmonius on GitHub · 2026-11-25 18:10 UTC · original · edited 2026-11-25 18:15 UTC
RTX 5070 verification of #2270
The PR's added D3D12.X VRAM test passed on this RTX 5070. Both builds stopped presenting during a paired title run before the prologue was visible. The logs recorded DirectStorage request failures and no D3D12 device removal or DRED page fault.
Tested
1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6and PRb7f6b760e2ce94f68a05ed7c5aeac0360abac1b0, built in separate target directories from the commit snapshots without local source changes.cargo test --locked --offline --release -j 4 -p xcl --lib hle::d3d12x::vram::tests:: -- --show-output --test-threads=1. Base: 15 passed, 0 failed, 1 ignored. PR: 16 passed, 0 failed, 1 ignored. The addeda_superseded_texture_keeps_its_tiles_until_the_work_before_it_is_donealso passed in isolation. Both runs ignoredchurn_update_tile_mappings_timing. Neither log reports a GPU skip.sparse:16), and networking disabled. The completed pair ran without scripted controller input.0x0, internal timer (605.1 s)0x0, internal timer (605.5 s)The last saved frames showed a loading illustration on base and a nearly black frame on the PR. The first logged DirectStorage request failure on each was
0x89240009, before its last Present. An earlier attempt per build overlapped a separate Cargo job and was stopped by the harness at its available-RAM floor (base 421.9 s, PR 90.4 s).Not tested
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable in this session) ran the paired comparison, checked the saved VRAM test logs and title-run evidence, and drafted this report.
@bstillbstill on GitHub · 2026-11-25 17:15 UTC · original · edited 2026-11-25 18:46 UTC
Test report on an RTX 3090 Ti (Ampere): no difference from this PR on this card, either on #2057 or on its own
head. On #2057 the retail title's silent
0x887a0005in the world comes at the same time with and without it; onthis PR's own head the title stops presenting within about 2 s of the world load with and without it. Your probe passes here, so the
race doesn't seem to happen on this card.
Setup
runs, debug for the tests.
presses,
XCL_NETWORK=0 XCL_ACTIVITY=1; runs alternated with and without this PR on the same day.1. On #2057 (
4df1e6e+ treybertram06's one-line upload wait from #1452, with and withoutb7f6b76cherry-picked; it conflicts in
vram::before_execute, because #2057 doesn't havemain's newer reclaim code there,so I kept #2057's body and added this PR's two lines,
release_heldunder the lock and the drop after it).XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_LOOK_SKIP=1 XCL_HUGE_PSO_CONCURRENCY=6.0x887a0005)0x80000003. The scene stays grey in all of them.73.6 s and 83.3 s, one freeze at 82 s); here it lasts 33–66 s. Something besides this PR moves that time between
days, so only same-day runs are compared.
2. On this PR's own head (
b7f6b76) against its parentmain(1a0bbe3), both as they are. Thatmainhasno
XCL_UMA_SHADOW, so the coherent window is used in place (as in the 5070 Ti run on #2057).XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_HUGE_PSO_CONCURRENCY=6.main0x887a0007in XCL's queue drain at exit0x887a0006at 162.0 smainVCRUNTIME140.dll, read at0xc491de410)0x887a0006at 106.7 smain0x887a0006at 106.4 sSo on this card the title doesn't get past the world load's first seconds on this base, with or without the PR, and
never reaches the in-world stretch where the copy-fault removal would show.
Tests
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4onb7f6b76:1251 passed, 0 failed, 46 ignored, including
a_superseded_texture_keeps_its_tiles_until_the_work_before_it_is_done. 25SKIPPEDlines: 20 "no wave64", 3per-lane f16 forms refused (
V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32),pso_measurement_compiles_an_exact_synthetic_record(driver cache can't be disabled without Developer Mode),
heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).
cargo test -p xcl --lib hle::d3d12x::vram -- --test-threads=4: 12 passed, 0 failed,1 ignored.
probe/reserved-copy-faultsatb39608e, debug, one process per case as in your loop): all 13cases pass, no removal. Mapped tiles read back right and NULL tiles read 0;
r_null_during_copyq,r_null_during_directandr_other_tiles_during_copyqran all 20 rounds with 20,900 / 24,628 / 15,808 remaps.So the race doesn't remove the device on this card (as on the 3070 and 4070 Ti), which fits this PR changing
nothing in the runs above.
Not tested: this PR merged with the latest
main(it conflicts with68a284a) or in theRTX 5070 Ti stack on #2057; AMD.
AI use: Claude Code (Claude Opus 5.5) built the trees, ran everything above and wrote this report.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.