D3D12.X: reuse the pipeline lookup when binding a stand-in #1708

Open
github-bot wants to merge 1 commit from github-bot/gh-1708 into main AGit
Owner

@⁠CallMeBrado on GitHub · 2026-11-24 19:31 UTC · original
CallMeBrado:perf-reuse-pipeline-on-bind → main · +27 −2 · 1 files · 1 commits · open

A title can bind the same completed pipeline thousands of times. Each bind used to look up its stand-in twice. A compute bind with the default wait policy also locked the job, demand and completion state even when the worker had already published the real pipeline.

What is in it

Bind using the entry from the first lookup. A waiting caller checks the published pipeline pointer after recording first use. A zero pointer still takes the existing wait and failure paths. The new test lets a worker finish before binding and checks that the bind returns its pipeline without requesting a priority boost.

Tested

  • Ryzen 9 9950X3D, RTX 5090, Windows 11 x64, Rust 1.96.0 MSVC.
  • cargo build --locked --workspace --jobs 6 and cargo test --locked --workspace --no-fail-fast --jobs 6 -- --test-threads=4 --show-output passed. 859 reported passed, 0 failed, 42 ignored. The following tests reported a skip on this machine.
    • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64)
    • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)
    • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
    • test_title_draws_with_a_root_signature_under_the_debug_layer (no xgameruntime.dll)

I timed resolve_for_bind in release against 256 already-built stand-ins, with the default wait policy. Each caller cycled through the handles 500,000 times. The numbers are median elapsed time divided by total binds over seven runs per revision, alternating run order.

  • One caller, graphics 39.6 to 20.7 ns, compute 64.5 to 21.4 ns.
  • Four callers, graphics 195.6 to 102.2 ns, compute 205.8 to 102.0 ns.
Reproduce the bind benchmark

The harness uses synthetic pipeline handles and does no GPU work. To run it with Cargo, save it as crates/xcl/examples/bind_cost.rs in a local checkout, leave XCL_PSO_WAIT_MS unset and run cargo run --release -p xcl --example bind_cost -- 1 compute. The first argument is the caller count and the second is compute or graphics. The output is nanoseconds per bind.

use std::{hint::black_box, sync::Barrier, thread, time::Instant};
use xcl::hle::d3d12x::pso_async::{released, resolve_for_bind, resolve_wait, submit_lazy};
fn main() {
    let args: Vec<_> = std::env::args().collect();
    let threads: usize = args[1].parse().unwrap();
    let compute = args[2] == "compute";
    const N: usize = 500_000;
    const FIRST: usize = 0x7E00_0000;
    for i in 0..256 {
        let p = FIRST + i;
        submit_lazy(p, compute, Box::new(move || p + 256), 0);
        assert_eq!(resolve_wait(p), p + 256);
    }
    let start = Barrier::new(threads + 1);
    let finish = Barrier::new(threads + 1);
    let elapsed = thread::scope(|s| {
        for t in 0..threads {
            let (start,finish) = (&start,&finish);
            s.spawn(move || {
                start.wait();
                for i in 0..N {
                    black_box(resolve_for_bind(black_box(FIRST + ((i+t*17)&255))));
                }
                finish.wait();
            });
        }
        let now = Instant::now();
        start.wait();
        finish.wait();
        now.elapsed()
    });
    println!("{:.2}", elapsed.as_nanos() as f64 / (N * threads) as f64);
    for i in 0..256 { assert_eq!(released(FIRST+i), FIRST+i+256); }
}

Regression run

The retail title, 60 seconds per build, separate empty XCL profiles and shader caches, XCL_DXC_THREADS=3.

main

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 763 (PresentX 763)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15322 MB

PR

xcl-smoke v1
commit: 35ec9ebfae008778d7fef2cd8e5a05379e4797aa
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 947 (PresentX 947)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15325 MB

Not tested

Gameplay frame times, world loading and other GPU vendors. Optional retail sample variables were unset for the workspace suite. The benchmark measures CPU bind resolution.

AI use

OpenAI Codex (GPT-6) wrote the change, test and benchmark, ran the checks and drafted this PR.

**@⁠CallMeBrado** on GitHub · 2026-11-24 19:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/1708) `CallMeBrado:perf-reuse-pipeline-on-bind` → `main` · +27 −2 · 1 files · 1 commits · open A title can bind the same completed pipeline thousands of times. Each bind used to look up its stand-in twice. A compute bind with the default wait policy also locked the job, demand and completion state even when the worker had already published the real pipeline. **What is in it** Bind using the entry from the first lookup. A waiting caller checks the published pipeline pointer after recording first use. A zero pointer still takes the existing wait and failure paths. The new test lets a worker finish before binding and checks that the bind returns its pipeline without requesting a priority boost. **Tested** - Ryzen 9 9950X3D, RTX 5090, Windows 11 x64, Rust 1.96.0 MSVC. - `cargo build --locked --workspace --jobs 6` and `cargo test --locked --workspace --no-fail-fast --jobs 6 -- --test-threads=4 --show-output` passed. 859 reported passed, 0 failed, 42 ignored. The following tests reported a skip on this machine. - `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask` (no wave64) - `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware` (no wave64) - `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows) - `test_title_draws_with_a_root_signature_under_the_debug_layer` (no xgameruntime.dll) I timed `resolve_for_bind` in release against 256 already-built stand-ins, with the default wait policy. Each caller cycled through the handles 500,000 times. The numbers are median elapsed time divided by total binds over seven runs per revision, alternating run order. - One caller, graphics 39.6 to 20.7 ns, compute 64.5 to 21.4 ns. - Four callers, graphics 195.6 to 102.2 ns, compute 205.8 to 102.0 ns. <details> <summary>Reproduce the bind benchmark</summary> The harness uses synthetic pipeline handles and does no GPU work. To run it with Cargo, save it as `crates/xcl/examples/bind_cost.rs` in a local checkout, leave `XCL_PSO_WAIT_MS` unset and run `cargo run --release -p xcl --example bind_cost -- 1 compute`. The first argument is the caller count and the second is `compute` or `graphics`. The output is nanoseconds per bind. ```rust use std::{hint::black_box, sync::Barrier, thread, time::Instant}; use xcl::hle::d3d12x::pso_async::{released, resolve_for_bind, resolve_wait, submit_lazy}; fn main() { let args: Vec<_> = std::env::args().collect(); let threads: usize = args[1].parse().unwrap(); let compute = args[2] == "compute"; const N: usize = 500_000; const FIRST: usize = 0x7E00_0000; for i in 0..256 { let p = FIRST + i; submit_lazy(p, compute, Box::new(move || p + 256), 0); assert_eq!(resolve_wait(p), p + 256); } let start = Barrier::new(threads + 1); let finish = Barrier::new(threads + 1); let elapsed = thread::scope(|s| { for t in 0..threads { let (start,finish) = (&start,&finish); s.spawn(move || { start.wait(); for i in 0..N { black_box(resolve_for_bind(black_box(FIRST + ((i+t*17)&255)))); } finish.wait(); }); } let now = Instant::now(); start.wait(); finish.wait(); now.elapsed() }); println!("{:.2}", elapsed.as_nanos() as f64 / (N * threads) as f64); for i in 0..256 { assert_eq!(released(FIRST+i), FIRST+i+256); } } ``` </details> **Regression run** The retail title, 60 seconds per build, separate empty XCL profiles and shader caches, `XCL_DXC_THREADS=3`. main ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: NVIDIA GeForce RTX 5090 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 763 (PresentX 763) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15322 MB ``` PR ``` xcl-smoke v1 commit: 35ec9ebfae008778d7fef2cd8e5a05379e4797aa gpu: NVIDIA GeForce RTX 5090 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 947 (PresentX 947) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 15325 MB ``` **Not tested** Gameplay frame times, world loading and other GPU vendors. Optional retail sample variables were unset for the workspace suite. The benchmark measures CPU bind resolution. **AI use** OpenAI Codex (GPT-6) wrote the change, test and benchmark, ran the checks and drafted this PR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:15 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 22:09 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-24 22:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/1708#issuecomment-7145881630) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 04:25 UTC · original

PR #1708 verification

Clean detached head 35ec9ebfae008778d7fef2cd8e5a05379e4797aa on STOR-WINLAB. Windows 11 Enterprise Evaluation (build 26200), AMD Ryzen 7 3800X, Intel Arc A770 (driver 32.0.101.9175), DXC 1.9.2609.5, rustc 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc). Unoptimized dev/test profiles, with debug info and incremental compilation disabled.

Tested

  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the Arc mutex. Cargo prepared 19 test executables.
  • cargo test -p xcl --lib hle::d3d12x::pso_async::used_tests -- --test-threads=1 outside the mutex with XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1 yielded 6 passed, 0 failed, 0 ignored, and 0 explicit skips.
  • The change is confined to crates/xcl/src/hle/d3d12x/pso_async.rs. Its new test uses synthetic handles to check that binding a completed compute stand-in returns the real pipeline, leaves the demand flag clear, and returns the real handle on release. It also checks the unbounded wait path. Existing tests exercised the wait budget, demand signaling, and preload behavior.
  • Ran cargo test --workspace --no-fail-fast -- --test-threads=4 once inside Invoke-ArcTest.ps1 with XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1. Cargo exited 101. All 20 result lines (19 executables plus doc-tests) sum to 841 passed, 18 failed, and 42 ignored. The new unit test passed in this run too.

Workspace failures and skips

  • The library had 13 CreateComputePipelineState failures (0x80070057) and four assertion failures in FMA, mip sampling, VALU, and wave reductions. The e2e title failed the RSSetDepthBiasX dynamic depth-bias check (blue pixel instead of green).
  • Six SKIPPED lines report two wave64 cases, one tiled-resource tier requirement, one unavailable heap-window case, and two missing D3D12 debug-layer cases. Cargo includes these early returns in the pass count. Sample-backed cases also returned early with the sample variables unset.

Not tested

Matched main run, retail-title smoke, bind performance, or other adapters.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1708-suite.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 04:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1708#issuecomment-7152835256) # PR #1708 verification Clean detached head `35ec9ebfae008778d7fef2cd8e5a05379e4797aa` on STOR-WINLAB. Windows 11 Enterprise Evaluation (build 26200), AMD Ryzen 7 3800X, Intel Arc A770 (driver 32.0.101.9175), DXC 1.9.2609.5, rustc 1.100.0 (`0ef1bc386`, `x86_64-pc-windows-msvc`). Unoptimized dev/test profiles, with debug info and incremental compilation disabled. **Tested** - `cargo build --workspace` and `cargo test --workspace --no-run` both exited 0 outside the Arc mutex. Cargo prepared 19 test executables. - `cargo test -p xcl --lib hle::d3d12x::pso_async::used_tests -- --test-threads=1` outside the mutex with `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1` yielded 6 passed, 0 failed, 0 ignored, and 0 explicit skips. - The change is confined to `crates/xcl/src/hle/d3d12x/pso_async.rs`. Its new test uses synthetic handles to check that binding a completed compute stand-in returns the real pipeline, leaves the demand flag clear, and returns the real handle on release. It also checks the unbounded wait path. Existing tests exercised the wait budget, demand signaling, and preload behavior. - Ran `cargo test --workspace --no-fail-fast -- --test-threads=4` once inside `Invoke-ArcTest.ps1` with `XCL_ADAPTER=A770` and `RUST_TEST_NOCAPTURE=1`. Cargo exited 101. All 20 result lines (19 executables plus doc-tests) sum to 841 passed, 18 failed, and 42 ignored. The new unit test passed in this run too. **Workspace failures and skips** - The library had 13 `CreateComputePipelineState` failures (`0x80070057`) and four assertion failures in FMA, mip sampling, VALU, and wave reductions. The e2e title failed the `RSSetDepthBiasX` dynamic depth-bias check (blue pixel instead of green). - Six `SKIPPED ` lines report two wave64 cases, one tiled-resource tier requirement, one unavailable heap-window case, and two missing D3D12 debug-layer cases. Cargo includes these early returns in the pass count. Sample-backed cases also returned early with the sample variables unset. **Not tested** Matched `main` run, retail-title smoke, bind performance, or other adapters. **AI use** T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1708-suite.log` and published.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/pso_async.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1708/head:github-bot/gh-1708'
git switch 'github-bot/gh-1708'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1708'
git switch 'github-bot/gh-1708'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1708'
git switch 'github-bot/gh-1708'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1708'
git switch 'main'
git merge --squash 'github-bot/gh-1708'
git switch 'main'
git merge --ff-only 'github-bot/gh-1708'
git switch 'main'
git merge 'github-bot/gh-1708'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.