D3D12.X: draws find their pipeline facts and list state without global locks #904

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

@⁠mastrr9 on GitHub · 2026-11-24 08:00 UTC · original
mastrr9:perf/d3d12x-lockfree-draw-lookups → main · +360 −38 · 2 files · 1 commits · open

Eliminates repeated global mutex grabs and per-call allocations on hot draw and dispatch paths (crates/xcl/src/hle/d3d12x/bind.rs + real.rs):

  • Caches per-pipeline facts and per-command-list state locally instead of re-querying global hash maps on every draw/dispatch, and removes a per-call Vec allocation on root-constants updates.
  • Together with hot-hook slot caching, reduces global lock acquisitions on a translated DrawInstanced from ~33 down to ~8 (and DrawIndexedInstanced 29 → 7, Dispatch 24 → 7), sharply reducing contention across multi-threaded command list recording.

Tested

  • Hardware/OS: NVIDIA RTX 5080 (driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC debug, DXC Windows SDK 10.0.26100.0, d3d12SDKLayers.dll installed
  • Commit tested: 3d6253bbcb307f919621f2a72de758f19808c33f (HEAD 21755afb2dba7318a49690ff02b9fe6a69270740 has an identical tree; only commit author metadata was updated after GitHub account rename)
  • cargo build --workspace: clean (no new warnings; only pre-existing fetch_update deprecation warning)
  • cargo test --workspace -- --test-threads=4: 719 passed, 0 failed, 41 ignored
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64

Regression run
Smoke run by @⁠Toons29 in comment below: #904
Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted.

main:

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB

PR:

xcl-smoke v1
commit: 7c2ccd9b777fb35aa34420d5e39d2c6d89993308
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14686 MB

Tester's setup and limits: AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

Tester's AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; the tester checked the blocks before posting.

Not tested

  • No retail title was available to the author; whether the community regression run above reaches the code this PR changes is not known.

AI use

  • Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).
  • Claude Code (Claude Sonnet 5.5) added the community regression run to this description and updated the lines that it made out of date or that the PR check requires.
**@⁠mastrr9** on GitHub · 2026-11-24 08:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/904) `mastrr9:perf/d3d12x-lockfree-draw-lookups` → `main` · +360 −38 · 2 files · 1 commits · open Eliminates repeated global mutex grabs and per-call allocations on hot draw and dispatch paths (`crates/xcl/src/hle/d3d12x/bind.rs` + `real.rs`): - Caches per-pipeline facts and per-command-list state locally instead of re-querying global hash maps on every draw/dispatch, and removes a per-call `Vec` allocation on root-constants updates. - Together with hot-hook slot caching, reduces global lock acquisitions on a translated `DrawInstanced` from ~33 down to ~8 (and `DrawIndexedInstanced` 29 → 7, `Dispatch` 24 → 7), sharply reducing contention across multi-threaded command list recording. **Tested** - Hardware/OS: NVIDIA RTX 5080 (driver `617.42` / `32.0.16.1742`), Windows 11 Pro 25H2 (`26200.9974`), `rustc 1.100.0 (0ef1bc386 2026-11-09)` MSVC debug, DXC Windows SDK `10.0.26100.0`, `d3d12SDKLayers.dll` installed - Commit tested: `3d6253bbcb307f919621f2a72de758f19808c33f` (HEAD `21755afb2dba7318a49690ff02b9fe6a69270740` has an identical tree; only commit author metadata was updated after GitHub account rename) - `cargo build --workspace`: clean (no new warnings; only pre-existing `fetch_update` deprecation warning) - `cargo test --workspace -- --test-threads=4`: **719 passed, 0 failed, 41 ignored** - `SKIPPED` GPU tests: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64` **Regression run** Smoke run by @⁠Toons29 in comment below: https://git.gtahub.st/github/xcl-dev--xcl/pulls/904 Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted. main: ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` PR: ``` xcl-smoke v1 commit: 7c2ccd9b777fb35aa34420d5e39d2c6d89993308 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1632 (PresentX 1632) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14686 MB ``` Tester's setup and limits: AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. Tester's AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; the tester checked the blocks before posting. **Not tested** - No retail title was available to the author; whether the community regression run above reaches the code this PR changes is not known. **AI use** - Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5). - Claude Code (Claude Sonnet 5.5) added the community regression run to this description and updated the lines that it made out of date or that the PR check requires.
Every draw and dispatch of console code asked about its pipeline again:
graphics_bound resolved it (pso_async's table) and asked whether it is a
translated graphics pipeline, bind_abi resolved it again and asked for
its root signature (and for a dispatch its user SGPRs, each resolving it
once more), and DrawInstanced's rect list check resolved it and asked
for the rect list GS. Each is a global lock and a hash lookup: seven for
a translated DrawInstanced, seven for a Dispatch, eleven when the
pipeline was built in the background (its job and done locks), on every
draw of a run of draws with one pipeline, with all recording threads
sharing those locks.

bind::pipeline finds it out once and the list keeps it for its last four
pipelines: a draw with a kept pipeline makes none of those lookups. What
is kept holds while no pipeline state is released (real::pso_generation,
changed by forget_pso: a later pipeline may get a released one's
address), and nothing is kept while a pipeline is still being built.

D3D12.X: root arguments reach their list without the table of all lists

Every root argument a title sets (SetGraphicsRoot32BitConstants,
...DescriptorTable, ...ConstantBufferView and the compute ones), every
draw and every dispatch of console code went through bind::with, which
took the one lock of the table of all lists' states and hashed the list's
address: several times a draw, on every thread that records a list, all
of them queuing on that lock. SetGraphicsRoot32BitConstants and its
compute twin also collected the words into a new Vec each call, and a
root signature set again allocated its argument buffer anew.

Each list's state now has a lock of its own (Entry), and a thread keeps
the entry of the list it used last: the table is asked only when the
thread turns to another list. A released list's entry is marked gone,
so a thread that kept it asks the table again for a list made later at
the same address. The words of a root constant call are put in place
as the bytes they are, and a root signature set again zeroes the buffer
the list had.

Assisted-by: Claude Code (Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:36:23 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 09:34 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head 21755af onto main 09940bb, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 709 passed, 11 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). lock-free pipeline/list hooks green; one extra failure (writes_land_after_the_queue) appeared once in the lane but passes 2/2 in isolation, consistent with the ordering flakes on this rig.

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. My Linux rows: #42 / #718.

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

**@⁠SlopTart** on GitHub · 2026-11-24 09:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/904#issuecomment-7127602510) Linux / AMD RDNA3 datapoint. **Merged state:** head `21755af` onto main `09940bb`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **709 passed, 11 failed, 41 ignored**; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). lock-free pipeline/list hooks green; one extra failure (`writes_land_after_the_queue`) appeared once in the lane but passes 2/2 in isolation, consistent with the ordering flakes on this rig. **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`. My Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 03:08 UTC · original

Regression run of 7c2ccd9b on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 7c2ccd9b777fb35aa34420d5e39d2c6d89993308
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14686 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 99 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 03:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/904#issuecomment-7151633202) Regression run of `7c2ccd9b` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 7c2ccd9b777fb35aa34420d5e39d2c6d89993308 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1632 (PresentX 1632) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14686 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 99 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 09:32 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • Does not compile: error[E0425]: cannot find value 'pso' in this scope at crates/xcl/src/hle/d3d12x/bind.rs:415 and :419 (2 errors). Fails on the PR head itself.

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-25 09:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/904#issuecomment-7158478984) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - **Does not compile**: `error[E0425]: cannot find value 'pso' in this scope` at `crates/xcl/src/hle/d3d12x/bind.rs:415` and `:419` (2 errors). Fails on the PR head itself. — Devin
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/bind.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/904/head:github-bot/gh-904'
git switch 'github-bot/gh-904'

Merge

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