D3D12.X: preserve used-pipeline key on RT-gated compute stand-ins #2755

Open
github-bot wants to merge 1 commit from github-bot/gh-2755 into amd-dev AGit
Owner

@⁠Saksukella on GitHub · 2026-11-26 10:15 UTC · original
Saksukella:fix/rt-gated-used-pipeline-key → amd-dev · +19 −5 · 2 files · 1 commits · open

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs:
    • Pass key: u64 into submit_gated(standin, driver, key) instead of hardcoding key: 0.
    • When a title binds an RT-gated compute stand-in under default XCL_RT_GATE=hold, resolve() / resolve_for_bind() already call p.note_use() (used::note(p.key)), so storing the real pipeline key lets used-pipelines.txt record bound RT compute pipelines for targeted offline xcl shaders ... --precompile --pipelines --used-only --only cs runs before switching to XCL_RT_GATE=auto. Prerequisite: this capture path applies when shared stand-in shells are enabled (default standin::enabled() == true; disabled under XCL_SHARED_STANDINS=0 or console-shaped lists, where maybe_rt_gated_compute_pso takes the raw standin_compute branch without a pso_async entry).
    • Extend submit_gated_maps_driver_without_pending_or_enqueue to assert non-zero key preservation via entry() without touching the on-disk used-pipelines.txt cache.
  • crates/xcl/src/hle/d3d12x/real.rs:
    • Add zero-allocation single_shader_key(hash) (matching shaders_key(&[blob]) without cloning the shader bytes) and pass single_shader_key(record) in maybe_rt_gated_compute_pso.
    • Extend a_key_follows_the_shaders_and_their_order_and_is_never_zero to verify single_shader_key(fnv64(&a)) == shaders_key(&[a]).
  • Target branch: amd-dev (where submit_gated / XCL_RT_GATE live).

Tested

  • Hardware: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), 24-thread x86_64 CPU, 32 GB RAM, Windows; rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).
  • cargo test -p xcl --lib submit_gated_maps_driver_without_pending_or_enqueue: 1 passed, 0 failed (0.00s).
  • cargo test -p xcl --lib a_key_follows_the_shaders_and_their_order_and_is_never_zero: 1 passed, 0 failed (0.00s).

Regression run

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1624 (PresentX 1624)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19700 MB
xcl-smoke v1
commit: 4bb6b30fc5b19e5dbcec8818134af47e39a68a31
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15090 MB

Not tested

  • NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only).

AI use

  • Antigravity (Google Gemini): assisted with auditing pso_async::submit_gated / used::note reachability, writing the zero-allocation key helper and unit tests, and running local tests and smoke verification. All diffs and measurements were verified locally on hardware.
**@⁠Saksukella** on GitHub · 2026-11-26 10:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/2755) `Saksukella:fix/rt-gated-used-pipeline-key` → `amd-dev` · +19 −5 · 2 files · 1 commits · open **What is in it** - `crates/xcl/src/hle/d3d12x/pso_async.rs`: - Pass `key: u64` into `submit_gated(standin, driver, key)` instead of hardcoding `key: 0`. - When a title binds an RT-gated compute stand-in under default `XCL_RT_GATE=hold`, `resolve()` / `resolve_for_bind()` already call `p.note_use()` (`used::note(p.key)`), so storing the real pipeline key lets `used-pipelines.txt` record bound RT compute pipelines for targeted offline `xcl shaders ... --precompile --pipelines --used-only --only cs` runs before switching to `XCL_RT_GATE=auto`. Prerequisite: this capture path applies when shared stand-in shells are enabled (default `standin::enabled() == true`; disabled under `XCL_SHARED_STANDINS=0` or console-shaped lists, where `maybe_rt_gated_compute_pso` takes the raw `standin_compute` branch without a `pso_async` entry). - Extend `submit_gated_maps_driver_without_pending_or_enqueue` to assert non-zero key preservation via `entry()` without touching the on-disk `used-pipelines.txt` cache. - `crates/xcl/src/hle/d3d12x/real.rs`: - Add zero-allocation `single_shader_key(hash)` (matching `shaders_key(&[blob])` without cloning the shader bytes) and pass `single_shader_key(record)` in `maybe_rt_gated_compute_pso`. - Extend `a_key_follows_the_shaders_and_their_order_and_is_never_zero` to verify `single_shader_key(fnv64(&a)) == shaders_key(&[a])`. - Target branch: `amd-dev` (where `submit_gated` / `XCL_RT_GATE` live). **Tested** - Hardware: AMD Radeon RX 9070 XT (driver `32.0.32029.2010`), 24-thread x86_64 CPU, 32 GB RAM, Windows; `rustc 1.100.0 (0ef1bc386 2026-11-09)`; debug (tests) and release (`xcl.exe`). - `cargo test -p xcl --lib submit_gated_maps_driver_without_pending_or_enqueue`: 1 passed, 0 failed (`0.00s`). - `cargo test -p xcl --lib a_key_follows_the_shaders_and_their_order_and_is_never_zero`: 1 passed, 0 failed (`0.00s`). **Regression run** ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1624 (PresentX 1624) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19700 MB ``` ``` xcl-smoke v1 commit: 4bb6b30fc5b19e5dbcec8818134af47e39a68a31 gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1674 (PresentX 1674) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15090 MB ``` **Not tested** - NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only). **AI use** - Antigravity (Google Gemini): assisted with auditing `pso_async::submit_gated` / `used::note` reachability, writing the zero-allocation key helper and unit tests, and running local tests and smoke verification. All diffs and measurements were verified locally on hardware.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:14:48 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 10:22 UTC · original · reviewed

The used-pipelines.txt capture path described here requires shared stand-in shells. At 4bb6b30, maybe_rt_gated_compute_pso calls submit_gated(..., key) only when standin::shell returned a nonzero driver; with XCL_SHARED_STANDINS=0 or console-shaped lists enabled, standin::enabled() is false and creation takes the raw standin_compute branch instead. A successful bind then has no pending key for resolve() to record. This is a scope limitation of the proposed workflow, not a new regression introduced by this patch; the new tests inject a key directly and do not cover creation with shells disabled.

Could the PR description name the shared-standin prerequisite for the XCL_RT_GATE=hold → --used-only workflow? That would keep users from treating a capture in either non-shell configuration as complete. Exact-head source review assisted by Codex (GPT-6.2 Sol and GPT-6.2 Astra); I did not run a non-shell title capture.

**@⁠luckyteagirl** on GitHub · 2026-11-26 10:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/2755#pullrequestreview-6072333077) · **reviewed** The `used-pipelines.txt` capture path described here requires shared stand-in shells. At `4bb6b30`, `maybe_rt_gated_compute_pso` calls `submit_gated(..., key)` only when `standin::shell` returned a nonzero `driver`; with `XCL_SHARED_STANDINS=0` or console-shaped lists enabled, `standin::enabled()` is false and creation takes the raw `standin_compute` branch instead. A successful bind then has no pending key for `resolve()` to record. This is a scope limitation of the proposed workflow, not a new regression introduced by this patch; the new tests inject a key directly and do not cover creation with shells disabled. Could the PR description name the shared-standin prerequisite for the `XCL_RT_GATE=hold` → `--used-only` workflow? That would keep users from treating a capture in either non-shell configuration as complete. Exact-head source review assisted by Codex (GPT-6.2 Sol and GPT-6.2 Astra); I did not run a non-shell title capture.
Author
Owner

@⁠Saksukella on GitHub · 2026-11-26 10:26 UTC · original

Good point @⁠luckyteagirl — updated the PR description to state explicitly that the XCL_RT_GATE=hold -> --used-only capture path applies when shared stand-in shells are enabled (default standin::enabled() == true, not under XCL_SHARED_STANDINS=0 or console-shaped lists).

**@⁠Saksukella** on GitHub · 2026-11-26 10:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/2755#issuecomment-7189370398) Good point @⁠luckyteagirl — updated the PR description to state explicitly that the `XCL_RT_GATE=hold` -> `--used-only` capture path applies when shared stand-in shells are enabled (default `standin::enabled() == true`, not under `XCL_SHARED_STANDINS=0` or console-shaped lists).
Author
Owner

@⁠vibryxcx on GitHub · 2026-11-27 01:05 UTC · original · edited 2026-11-27 04:24 UTC

I tried to see the new behaviour on a retail title on Windows / RDNA2. No RT-gated key reached used-pipelines.txt in either tree. Nothing regressed, but I could not confirm the change works in a real run either.

Setup: RX 6800 (driver 32.0.21045.5002), Windows 11 Pro 26200, release. This head sits on b5c0275f, where my shader cache is cold (about an hour of recompile), so I merged it onto the current amd-dev bf7c82ee (no conflicts) and compared that merge (adafbeb) with bf7c82ee. Default XCL_RT_GATE (hold), shared stand-ins on (the log has pipelines whose shaders are not compiled yet get a stand-in…).

Method: each run started from an empty used-pipelines.txt, with XCL_PREPARE=0 so that the title starts at once and A pressed every 10 s. Each run lasted 120 s. The log names each held pipeline as RT-gated compute PSO <record> held back without compiling, and <record> is the same fnv64(cs) this PR passes to single_shader_key. So for each logged record I computed single_shader_key(record) and looked for it in the file afterwards.

tree RT-gated PSOs held their keys in used-pipelines.txt lines written frames / crashes
bf7c82ee 15 0 18 1887 / 0
bf7c82ee + this PR 15 0 14 2055 / 0

With a full file (1,892 lines from earlier runs) neither tree added a line, so that comparison says nothing.

Reading: submit_gated stores the key and resolve / resolve_for_bind call note_use, which looks right. My guess is that in these 120 s the title creates the 15 RT PSOs (at about 25 s) but never binds them, so note_use never runs. I could not check this, because binds are not logged. If there is a scene or switch that makes the title dispatch these (or a log line for a gated stand-in's first bind), I can rerun it.

Tests on the merge, debug: submit_gated_maps_driver_without_pending_or_enqueue and a_key_follows_the_shaders_and_their_order_and_is_never_zero pass (2 passed, 0 failed). I did not run the full suite.

Not tested: this exact head on its own base (b5c0275f); XCL_SHARED_STANDINS=0; runs longer than 120 s; NVIDIA.

AI use: Claude Code (Claude Opus 5.5) merged and built the trees, ran the title, computed the keys from the logs and wrote this comment.


Update: full lib suite on this exact head (4bb6b30f, on its own base b5c0275f; RX 6800, debug, cargo test -p xcl --lib -- --test-threads=1, with the tests skipped that hang or abort only inside the full amd-dev run and xgameruntime::gamesave::tests run on their own, see #42): 1519 passed, 11 failed, 27 ignored, and gamesave 11/11. The 11 failures are the set b5c0275f already has on this card (#2757): fuzz_validate_and_gpu_1, dispatch_chain_native_wave64_builds_whole, a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, f32_programs_on_the_gpu, two_pass_binds_set_the_shared_view_heap, a_dispatch_with_a_pipeline_still_building_waits_at_the_submit, a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget, bitset_runs_emit_exact_contiguous_page_ranges, giant_driver_compiles_have_their_own_lane, title_bytes_are_used_in_place_when_all_are_readable, physical_home_without_sparse_windows_uses_coherent_window. Both tests this PR changes pass.

**@⁠vibryxcx** on GitHub · 2026-11-27 01:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/2755#issuecomment-7207002139) · edited 2026-11-27 04:24 UTC I tried to see the new behaviour on a retail title on Windows / RDNA2. **No RT-gated key reached `used-pipelines.txt` in either tree.** Nothing regressed, but I could not confirm the change works in a real run either. **Setup:** RX 6800 (driver 32.0.21045.5002), Windows 11 Pro 26200, release. This head sits on `b5c0275f`, where my shader cache is cold (about an hour of recompile), so I merged it onto the current `amd-dev` `bf7c82ee` (no conflicts) and compared that merge (`adafbeb`) with `bf7c82ee`. Default `XCL_RT_GATE` (`hold`), shared stand-ins on (the log has `pipelines whose shaders are not compiled yet get a stand-in…`). **Method:** each run started from an empty `used-pipelines.txt`, with `XCL_PREPARE=0` so that the title starts at once and A pressed every 10 s. Each run lasted 120 s. The log names each held pipeline as `RT-gated compute PSO <record> held back without compiling`, and `<record>` is the same `fnv64(cs)` this PR passes to `single_shader_key`. So for each logged record I computed `single_shader_key(record)` and looked for it in the file afterwards. | tree | RT-gated PSOs held | their keys in `used-pipelines.txt` | lines written | frames / crashes | |---|---:|---:|---:|---| | `bf7c82ee` | 15 | 0 | 18 | 1887 / 0 | | `bf7c82ee` + this PR | 15 | **0** | 14 | 2055 / 0 | With a full file (1,892 lines from earlier runs) neither tree added a line, so that comparison says nothing. **Reading:** `submit_gated` stores the key and `resolve` / `resolve_for_bind` call `note_use`, which looks right. My guess is that in these 120 s the title creates the 15 RT PSOs (at about 25 s) but never binds them, so `note_use` never runs. I could not check this, because binds are not logged. If there is a scene or switch that makes the title dispatch these (or a log line for a gated stand-in's first bind), I can rerun it. **Tests** on the merge, debug: `submit_gated_maps_driver_without_pending_or_enqueue` and `a_key_follows_the_shaders_and_their_order_and_is_never_zero` pass (2 passed, 0 failed). I did not run the full suite. **Not tested:** this exact head on its own base (`b5c0275f`); `XCL_SHARED_STANDINS=0`; runs longer than 120 s; NVIDIA. AI use: Claude Code (Claude Opus 5.5) merged and built the trees, ran the title, computed the keys from the logs and wrote this comment. --- **Update: full lib suite on this exact head** (`4bb6b30f`, on its own base `b5c0275f`; RX 6800, debug, `cargo test -p xcl --lib -- --test-threads=1`, with the tests skipped that hang or abort only inside the full `amd-dev` run and `xgameruntime::gamesave::tests` run on their own, see #42): **1519 passed, 11 failed, 27 ignored**, and `gamesave` 11/11. The 11 failures are the set `b5c0275f` already has on this card (#2757): `fuzz_validate_and_gpu_1`, `dispatch_chain_native_wave64_builds_whole`, `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, `f32_programs_on_the_gpu`, `two_pass_binds_set_the_shared_view_heap`, `a_dispatch_with_a_pipeline_still_building_waits_at_the_submit`, `a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget`, `bitset_runs_emit_exact_contiguous_page_ranges`, `giant_driver_compiles_have_their_own_lane`, `title_bytes_are_used_in_place_when_all_are_readable`, `physical_home_without_sparse_windows_uses_coherent_window`. Both tests this PR changes pass.
Author
Owner

@⁠andrewDoing on GitHub · 2026-11-27 04:33 UTC · original

I checked the first actual bind of a gated compute pipeline on head 4bb6b30f and its parent b5c0275f, with the same synthetic shader and test-only fixture. Both builds created a shared held pipeline shell and had no entry for the expected key immediately after creation. The fixture then created a real direct command list and called SetPipelineState; it did not call submit_gated or the resolve helper directly.

On the parent, the key remained absent after the bind and the assertion failed. On the PR head, the expected key appeared in used-pipelines.txt and the test passed with no reported skip. Both runs logged the same held shader and expected key. This verifies capture on the tested shared-shell bind path; it does not establish whether any of the 15 held retail pipelines were bound or measure cold compilation savings.

AI use: OpenAI Codex with GPT-6.2 Astra constructed and ran the synthetic parent/head comparison; Codex coordinated and prepared this report.

**@⁠andrewDoing** on GitHub · 2026-11-27 04:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2755#issuecomment-7209888786) I checked the first actual bind of a gated compute pipeline on head `4bb6b30f` and its parent `b5c0275f`, with the same synthetic shader and test-only fixture. Both builds created a shared held pipeline shell and had no entry for the expected key immediately after creation. The fixture then created a real direct command list and called `SetPipelineState`; it did not call `submit_gated` or the resolve helper directly. On the parent, the key remained absent after the bind and the assertion failed. On the PR head, the expected key appeared in `used-pipelines.txt` and the test passed with no reported skip. Both runs logged the same held shader and expected key. This verifies capture on the tested shared-shell bind path; it does not establish whether any of the 15 held retail pipelines were bound or measure cold compilation savings. AI use: OpenAI Codex with GPT-6.2 Astra constructed and ran the synthetic parent/head comparison; Codex coordinated and prepared this report.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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