Skip to content

D3D12.X: prioritize graphics pipelines in the async PSO worker pool - #628

Open
Cattn wants to merge 1 commit into
xcl-dev:mainfrom
Cattn:pso-async-graphics-priority
Open

Cattn wants to merge 1 commit into
xcl-dev:mainfrom
Cattn:pso-async-graphics-priority

Conversation

@Cattn

@Cattn Cattn commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Replace the single FIFO mpsc::channel in pso_async with a two-lane WorkQueue so queued graphics pipelines dequeue ahead of queued compute pipelines on the xcl-pso-* worker pool.

When a retail title transitions into world rendering, it queues hundreds of large compute pipelines (100–490 KB DXIL) ahead of its graphics draw pipelines. With one shared FIFO channel, all xcl-pso-* workers spent tens of seconds compiling compute shaders while every queued graphics pipeline waited behind them (in a local world-loading stack run, 217 compute PSOs finished while 0 graphics PSOs finished over 28 s; with graphics prioritized first, 181 background pipelines built including ~147 graphics PSOs and the title began presenting post-loading world frames). Within each lane (graphics and compute), FIFO order is preserved.

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs: replace the mpsc channel in queue() with WorkQueue<T> (gfx and compute VecDeques, popping gfx before compute) + Pool / enqueue; add unit tests graphics_jobs_dequeue_ahead_of_queued_compute_jobs and worker_pool_prioritizes_graphics_pipeline_over_queued_compute.

Tested

  • Hardware / OS / toolchain: NVIDIA GeForce RTX 4070 12 GB (driver 32.0.16.1742, wave32), AMD Ryzen 7 7800X3D, 32 GB RAM, Windows 11 Pro 10.0.26200, DXC 1.9.2609.5, rustc 1.93.1 (01f6ddf75 2026-02-11), debug (tests) and release (smoke).
  • After the rebase (766b661), cargo build --workspace passed and cargo test -p xcl --lib pso_async -- --nocapture reported 4 passed, 0 failed, 0 ignored and 0 skipped.
  • Before the rebase (ac387a1), cargo build --workspace && cargo test --workspace -- --test-threads=4 reported 688 passed, 0 failed, 41 ignored.
  • SKIPPED GPU tests (2, no wave64 on this adapter): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware.
  • World-loading stack test (local stack with bounded waits + this change): switched from 0 post-loading graphics PSOs / 0 post-loading presents to 181 background PSOs built (~147 graphics) and 3 presented post-loading world frames before hitting an unrelated Wait64BitValueX stall.

Regression run

xcl-smoke v1
commit: f4ce27ceb6d1b0576d0c659b713b674778bf1968
gpu: NVIDIA GeForce RTX 4070
title: 1832dcf3d13e7a13
seconds: 60
exit: 0x0
frames shown: 919 (PresentX 919)
presents per 2 s (last 3): 32 47 58
device removals: 0
crashes: 0
peak commit: 17460 MB
xcl-smoke v1
commit: 766b661235289f8c76b2a4169b046927fa3e8355
gpu: NVIDIA GeForce RTX 4070
title: 1832dcf3d13e7a13
seconds: 60
exit: 0x0
frames shown: 1397 (PresentX 1397)
presents per 2 s (last 3): 48 54 43
device removals: 0
crashes: 0
peak commit: 19705 MB

Not tested

  • AMD / Intel GPUs and native wave64 hardware.
  • Other retail titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant).
  • The 60 s smoke runs check for regressions. The prior world-loading stack run exercised the compute backlog, and the pso_async unit tests cover queue priority.

AI use

  • Antigravity with Gemini 4 Neon: diagnosed the graphics-PSO starvation from local world-loading logs, wrote the WorkQueue priority scheduling and unit tests in pso_async.rs, ran the test suite and smoke runs on the hardware listed above, and drafted this description.
  • Codex (gpt-6.2-sol) resolved the rebase conflict, ran the post-rebase build and focused tests, and refreshed the regression runs and PR description.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of ac387a1af03b187fe6ca7bf330ff7085549d0230 on AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto current main 18c105a locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 691 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 651 passed, 0 failed, 21 ignored
  • 0 SKIPPED; graphics_jobs_dequeue_ahead_of_queued_compute_jobs and worker_pool_prioritizes_graphics_pipeline_over_queued_compute pass.

Review: The two-lane queue is strict priority: while graphics jobs keep arriving, queued compute jobs wait. That cannot hang, since a bind that needs a compute pipeline runs its job itself in resolve_wait when no worker has started it, but under a steady stream of graphics pipelines the compute ones are then built on the binding thread rather than in the background. Worth knowing; not a blocker.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@thehollowedone

Copy link
Copy Markdown

Tested

I ran the same synthetic D3D12 fixture on main at dd2ae9a and that revision with only ac387a1 applied. A gate held the sole pipeline worker while the fixture queued a compute job first and a graphics job second. Each job built a native pipeline, submitted work, and read back the result.

  • Baseline completed compute → graphics.
  • With the patch, the same queue completed graphics → compute. Both runs matched all 256 RGBA32F pixels and the expected compute output word.

cargo test --offline --locked -p xcl --test gpu_queue_check -- --nocapture --test-threads=1 ran the scratch fixture with XCL_DXC_THREADS=1 and XCL_ADAPTER=3080 Ti. Each revision passed 1/1 with no skips. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, DXC 1.8.2502.11, Rust 1.99.1 MSVC, debug.

Not tested

Sustained or multi-worker queue pressure, D3D12 debug-layer messages, and retail loading.

AI use

Codex with GPT-6.2 Sol wrote the scratch fixture, ran the tests, and drafted this report.

Replace the single FIFO channel in pso_async with a two-lane queue so queued graphics draw pipelines dequeue ahead of compute builds instead of starving behind large world-loading compute shaders.

Assisted-by: Antigravity (Gemini 4 Neon)
@Cattn
Cattn force-pushed the pso-async-graphics-priority branch from ac387a1 to 766b661 Compare November 24, 2026 03:58
@mastrr9

mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown

Independent NVIDIA RTX 5080 build/test run and code review at head 766b661235289f8c76b2a4169b046927fa3e8355.

Code Review

  • Clean two-deque WorkQueue split (gfx drained ahead of compute) under a single Mutex + Condvar, with deterministic unit tests covering both queue ordering and worker-pool prioritization. No issues found.

Tested

  • Environment: NVIDIA GeForce RTX 5080 (16 GB, driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09), debug build.
  • Command: cargo build --workspace && cargo test --workspace -- --test-threads=4
  • Result: 703 passed, 0 failed, 41 ignored (0 new warnings).
  • PR-specific tests (all ok):
    • hle::d3d12x::pso_async::tests::graphics_jobs_dequeue_ahead_of_queued_compute_jobs
    • hle::d3d12x::pso_async::tests::worker_pool_prioritizes_graphics_pipeline_over_queued_compute
    • Plus 2/2 existing hle::d3d12x::pso_async::used_tests::* tests.
  • SKIPPED (4):
    • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64)
    • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)
    • test_title_draws_with_a_root_signature_under_the_debug_layer (no d3d12SDKLayers.dll)
    • uploads_start_from_each_subresources_state (no D3D12 debug layer (0x887A002D))

Not tested

  • D3D12 debug layer, AMD/wave64 hardware, and retail titles.

AI use: Antigravity (Gemini 4 Neon) performed the code review, ran the RTX 5080 workspace tests, and drafted this comment.

@raylitebull

Copy link
Copy Markdown
Member

Code/CI review only (not independently runtime-tested by me): clean merge with both checks green (Build and test + PR description). The two-lane graphics-priority queue in pso_async cleanly prevents graphics builds from stalling behind compute backlog. Recommend merging, @ivall (small heads-up: check #690's preload queue() call on current main — it will need updating to enqueue() on merge).

@brainhay5

Copy link
Copy Markdown

Does not build when merged onto current main 47efa2e (merge itself is clean, one file, pso_async.rs):

error[E0425]: cannot find function `queue` in this scope
error: could not compile `xcl` (lib) due to 1 previous error

Looks like a rebase is needed — the call this PR adds does not resolve against what pso_async.rs has on main now.

For context on why it matters to this title: on 47efa2e the async PSO pool never drains. XCL's overlay shows 0 running, 3 done, 57516 pipelines queued at 95 s with a black screen, and xcl-pso-5…xcl-pso-14 are all blocked in a wait. So anything that gets those workers moving is on the critical path for GTA VI.

AI use: OpenCode, DeepSeek V4.1 Flash 1017.

@thehollowedone

Copy link
Copy Markdown

I verified the caller update on a local, uncommitted merge of 766b661 onto 47efa2e. The unresolved call is in resolve_within, the bounded wait path. Replacing let _ = queue().lock().unwrap().send(p.clone()); with enqueue(p.clone()); changed cargo check --offline --locked -p xcl --lib from E0425 to pass.

With the fix, cargo test --offline --locked -p xcl --lib pso_async -- --test-threads=1 passed 6/6. That includes a scratch fixture that occupied the worker pool, called the bounded wait twice on a lazy compute pipeline, then queued a graphics job. Both waits returned the stand-in. When one worker was released, it ran graphics first, then compute, once each. The fixture also passed three isolated runs with the filter scratch_bounded_bind_enqueues_compute_behind_graphics.

Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug. This check covers worker scheduling with synthetic jobs. Driver compile time and retail world loading remain untested here.

AI-assisted. Codex (GPT-6, exact variant unavailable) tested the caller change and drafted this follow-up.

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