Skip to content

D3D12.X: optional graphics-only pipeline preloading - #828

Open
Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:contrib/graphics-only-preload
Open

Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:contrib/graphics-only-preload

Conversation

@Prime1997

@Prime1997 Prime1997 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds XCL_PSO_PRELOAD=graphics as an optional admission policy for #690. Remembered graphics pipelines remain eligible for preloading; compute pipelines keep their required first-bind build and wait. Unset, 1, 0, and unrecognized values retain their previous behavior.

This PR is ready for review. Our two Windows suite runs reproduced the cubemap assertion tracked in #718. The failures and isolated reruns are recorded under Tested.

What is in it

  • pso_async.rs: filter pipeline type before starting/enqueueing preload workers; preserve pending-job ownership. A scheduling regression checks five settings in fresh processes, nonzero real-result selection at first use and exact-once completion.
  • README documents the option. Authored on official e50836b; cleanly mergeable with checked main beaa245.

Tested

  • Windows 11 build 26200, Intel Core i5-10400, RTX 3060 Ti, driver 32.0.16.1714, Rust 1.100.0 MSVC. One Cargo build job; debug tests, release startup runs.
  • Focused hle::d3d12x::pso_async::used_tests: 3 passed, 0 failed, 0 ignored on identical source immediately before b1530ac was committed. These scheduling cases also passed in both exact-head full runs.
  • Clean b1530ac5454469703db46e3c6366b6264486684e: cargo build --locked --workspace, cargo test --locked --workspace --no-run and cargo build --locked --release --workspace passed, with fresh synthetic title/DLL fixtures and the packaged DXC pair.
  • cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture: 702 passed, 3 failed, 41 ignored, twice with unchanged source/settings. Both hit placed_title_textures_share_vram_and_preserve_pixels at the cubemap reuse assertion, then PoisonError in transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory. Each exact failing case passed 1/0/0 in a fresh isolated process. Both full attempts explicitly skipped gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware because this adapter has no wave64. Optional samples/XG oracle were unset.
  • Separate candidate-only feature check: 90-second title limit, graphics, DXC threads 2, private clone of an earlier 196-set history, hidden desktop, verified hard job-memory backstop and no input. Actual report: exit 0, no crash/removal/OOM/guard stop, 542 presents, 15,462 MiB sampled peak process commit. Two preload threads logged graphics PSO successes and at least 512 completed preload jobs; that counter includes refusals (40 known MS-in-AS translation refusals), not 512 successful PSOs. One compute PSO built on another thread, none logged on the observed preload threads. Frame 500 had a readable Account Picker/Player 1 footer over a uniform dark background.

Independent hardware results

  • On an RTX 3080 Ti, thehollowedone compared graphics-only and full preloading. Both produced all 1,536 expected compute readback values. Hardware check
  • On an RTX 3060 12 GB, Anon64 reached world loading at about 55 seconds in both runs. Both ended at the title's watchdog, at 116 seconds on main and 104 seconds with graphics-only preloading. Each setting was tested once. Loading comparison

Regression run

Two fresh 60-second runs of the same title, each on a unique non-input Win32 desktop, offline, no input, distinct initially empty XCL data/DXIL caches, and the same adapter/DXC pair. Defaults were used; the feature check above is separate. Vendor/OS caches were not reset. Presentation counts are used only for the startup threshold.

Baseline:

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 295 (PresentX 295)
presents per 2 s (last 3): 13 13 13
device removals: 0
crashes: 0
peak commit: 15393 MB

Candidate:

xcl-smoke v1
commit: b1530ac5454469703db46e3c6366b6264486684e
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 286 (PresentX 287)
presents per 2 s (last 3): 13 13 12
device removals: 0
crashes: 0
peak commit: 15371 MB

Not tested

AI use

  • OpenAI Codex (GPT-6; exact model variant unavailable in this agent context): implementation, tests, independent source review, actual local validation, and description. The counts and observations above came from the named runs.

I use a temporary Discord to coordinate my work. Anyone helping test XCL or compare results is welcome. Test coordination on Discord

XCL_PSO_PRELOAD=graphics keeps remembered graphics pipelines eligible for
preloading while compute pipelines retain their ordinary first-bind build
and wait. Unset, 1, 0 and unrecognized values retain their existing behavior.
The existing queues, workers and exact-once job ownership are unchanged.

Extend xcl-dev#690 with an opt-in admission policy, not a default or dispatch change.
The CPU scheduling regression runs five policy values in fresh processes and
checks actual remembered graphics/compute submission and real-value selection.

Assisted-by: OpenAI Codex (GPT-6; exact model variant unavailable)
@Anon64

Anon64 commented Nov 24, 2026

Copy link
Copy Markdown

Regression runs for this PR's head b1530ac and for its base main e50836b, on a retail title (same title, 60 s each), made with scripts/smoke.ps1 (release, clean tree at each commit) and pasted unedited, for Regression run.

main:

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16639 MB

this PR:

xcl-smoke v1
commit: b1530ac5454469703db46e3c6366b6264486684e
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1642 (PresentX 1642)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16713 MB

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 581.80, wave32), Intel Core i9-14900KF, Windows 11 25H2 26200.9974, Rust 1.90.0

Not tested

  • the unit tests on this machine
  • XCL_PSO_PRELOAD=graphics itself: these runs use the default, which this PR leaves as it was (a world-loading run with graphics follows separately)

Report written with Claude Code (Claude Opus 5.5) from runs on this machine.

@Anon64

Anon64 commented Nov 24, 2026

Copy link
Copy Markdown

World-loading run with XCL_PSO_PRELOAD=graphics, for the mode itself (the smoke runs above use the default). This PR's head b1530ac merged onto main beaa245 (clean merge), release, XCL_NETWORK=0, A pressed every 4 s from 20 s (XCL_PRESS_A_AT), warm caches, same RTX 3060 12 GB as above. One run each, so a difference of a few seconds is within what these runs vary by.

main beaa245 + this PR, XCL_PSO_PRELOAD=graphics
world loading from ~55 s ~55 s
frames stop ~90 s ~80 s
title's watchdog (+0x23cf683) 116 s 104 s
Wait64BitValueX timeouts 0 0
slowest compute pipeline build 526 KB DXIL, 20.7 s 508 KB DXIL, 7.9 s
video memory at the end (12 GB card) 14.1 GB 14.2 GB

So on this machine graphics-only preloading does not get the title further. For context: thread dumps on #754 (my comment there) show the title's threads blocked in resolve_wait on a compute pipeline both with the build-ahead threads holding it and with preloading off, so leaving compute out of the preload moves which thread builds the pipeline but not that the title waits for it.

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

@thehollowedone

Copy link
Copy Markdown

Native D3D12 check

I tested b1530ac applied to beaa245 on Windows 11 build 26300, RTX 3080 Ti / 621.35, DXC 1.8.2502.11, Rust 1.99.1 MSVC, release. The policy source matched the PR head exactly.

I extended the stock wave64 compute readback fixture to seed one remembered compute shader with a cold DXIL cache. With XCL_PSO_PRELOAD=1, the preload worker completed its pipeline before the first bind. With graphics, the pipeline was still pending at bind and that bind resolved it. Both modes built one real pipeline and matched all 1,536 expected GPU readback values. Each mode passed 1/1. The stock used_tests passed 3/3. Zero failures, ignores or skips.

cargo test --release --offline --locked -p xcl --lib hle::d3d12x::pso_async::used_tests -- --nocapture --test-threads=1
cargo test --release --offline --locked -p xcl --test gpu_compute_e2e console_wave64_compute_through_the_pso_hook_dispatch_and_read_back -- --exact --nocapture --test-threads=1

This checks the compute dispatch contract on hardware. It leaves the world-loading performance question open.

AI use
Codex (GPT-6, exact variant unavailable) extended the scratch fixture, ran the tests and drafted this report.

@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@beaa245:

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
exit 0

All green: the graphics-only pipeline preload builds and runs, the workspace has no new failure against main on this box (737 passed there), and nothing else changes verdict. Restored the tree afterwards; no game data, hardware adapter, no Wine.

AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head b1530ac onto main a1672ef, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 705 passed, 11 failed, 41 ignored. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Graphics-only pipeline preloading tests green; no new failures.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. Linux rows: #42 / #718.

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

@Prime1997

Copy link
Copy Markdown
Contributor Author

I'm gunna push this for ready to review as I want to know what others think as well.

Even if we passed this for others to test, I want to know what the main reviewers think.

-Prime.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA test of b1530ac on main 09940bb, 6 alternated runs of 100 s: with the default preload the title's burst of pipeline creation after its loading screen starts crawled in 3 of 3 runs and it never reached its world load; with XCL_PSO_PRELOAD=graphics it was normal in 3 of 3. Under Wine this switch is the difference between reaching the world load and not, and below is why.

Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, VKD3D_CONFIG=ignore_shared_fence. RTX 4070 12 GB (driver 615.71.09, 32-lane waves), Ryzen 9 9950X3D, 64 GB RAM. Release, cross-compiled to x86_64-pc-windows-gnu (rustc 1.98.0), DXC 1.9.2609.5, XCL_NETWORK=0. Retail title 1.0.2.1, the first-run screens completed once and no story progress, one A press at 44.8 s through XCL_PRESS_AT. used-pipelines.txt held 1,131 shader sets from earlier runs that had reached the world load. b1530ac merged onto 09940bb without conflicts; it conflicts with main since #891 was merged.

Tested

  • cargo test --release -p xcl --lib preload_policy under Wine, on the merge: 1 passed, 0 failed.
default, run 1 / 2 / 3 XCL_PSO_PRELOAD=graphics, run 1 / 2 / 3
[SHADER] lines from 60 s to 80 s 1,009 / 1,231 / 2 10,465 / 10,465 / 10,468
DirectStorage requests from 70 s to 100 s 93 / 1,032 / 1,815 51,231 / 49,340 / 62,198
presents from 80 s to 100 s 570 / 583 / 580 (the loading pictures, 29 fps) 68 / 118 / 113 (the world loading)
compute builds of 5 s or more before 100 s 1 / 2 / 1 (14 s to 83 s long, 568 KB to 1.4 MB of DXIL) 0 / 0 / 0
compute PSO with the translated console CS lines 365 / 367 / 370 8 / 8 / 15
pipelines built ahead (last count logged) 1,024 / 1,024 / 1,024 1,024 / 1,024 / 1,024

Run 3 with graphics ended at 98.2 s in the copy_from fault of #662 (msvcrt.dll+0xa4f9), which #684 fixes and this tree does not have; the default runs never got that far. XCL_PSO_PRELOAD=0 on 09940bb without this change was also normal in 3 of 3 runs (10,465 lines each), so graphics keeps the graphics preload at no cost seen here.

Why the default crawls under Wine (thread dumps at 90 s and 110 s of a slow default run on main beaa245 + #684; ntdll.dll frames named with nm on Wine's ntdll.dll)

title, 5 threads:  RtlEnterCriticalSection < RtlFreeHeap < RtlReAllocateHeap < RawVec<rdna2::Decoded>::grow_one < gpu::xbox::parse < real::translated_mesh_stream < dxc::cached_only < real::dev_create_pipeline_state < game+0x2479a8d
                   RtlEnterCriticalSection < RtlAllocateHeap < gpu::rdna2::decode < gpu::xbox::parse < gpu::shader::capture < null::capture_stream_desc < real::dev_create_pipeline_state
xcl-dxc-0:         RtlEnterCriticalSection < RtlAllocateHeap < combase.dll+0x181f6 < dxcompiler.dll+0xdb83e < …           (the same in both dumps, 20 s apart)
xcl-pso-pre-2:     dxc::compile < dxc::compile_cached_in < pso::console_to_dxil_in < real::translated_compute_pso < real::build_compute      (waits for that compile)

The preload worker is building a remembered compute pipeline whose DXIL is not in the cache, and DXC takes 23 to 50 s for these programs, allocating from the process heap all the while. The title's five pipeline-creation threads allocate from the same heap as XCL parses each shader, and under Wine that heap has one critical section for these sizes. Sampled 40 times over 2 s in another slow run, each of the five used 14 to 18% of a core and was in a futex wait in about 70% of the samples.

Read

Not tested: past 100 s; this switch together with #684 and XCL_PSO_WAIT_MS; native Windows; Proton's Wine; the rest of the test suite; AMD and Intel.

AI use: Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the title with XCL_PRESS_AT, took the thread dumps and samples, named the frames and wrote this report.

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.

6 participants