Skip to content

D3D12.X: title texture uploads run on the title's queue and wait for its page mappings - #2558

Open
treybertram06 wants to merge 2 commits into
xcl-dev:mainfrom
treybertram06:title-queue-uploads
Open

treybertram06 wants to merge 2 commits into
xcl-dev:mainfrom
treybertram06:title-queue-uploads

Conversation

@treybertram06

Copy link
Copy Markdown
Contributor

Supersedes #455 (@Cattn). That PR has had no update from its author since 2026-11-24, and it no longer merges into main. This carries its commit forward unchanged in substance, with Cattn's authorship kept, rebased onto current main. It adds the fix for a race the reviews and runs found in it.

Title texture uploads go on the queue of the submit that needs them (ExecuteCommandLists / KickoffX on a DIRECT queue), ahead of the title's lists, instead of on XCL's upload queue followed by a CPU wait (#455's description has the rest). With uploads on the title's queue, nothing made that queue wait for the texture page mappings, which XCL's own upload queue waits for (vram::before_execute). A texture created on another thread after refresh_once's wait, or the levels map_levels_with_texels maps right before the copies, could therefore be copied into tiles whose UpdateTileMappings hadn't run yet on the page queue.

On an RTX 3080 that was a copy-engine write page fault and a hung device in the retail title's world load:

What is in it

  • D3D12.X: title texture uploads run on the submitting queue, without a CPU wait (gpu/texture.rs, hle/d3d12x/title_textures.rs). This is D3D12.X: title texture uploads run on the submitting queue, without a CPU wait #455's commit by Cattn, rebased onto main e1d84b7. The two conflicts in title_textures.rs were with code added on main since. Both sides are kept:
  • D3D12.X: a title-queue texture upload waits for the page mappings first (hle/d3d12x/title_textures.rs, test hooks in hle/d3d12x/vram.rs):
    • submit_on_title_queue calls vram::before_execute first.
    • New test gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it. It records a page mapping, uploads on a title queue, and checks the queue waited for that mapping. Without the wait it fails (waited 0, needed 1).

#455's review points

  • Destination textures not held while an upload is in flight (@upipibi, @ozimchuk). On current main this is covered by late_release. The title's last Release of a resource is held until a fence value signalled on every known title queue (present::known_queues), the sparse queue and the upload queues has been passed. An upload submitted on the title queue before that release is ahead of the fence on the same queue, so the texture can't be destroyed under the copy. This also avoids holding the destinations in InFlight, which @ozimchuk measured breaks placed_title_textures_share_vram_and_preserve_pixels by moving a shadowed placement's reactivation to a later reclaim. I checked this by reading late_release.rs; I didn't add a test of it here.
  • Krashgamer's measurement (the CPU wait is not where the refresh time goes on his 3080) still applies. This PR doesn't claim a speed-up beyond D3D12.X: title texture uploads run on the submitting queue, without a CPU wait #455's.

Tested

Regression run

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3080
title: 4ba6c38e
seconds: 60
exit: 0x0
frames shown: 1559 (PresentX 1559)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14937 MB
xcl-smoke v1
commit: 2dc76ac89461198bc502f26bd6088eed26a3f521
gpu: NVIDIA GeForce RTX 3080
title: 4ba6c38e
seconds: 60
exit: 0x0
frames shown: 1568 (PresentX 1568)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14734 MB

Not tested

AI use

Cattn and others added 2 commits November 25, 2026 13:52
… CPU wait

title_textures::refresh runs on the title's thread before each of its
submits and uploaded the CPU's writes to its textures on XCL's own queue,
then waited on the CPU until the GPU had run them (texture::upload_batch).
While a retail title streams its world with video memory past the card,
those waits are long: thread dumps show its submit thread blocked in
fence::wait under refresh, presents drop to a few per 20 s, and the title's
watchdog ends it on the loading screen.

When the submitting queue is a DIRECT queue on the texture's device, the
upload list now runs on that queue, ahead of the title's lists, so the GPU
orders the copies before the work that samples them, with no cross-queue
wait. A fence on that queue retires each batch's allocator, list and staging
buffers at later submits; over 512 MB in flight the oldest batches are waited
for, and a batch whose wait fails or times out stays in flight. Compute and
copy queues, and a queue of another device, keep the upload queue and its
wait. texture::submit_batch is upload_batch without the wait.
With uploads on the title's queue (the commit before), the copies of a
batch went out on that queue without the wait for texture page mappings
that XCL's own upload queue makes (vram::before_execute). A texture made
on another thread after refresh_once's wait, or its levels mapped just
before the upload by map_levels_with_texels, could then be copied into
tiles whose UpdateTileMappings had not run on the page queue yet.

On an RTX 3080 (driver 621.40) with a retail title that was a copy-engine
write page fault (DmaPageFaultWrite, EngineResetRequired, 4.6 ms before
VidSchErrorHardwarePageFault in a DxgKrnl trace) and a hung device
(0x887a0006 with nvlddmkm 153) in 3 of 4 runs of the world load; with
the wait, 0 of 7.

submit_on_title_queue now waits first, so every title-queue upload does.
The test fails without it (the queue never waits for the mapping).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DarkPanda69

Copy link
Copy Markdown

AMD run (listed as untested) on an RX 9070 XT, plus an RTX 3060: all 3 new GPU tests pass on both cards, with no skips.

Head 2dc76ac applied on main 08db802, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- title_textures --test-threads=4, card chosen with XCL_ADAPTER (the tests take the backend device, real::device_raw()):

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010): 22 passed, 0 failed, 0 SKIPPED. gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released, gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it and gpu_an_upload_still_running_is_kept_when_its_wait_times_out ok.
  • RTX 3060 (driver 32.0.16.1088): 22 passed, 0 failed, 0 SKIPPED; the same 3 tests ok.

Not tested: the whole suite with this PR, Intel, Linux / vkd3d-proton, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

@fromthemoonx

Copy link
Copy Markdown

D3D12 debug-layer check: the three new GPU tests run clean under the layer (only the exit-time live-object report), and the e2e title's messages are the same as main's. It adds the layer to the RTX 3080 / 3060 runs above.

Tested: 2dc76ac merged onto main 08db802 (clean). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, Graphics Tools (D3D12 debug layer) installed.

result
gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released, gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it, gpu_an_upload_still_running_is_kept_when_its_wait_times_out, each with XCL_D3D12_DEBUG=1 (D3D12: debug layer enabled in the output) each passes; no error or corruption messages, only the 8 id 0 live-object lines at process exit
e2e test_title_draws_with_a_root_signature_under_the_debug_layer, merged vs main 08db802 passes on both, the same messages: 3× error id 93, 1× error id 1046, 1× warning id 820, 8× id 0 at exit

The e2e title's log doesn't show whether it takes the title-queue upload path, so the three tests are what checks the new code here.

Not tested: the whole suite (DarkPanda69 and the description cover NVIDIA), a title, a release build.

AI use: Claude Code (Claude Opus 5.5) ran the debug-layer checks and wrote this report.

@KOLESNiii KOLESNiii mentioned this pull request Nov 25, 2026
raylitebull added a commit that referenced this pull request Nov 26, 2026
…queues

Port upstream #2558 adapted to amd-dev's staging pool and low-commit
guards so streaming texture uploads no longer stall ExecuteCommandLists
on synchronous CPU fence waits:
- gpu/texture.rs: extract plan_batch and add submit_batch returning an
  InFlight guard that reuses STAGING_POOLS for <=8 MiB batches (returned
  on GPU completion) and frees oversized staging buffers immediately
- title_textures.rs: submit batches inline on matching DIRECT title
  queues after vram::before_execute(queue), track per-queue in-flight
  batches bounded by 512 MiB (64 MiB under low Windows commit), and
  non-blockingly reclaim completed batches on quiet refresh_once ticks
- vram.rs: add test helpers (note_mapping_for_test, waited_for_test) for
  the #2558 title-queue upload and tile-mapping wait regression tests

Assisted-by: Antigravity (Gemini 4 Neon High)
@luckyteagirl

Copy link
Copy Markdown
Contributor

RX 6800M focused GPU report for #2558: the title-queue upload mapping-wait regression passes on this RDNA2 card.

Setup: clean detached head 2dc76ac89461198bc502f26bd6088eed26a3f521; Windows 11 Home build 26200; Ryzen 9 5980HX; AMD Radeon RX 6800M, driver 30.0.13002.13003; Rust 1.99.0 MSVC, debug lib-test build with its own Cargo target. XCL_ADAPTER=6800M and XCL_REQUIRE_GPU=wave64 were set. The run log confirms backend 'real' – AMD Radeon RX 6800M (11987 MiB VRAM) and the tiled-resource page queue/fence path.

Tested: cargo test --locked -p xcl --lib -j 1 hle::d3d12x::title_textures::tests::gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it -- --exact --test-threads=1 --nocapture, under a free-memory guard: 1 passed, 0 failed, 0 ignored, 0 measured, 1326 filtered out, 0.65 s; no SKIPPED line and no guard stop. The fixture checked that the title queue waited for the mapping-fence value before the upload and completed a 64×64 texture upload/readback.

Limit: The fixture's test helper signals the page-mapping fence but does not itself issue UpdateTileMappings, so this verifies the queue-wait ordering and GPU upload/readback rather than a physical tile-mapping race. I did not run the full suite or a title smoke pair. DXC was configured but this fixture did not compile a shader. No game files were used.

AI use: Codex (GPT-6) and a Codex Luna subagent prepared the clean worktree, ran the guarded focused test, checked the log and source coverage, and wrote this report.

@itsSio

itsSio commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent dual-PC NVIDIA full-workspace test report on clean head 2dc76ac89461198bc502f26bd6088eed26a3f521.

Tested

  • Machine 1: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200.9974, rustc 1.97.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug build
    • cargo build --workspace: exit 0 (1 dead_code warning in vram.rs:1110)
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1426 passed, 0 failed, 46 ignored (all 22 title_textures tests passed)
    • SKIPPED: 26 (wave64-only GPU tests, #1426 wave32 f16/cvt refusals, no heap windows, pso_measurement driver-cache disable 0x887A002D)
  • Machine 2: NVIDIA GeForce RTX 2080 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200.8653, rustc 1.99.1 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC 1.8.2502.11, debug build
    • cargo build --workspace: exit 0 (3 warnings)
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1426 passed, 0 failed, 46 ignored
    • SKIPPED: 29 (same 26 as Machine 1 plus 3 requiring d3d12SDKLayers.dll)

Not tested

  • Retail title / scripts/smoke.ps1 runs
  • Release builds (--release)
  • AMD / Intel GPUs, native wave64, Linux / Wine / vkd3d-proton

AI use
Ran via Samaritan:

  • Google Antigravity CLI (Gemini 4 Hydrogen (High)): built the branch and ran the workspace test suite on both NVIDIA machines.
  • Google Antigravity CLI (Gemini 4 Neon (High)): coordinated the runs and wrote this test report.

@pickles976

Copy link
Copy Markdown

First Wine/NVIDIA verdict for the mapping-wait fixture, now that a diagnostic stack can run it. Head 2dc76ac89461198bc502f26bd6088eed26a3f521, RTX 4060 Laptop GPU 8 GiB, Wine 11.0, NVIDIA 590.48.1, --locked --target x86_64-pc-windows-msvc, one test thread, fresh Compiling xcl .../xcl-pr2558/... provenance.

On stock vkd3d-proton 3.2.0 this fixture aborts before its body: ID3D12Fence1 – 12 PC methods, 10 internal slots under the guard then Assertion failed: iface->lpVtbl == &d3d12_fence_vtbl (vkd3d_private.h:705) — the #175 identity wall, which is why my earlier report could make no pass/fail claim for the GPU leg.

On a relaxed diagnostic build of the exact same provenance commit (2576c0b4adfae4a, -Db_ndebug=true + the two from_iface relaxations described in #175, local-only, not proposed anywhere), gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it passes 1/1 (0.86 s, 0 ignored) on the real adapter: the upload waits for the title queue's page mappings ahead of it and the fixture's readback checks hold.

Scope: this verifies the fixture's own assertions under Wine/vkd3d-proton, not retail title behavior, and the relaxed DLL means the identity checks that stock builds enforce were absent — it removes the abort, it does not validate XCL's vtable patching against a stock runtime. Log: .compat-xcl/logs/verify-pr2558-wine-mapping-wait-relaxed.log (local). AI-assisted verification and report (OpenAI Codex).

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 168 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
The three new upload-queue tests (gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released, gpu_a_title_queue_upload_waits_for_the_page_mappings_before_it, gpu_an_upload_still_running_is_kept_when_its_wait_times_out) ran inside the suite: passed (suite gained 3 passes over main).

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both error branches run after texture::submit_batch() has submitted the upload list. If CreateFence or queue.Signal fails, they call texture::wait(dev, queue)?; that recovery wait can also fail (including its 10-second timeout), so ? returns and drops f without proving the queued copy finished. f owns the staging resource and command allocator used by that copy. Microsoft's D3D12 synchronization guidance requires those objects to remain valid until GPU work is done. Could the retirement fence be established before submission where possible, and could a failed recovery wait retain/quarantine f instead of dropping it? A blocked-queue fault injection (submit, fail fence setup or signal, let recovery time out, then unblock) would cover this path. The normal success path and the new mapping-wait tests do not exercise it.

Exact-head source review of 2dc76ac89461198bc502f26bd6088eed26a3f521; I did not force a device/fence failure or run a title on this head. AI-assisted review with Codex.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
… GPU writeback (port upstream xcl-dev#2470 + xcl-dev#2558 + xcl-dev#2678)

(cherry picked from commit f78556f9601c01eac0e05e43532047658d085701)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
koboshchan pushed a commit to koboshchan/xcl that referenced this pull request Nov 26, 2026
…queues

Port upstream xcl-dev#2558 adapted to amd-dev's staging pool and low-commit
guards so streaming texture uploads no longer stall ExecuteCommandLists
on synchronous CPU fence waits:
- gpu/texture.rs: extract plan_batch and add submit_batch returning an
  InFlight guard that reuses STAGING_POOLS for <=8 MiB batches (returned
  on GPU completion) and frees oversized staging buffers immediately
- title_textures.rs: submit batches inline on matching DIRECT title
  queues after vram::before_execute(queue), track per-queue in-flight
  batches bounded by 512 MiB (64 MiB under low Windows commit), and
  non-blockingly reclaim completed batches on quiet refresh_once ticks
- vram.rs: add test helpers (note_mapping_for_test, waited_for_test) for
  the xcl-dev#2558 title-queue upload and tile-mapping wait regression tests

Assisted-by: Antigravity (Gemini 4 Neon High)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants