D3D12.X / XG: async texture upload, detiling, VRAM, XG ABI, and PSO scheduling improvements #539
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!539
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/539/head"
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?
@JGonzalezRodriguez on GitHub · 2026-11-24 01:34 UTC · original
JGonzalezRodriguez:feat/d3d12x-perf-and-xg-fixes→main· +2645 −154 · 10 files · 16 commits · closed without mergingThis branch bundles D3D12.X performance, scheduling, and
XGABI/correctness fixes targeting heavy streaming and shader-compilation workloads (no Linux/Wine-specific workarounds are included).What is in it
crates/xcl/src/gpu/texture.rs,crates/xcl/src/hle/d3d12x/title_textures.rs,crates/xcl/src/hle/d3d12x/vram.rs,crates/xcl/src/hle/d3d12x/real.rs): per-device asyncUploaderwith fence-ordered consuming-queue waits, reusable mapped staging chunks and allocators, and tracked in-flight destination refs for safe texture release andvram::Pagesordering.xg::CopyFromSubresource7-argument ABI fix & destination span guard (crates/xcl/src/hle/xg.rs,crates/xcl/tests/xg_oracle.rs): handle the extrau32argument beforesrc, bounds-check the destination span, and log invalid arguments.crates/xcl/src/gpu/tiling.rs,crates/xcl/src/hle/d3d12x/title_textures.rs): copy linear mip levels row-by-row, hoist tiled detiling with parallel batch detiling, and cacheLayoutoffset tables viaArcslices while trimming unused high-bit tables.vram::Pagesoverhead reduction (crates/xcl/src/hle/d3d12x/vram.rs): coalesce page-queue fence signals and throttle idle-page sweeps.VirtualQueryspan cache (crates/xcl/src/hle/d3d12x/title_textures.rs): cacheVirtualQuerymemory region spans across sorted entries inrecheck_gpu_view_sources.crates/xcl/src/hle/d3d12x/pso_async.rs,crates/xcl/src/hle/d3d12x/bind.rs,crates/xcl/src/hle/d3d12x/real.rs):BELOW_NORMALpriority;XCL_ASYNC_COMPUTE=1non-blocking compute PSO mode.Wait64BitValueXGPU fence bridge, cycle-breaking, and GPU-completion watchdog (crates/xcl/src/hle/d3d12x/list_x.rs,crates/xcl/src/hle/d3d12x/real.rs):Write64BitValue{Bottom,Top}OfPipeX→Wait64BitValueX(GREATER_EQUAL, full 64-bit mask) onto per-addressID3D12Fencequeue.Signal/queue.Waitcalls, bypass redundant waits when the producer already submitted earlier on the same queue (D3D12 FIFO order), detect and break cross-queue fork-join wait cycles before hoistingqueue.Wait, and monitor armed GPU waits with a bounded GPU-completion watchdog (falling back to bounded CPU polling for non-monotonic or ineligible waits).Wait64BitValueXahead of the producer list on another queue previously stalled the CPU submission thread until timeout or risked cross-queue/unsubmitted-producer deadlocks; moving eligible waits to GPU fences preserves ordering without blocking command submission.Tested
rustc 1.98.1, debug):cargo check -p xcl --target x86_64-pc-windows-msvc --testspassed (0 errors, 0 warnings).list_x::tests: 19/19 passed (includingwrite_buffer_immediate_on_open_existing_heap_visible_to_cpu,cross_queue_wait64_before_signal_does_not_deadlock_submit_thread,cross_queue_cycle_and_same_queue_fifo_do_not_deadlock)vram: 6/6 passedtitle_textures: 9/9 passedgpu::texture: 15/15 passedgpu::tiling: 11/11 passedhle::xg: 4/4 passedbind: 4/4 passedRegression run
scripts/smoke.ps1runs (draft PR for contributor testing; will be split and includemain+ PRxcl-smokeblocks before review).Not tested
scripts/test.ps1(full workspace suite) andscripts/smoke.ps1regression runs (opening as draft for a Windows contributor to test).AI use
@grahamster2 on GitHub · 2026-11-24 02:37 UTC · original
Evidence for the cross-queue
Wait64BitValueXproblem this PR targets, from the retail title that trips #232. Setup: RTX 3080 10 GB, Windows 11, release builds,XCL_NETWORK=0. Counters are given as offsets from one 256-byte block of title memory (baseB).main
9ce2070+ #435, with a local env-gated trace of writes, waits and submits on that block (once the shader cache is warm enough to reach the world, ~80 s):Write64BitValueBottomOfPipeX(B+0x58, 0x613)is recorded on a direct list D1.Wait64BitValueX(B+0x58 >= 0x613)is recorded on a compute list C1. The same pattern repeats for B+0x10, +0x18, +0x68, +0xe8: four more counters, all used for the first time at world start (memory 0). Writers and waiters are on both queue types.execute_with_waits→wait_allblocks that thread on the CPU.This PR (head
4ff33f0, on its own base): the bridge does what it says. At 91.5 s three waits (B+0x58, +0x10, +0xe8 >= 0x6d5, compute waiting on direct producers) became GPUqueue.Waitcalls and the submit thread was not blocked. 1 s later:GPU queue.Wait at B+0x58 >= 0x6d5 did not complete within 1000 ms (waiter_ty=2, prod_ty=Some(0), recorded=0x6d5, submitted=0x6d5, completed=0x0) – released on CPU. The same happened for B+0x68 (producer on the compute queue). The title then crashed at 93 s with the same garbage-data read. A local run with the watchdog raised to 10 s didn't reach this point: the new binary had to retranslate, and the compile backlog tripped #232 first. So that run is inconclusive.Question for you and the maintainer (design): XCL checks every
Wait*BitValueXof a list before the whole list is submitted, but on the console the wait sits where it was recorded. In the trace, one compute list recordswait +0x10,write +0x18,wait +0x68 / +0xe8,write +0xf0, and a direct list waits on+0x18. With the waits moved to the front of the list,+0x18can't be written until+0x68is ready, though on the console it is written before that wait. That can turn a valid console chain into a cycle. It may also explaincompleted=0x0(the other explanation: the GPU really is that slow here, with 12.8 GB of video memory in use on a 10 GB card). Would splitting a list at each recorded wait (close the PC list, continue in a new one,queue.Waitbetween the parts) be the intended direction?Test report written with Claude Code (Claude Opus 5.5) from my own runs; the trace patch is local only.
@alpz1000 on GitHub · 2026-11-24 02:38 UTC · original · edited 2026-11-24 02:40 UTC
Native Windows/NVIDIA test of the draft on RTX 3060 12 GB (driver 610.88 / 32.0.16.1088), Core i5-8400, Windows 11 Home 26200.9974, Rust 1.100.0 x86_64-pc-windows-msvc, MSVC 14.44.35230, debug. Tested the exact PR head as-is against the then-current upstream main (no local merge).
3db536ebe231418d76e8d6e52ccee0b47330a5224ff33f02789f6f6b9748567e45366568f60f13c9cargo build --locked --workspacecargo test --locked -p xcl --lib -- --test-threads=1 --nocapture gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes placed_title_textures_share_vram_and_preserve_pixelscargo test --locked -p xcl --test e2e test_title_runs_and_game_folder_is_untouched -- --exact --nocaptureNo skip messages in these runs. The bundled title reported zero failures and the real RTX 3060 backend on both revisions.
Not tested: full workspace suite, opt-in async compute, retail gameplay/loading, or other adapters.
AI use: OpenAI Codex (GPT-6) ran the local checks and drafted the report.
Follow-up: compute checks with the opt-in flag off and on. Same PR head
4ff33f0and RTX 3060 setup. I rancargo test --locked -p xcl --test gpu_compute_e2e -- --test-threads=1 --nocaptureandcargo test --locked -p xcl --lib async_compute_pso_success_and_failure_in_dispatch_and_execute_indirect -- --nocapturein separate processes withXCL_ASYNC_PSO=1andXCL_ASYNC_COMPUTE=0then1. Both configurations had 2 GPU tests and 1 bind test pass, with zero failures or skips. The GPU integration tests used the real RTX 3060 device and covered cold pipeline resolution and translated compute dispatch/readback. This is compatibility coverage with the setting enabled, with no measurement of pending-dispatch latency or retail loading.@ddm-j on GitHub · 2026-11-24 02:50 UTC · original
Tested the two
xgcommits on Linux (Wine, NVIDIA): the 7-argument ABI fix is right; split out, it would also cover #477.Tested:
ivall/main9ce2070+ #257 (26fdda6) + only this PR's7d1c466(guard dst span) and9c4c3e6(7-argument ABI), cherry-picked without conflict, plus a local log line incopy_from(logging only). Compared with the same base without them, same protocol (300 s, Series X, one A press).Tested
x86_64-pc-windows-gnu.CopyFromSubresourcecalls during world loading arrive with a row pitch that is the low 32 bits of the source pointer (one argument off), so rows land far outside the destination. On an earliermain(a6f5f7a) that ended the run with an access violation in XCL; on9ce2070I compared against a local guard that packs the rows instead.Not tested
scripts/smoke.sh.The two
xgcommits apply cleanly on their own; as a separate PR they would be small and easy to check.AI use
@JGonzalezRodriguez on GitHub · 2026-11-24 03:28 UTC · original
Closing this rollup PR and replacing it with a clean, single-purpose PR against current
main: #684 (XG: fix CopyFromSubresource 7-argument ABI and guard destination span, fixing #477 and the first crash in #662 — thanks @ddm-j for verifying thexgfix independently).Summary of what was dropped from #539:
main:tiling::Layouthigh-coordinate tables → #435.ExecuteIndirectpending-PSO skip gate → #574.vram::Pages→ #490.Wait64BitValueXGPU fence bridge: thanks @grahamster2 for the trace and feedback showing that hoisting all waits to the front of a command list breaks mid-list wait/write interleaving; that needs a dedicated list-splitting design rather than reviving the hoisted-wait patch.vram::Pagesfence signal coalescing, sortedVirtualQueryregion caching inrecheck_gpu_view_sources,BELOW_NORMALPSO worker priority) were intentionally kept out of #684 to follow the one-logical-change-per-PR rule inCONTRIBUTING.md.@crosettiremi on GitHub · 2026-11-24 03:34 UTC · original
RX 7900 XT comparison for the two Wait64 commits (
d419af8d11bcand4ff33f02789f). Windows 11 build 26100, AMD driver 32.0.32029.2010, retail 1.0.2.1, same saved profile, networking off. Both runs used a local stack with #267, #533 and #574, with a 1 ms graphics wait and 4,000 ms compute wait. The comparison adds only the two fence commits to that stack.DXGI_ERROR_DEVICE_HUNG(0x887a0006), and the game hit a breakpoint. Windows recorded LiveKernelEvent 141. I stopped the unresponsive game process after collecting the log.This confirms the bridge executes on RDNA3. I could not determine which GPU command caused the hang or establish that a particular CPU fence release caused it.
AI disclosure: Codex ran the tests and prepared this report.
@artor410 on GitHub · 2026-11-24 03:37 UTC · original
Native Windows test of
4ff33f0(this PR's head, as checked out; not rebased, so this is not the conflict-resolved tree)Tested
cargo build --workspacethencargo test --workspace --no-fail-fast -- --test-threads=4: 688 passed, 1 failed, 41 ignored. SKIPPED (no wave64):gpu_wave32_program_in_wave64_hardware,gpu_geometry_wave32_prefix_count_over_a_mask.e2e::test_title_draws_with_a_root_signature_under_the_debug_layer, comes from my environment, not from this PR: the checkout's path is long, and the test title's overlay and PLS steps fail with os error 3 / 206 (path too long).mainat the merge base508a0c7fails the same test with the same three[FAIL]lines in the same location.list_x,vram,title_textures,gpu::texture,gpu::tiling,hle::xgandbindtests pass natively here, including the new cross-queueWait64ones.Not tested
scripts/smoke.ps1/ any retail title (I have none); AMD and Intel; release build; the tree after resolving this PR's current conflicts withmain.AI use: Claude Code (Claude Opus 5.5) ran the commands above and wrote this report.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175Pull request closed