Skip to content

D3D12.X: wait for tiled-texture queues in late_release - #1314

Open
ExoCalibra wants to merge 1 commit into
xcl-dev:mainfrom
ExoCalibra:pr/late-release-vram-queue
Open

ExoCalibra wants to merge 1 commit into
xcl-dev:mainfrom
ExoCalibra:pr/late-release-vram-queue

Conversation

@ExoCalibra

@ExoCalibra ExoCalibra commented Nov 24, 2026 •

Copy link
Copy Markdown

late_release::drain_known waited on title queues, the sparse tile-mapping queue, and title-texture upload queues before running a held resource's final COM Release, but omitted the tiled-texture tile-mapping queues owned by vram::Pages. A released placed texture could therefore reach its final Release while UpdateTileMappings was still in flight on vram::Pages.queue.

What is in it

  • crates/xcl/src/hle/d3d12x/vram.rs: track vram::Pages queues in a separate VRAM_QUEUES mutex and expose vram::queues() so late_release can snapshot them without taking PAGES.
  • crates/xcl/src/hle/d3d12x/late_release.rs: include vram::queues() in drain_known (via drain_queues), and add GPU regression test drain_queues_waits_for_vram_tile_mapping_queue.

Tested

  • Hardware / OS / toolchain: NVIDIA GeForce RTX 3080 Ti (driver 32.0.16.1088), AMD Ryzen 7 7800X3D, Windows 11 Pro Build 26200, rustc 1.100.0 (0ef1bc386 2026-11-09), debug (scripts/test.ps1) + release (cargo build --release -p xcl).
  • .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4): 736 passed, 0 failed, 41 ignored.
  • SKIPPED GPU tests on this adapter: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).

Regression run

Main (67a3735):

xcl-smoke v1
commit: 67a3735177f42cf8e5c886e67a974da7f87541b3
gpu: NVIDIA GeForce RTX 3080 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1084 (PresentX 1084)
presents per 2 s (last 3): 59 59 56
device removals: 0
crashes: 0
peak commit: 16561 MB

PR (7aa9d68):

xcl-smoke v1
commit: 7aa9d68b3fd3918c151ea8f9aa2be7fa3152fbc4
gpu: NVIDIA GeForce RTX 3080 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1216 (PresentX 1216)
presents per 2 s (last 3): 59 60 60
device removals: 0
crashes: 0
peak commit: 15924 MB

Not tested

  • AMD RDNA / wave64 GPUs and Intel GPUs.
  • XCL_SAMPLE_* tests on local sample files (not set).

AI use

  • Antigravity with Gemini 4 Neon: assisted with root-cause analysis, fix, GPU regression test, audit, and PR description. All code, tests, and smoke logs reviewed by the author.

late_release::drain_known waited on title queues, the sparse tile-mapping queue, and title-texture upload queues, but omitted the tiled-texture tile-mapping queues owned by vram::Pages. A released placed texture could reach its final COM Release while UpdateTileMappings was still in flight on vram::Pages.queue.

Record vram::Pages queues in a separate VRAM_QUEUES mutex so late_release can snapshot them without taking PAGES, include them in drain_known via drain_queues, and add a GPU regression test verifying held batches wait until the vram queue passes.
@futurepro62

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 7aa9d68 (on its base 67a3735).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 736 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: drain_queues_waits_for_vram_tile_mapping_queue.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 736 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@JoaoPauluu

Copy link
Copy Markdown

A regression run under Wine on Linux, on a retail title.

Tested

Regression run

main (first run):

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1371 (PresentX 1371)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: 7aa9d68b3fd3918c151ea8f9aa2be7fa3152fbc4
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1359 (PresentX 1359)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

The last main run: 1338 frames, exit: 0x0, no device removal, no crash. Under Wine, peak commit reads 0 MB, so these blocks do not check memory.

Not tested

  • the test suite on this head; native Windows; AMD.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
ivall#1379

Integrate 22 open upstream PRs targeting world rendering, shader correctness, DirectStorage terrain loads, and crash/memory stability:
- ivall#1321 (ivall#1307): fall back to pc blocks when structured CFG HLSL grows oversized (eliminates the 148 MB HLSL / 1 GB/s commit explosion from b8b1f49 so XCL_PSO_PRELOAD=1 stays flat at ~5.4 GiB)
- ivall#549, ivall#1312: DirectStorage late page-array queue hold (fixes 0x89240009 terrain read failures) and 0-byte memory-source requests
- ivall#1365 (ivall#1361): GFX10.30 scratch SADDR 0x7F addresses the immediate offset alone instead of adding v0
- ivall#1368: translated compute PSOs use NodeMask 0
- ivall#1371 (ivall#105): deduplicate packed ISG1 vertex input struct fields
- ivall#1375 (ivall#1360): ES s_setpc_b64 ends block before gs_start
- ivall#1350, ivall#1351, ivall#1352, ivall#1353, ivall#1349: VS layer/viewport outputs, PS sample index/fixed-point position & SV_Coverage, depth+UAV initial states, console SetPredication
- ivall#1305, ivall#1306, ivall#1314, ivall#1319, ivall#1322, ivall#1334, ivall#1339, ivall#1355, ivall#1357, ivall#1379: console_list UMA hold on Release, v_cmp_class_f32 bitwise abs/neg, late_release vram queue wait, root arg clamping, empty BVH / NaN rays, NULL IASetIndexBuffer clearing, MSAA MipLevels=1, VFS lazy-page commits, coherent VirtualFree validation, cpu_writes PAGE_GUARD & stale fence wakeups
- README.md: document the integrated PRs, XCL_PSO_PRELOAD=1, and 16 GiB cap

Verified on RX 9060 XT / GE-Proton11-14: release build clean, targeted unit tests pass (75 passed, 0 failed), and 80 s run with XCL_PSO_PRELOAD=1 and XCL_MEM_LIMIT=12G stays flat at 5340-5413 MB with 512+ pipelines preloaded (1385 frames, exit 0x0).

Assisted-by: Antigravity (Google DeepMind)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…v#1305-xcl-dev#1379

Integrate 22 open upstream PRs targeting world rendering, shader correctness, DirectStorage terrain loads, and crash/memory stability:
- xcl-dev#1321 (xcl-dev#1307): fall back to pc blocks when structured CFG HLSL grows oversized (eliminates the 148 MB HLSL / 1 GB/s commit explosion from b8b1f49 so XCL_PSO_PRELOAD=1 stays flat at ~5.4 GiB)
- xcl-dev#549, xcl-dev#1312: DirectStorage late page-array queue hold (fixes 0x89240009 terrain read failures) and 0-byte memory-source requests
- xcl-dev#1365 (xcl-dev#1361): GFX10.30 scratch SADDR 0x7F addresses the immediate offset alone instead of adding v0
- xcl-dev#1368: translated compute PSOs use NodeMask 0
- xcl-dev#1371 (xcl-dev#105): deduplicate packed ISG1 vertex input struct fields
- xcl-dev#1375 (xcl-dev#1360): ES s_setpc_b64 ends block before gs_start
- xcl-dev#1350, xcl-dev#1351, xcl-dev#1352, xcl-dev#1353, xcl-dev#1349: VS layer/viewport outputs, PS sample index/fixed-point position & SV_Coverage, depth+UAV initial states, console SetPredication
- xcl-dev#1305, xcl-dev#1306, xcl-dev#1314, xcl-dev#1319, xcl-dev#1322, xcl-dev#1334, xcl-dev#1339, xcl-dev#1355, xcl-dev#1357, xcl-dev#1379: console_list UMA hold on Release, v_cmp_class_f32 bitwise abs/neg, late_release vram queue wait, root arg clamping, empty BVH / NaN rays, NULL IASetIndexBuffer clearing, MSAA MipLevels=1, VFS lazy-page commits, coherent VirtualFree validation, cpu_writes PAGE_GUARD & stale fence wakeups
- README.md: document the integrated PRs, XCL_PSO_PRELOAD=1, and 16 GiB cap

Verified on RX 9060 XT / GE-Proton11-14: release build clean, targeted unit tests pass (75 passed, 0 failed), and 80 s run with XCL_PSO_PRELOAD=1 and XCL_MEM_LIMIT=12G stays flat at 5340-5413 MB with 512+ pipelines preloaded (1385 frames, exit 0x0).

Assisted-by: Antigravity (Google DeepMind)
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, ~21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified main.)

Thanks!

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

@safesearch77

Copy link
Copy Markdown

I checked this against current main (b49be183). The bug is still there, and the fix is still needed.

On main, late_release::drain_known (late_release.rs:131-139) fences the title's queues, sparse::queue() and the upload queues, but not vram::Pages::queue. Paths that queue UpdateTileMappings on that queue for a resource the title can then release:

  • unmap_superseded → Pages::unmap (vram.rs:1036-1056, :727-748).
  • bind / remap_if_unmapped / map_levels.

A title queue is ordered after those mappings only at its next before_execute Wait (vram.rs:1207-1214). So a mapping queued after a queue's last Wait is not covered by the fence values late_release signals.

The vram.rs hunk no longer applies (Pages::new is at vram.rs:618-650 now, with a SetName call). Rebased, it is:

@@ -627,6 +627,7 @@ impl Pages {
         let queue: ID3D12CommandQueue = dev.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC::default()).ok()?;
         let _ = queue.SetName(windows::core::w!("xcl vram tile-mapping queue"));
         let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).ok()?;
+        VRAM_QUEUES.lock().unwrap().push(SendQueue(queue.clone()));

and the SendQueue / VRAM_QUEUES / queues() block unchanged, e.g. right after forget_pages. The late_release.rs part applies as is. With that, cargo check --workspace --tests (x86_64-pc-windows-gnu) is clean apart from the 3 warnings main already has.

Smaller points:

  • SendQueue and its unsafe impl Send are not needed. ID3D12CommandQueue is already Send: sparse.rs:416 keeps one in static QUEUE: Mutex<Option<ID3D12CommandQueue>>. Mutex<Vec<ID3D12CommandQueue>> removes one unsafe impl.
  • Keeping the queues out of PAGES is the right design. It is the same reason as sparse::QUEUE (sparse.rs:410-416): a last Release can come from inside a D3D12 call while a holder of the state lock waits for that call. Taking PAGES in queues() could deadlock the same way. The lock order is only PAGES → VRAM_QUEUES (the push in Pages::new runs under PAGES, vram.rs:981), and queues() takes VRAM_QUEUES alone, so there is no cycle.
  • The test skips with "tiled tier < 2" and "no reserved textures". CONTRIBUTING and runner::skip_test list no GPU / no DXC / no wave64 / no mesh shaders. With XCL_REQUIRE_GPU=wave64, either of these other skips is turned into a failure (runner.rs:626-633).
  • VRAM_TEST_LOCK.lock().unwrap(): most other vram tests (vram.rs:1700/1862/1965/2073, title_textures.rs:1528/1968) use unwrap_or_else(|e| e.into_inner()), so one failed vram test does not make this one fail too.

I also checked Held::drain's fence map for dead queues and its "one failed Signal keeps the batch open" path. Neither is a bug on main, so I am not asking for changes there:

  • Every queue it sees lives for the whole process. present::note_execute AddRefs title queues and never releases them (present.rs:292-314). The upload, sparse and tile-mapping queues are never dropped. So the map has no dead queues, and no address can be reused for a new queue.
  • Signal fails in practice only on device removal (or E_OUTOFMEMORY), and all these queues are on the title's device.

If #1691 (which releases queues) lands, its forget_queue handles the fence map.

AI use: Antigravity (Claude Opus 5.5) helped trace the paths and rebase the hunk. I checked each point myself against b49be183.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants