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

Closed
CallMeBrado wants to merge 1 commit from upstream-pr/1708 into main
CallMeBrado commented 2026-11-24 19:31:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CallMeBrado on 2026-11-24T19:31:00Z.


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.

<!-- greyfinch-sync:ivall/xcl:issue:5478924341 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1708). Originally posted by [CallMeBrado](https://github.com/CallMeBrado) on 2026-11-24T19:31:00Z. --- 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.
DavidM1911 commented 2026-11-24 23:08:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T22:09:39Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7145881630 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1708#issuecomment-7145881630). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T22:09:39Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
JJAutoCompare commented 2026-11-25 05:08:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T04:25:51Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7152835256 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1708#issuecomment-7152835256). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T04:25:51Z. --- # 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.
github-actions[bot] commented 2026-11-28 20:17:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:17:47Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7245181671 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1708#issuecomment-7245181671). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T20:17:47Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 06:32:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:32:51Z.


Triage (#1607) – head 35ec9eb

This change is on main as commit 4e59a81 ("D3D12.X: reuse pending pipeline entries on bind", merged with #2959), which says it was adapted from this PR. resolve_for_bind now resolves through the entry from its first lookup (resolve_pending / resolve_wait_pending), returns the real pipeline once build.real is set, and has the test binding_a_completed_compute_pipeline_neither_relooks_it_up_nor_requests_work.
Recommendation: close (superseded by main commit 4e59a81).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302997846 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1708#issuecomment-7302997846). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:32:51Z. --- **Triage (#1607)** – head 35ec9eb This change is on main as commit 4e59a81 ("D3D12.X: reuse pending pipeline entries on bind", merged with #2959), which says it was adapted from this PR. `resolve_for_bind` now resolves through the entry from its first lookup (`resolve_pending` / `resolve_wait_pending`), returns the real pipeline once `build.real` is set, and has the test `binding_a_completed_compute_pipeline_neither_relooks_it_up_nor_requests_work`. Recommendation: close (superseded by main commit 4e59a81). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:47:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:47:21Z.


Closing as superseded: this change is already on main (4e59a81). 4e59a81 (adapted from #1708): resolve_for_bind resolves through the first retained Pending and returns a published real pipeline after one load; main test binding_a_completed_compute_pipeline_neither_relooks_it_up_nor_requests_work

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311648661 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1708#issuecomment-7311648661). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:47:21Z. --- Closing as superseded: this change is already on `main` (4e59a81). 4e59a81 (adapted from #1708): resolve_for_bind resolves through the first retained Pending and returns a published real pipeline after one load; main test binding_a_completed_compute_pipeline_neither_relooks_it_up_nor_requests_work Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1698
No description provided.