D3D12.X: the hot list, resource and queue hooks look their PC slot up once #903

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

@⁠mastrr9 on GitHub · 2026-11-24 08:00 UTC · original
mastrr9:perf/d3d12x-cache-hot-hook-slots → main · +117 −15 · 1 files · 1 commits · open

Caches PC COM vtable slot indices per hot hook call site (slot!(this, "Name")) in crates/xcl/src/hle/d3d12x/real.rs instead of locking the global CLASSES mutex and scanning method names on every draw, bind, map, unmap, render-target set, and ExecuteCommandLists call:

  • Because COM vtables only append methods in derived interface versions, every hot method keeps a single fixed slot across all versions of its interface.
  • Adds unit tests verifying both the table invariant (hot_methods_have_one_slot_in_every_version_of_their_interface) and that repeated draws/binds perform one lookup per call site (draws_and_pipeline_binds_look_their_slot_up_once).

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: 0a1141e93c14dd348a9469ff7bad220d978e7908 (HEAD 3179fa00d420fafdab43b7ec484d1c04c1d8a8b6 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: 717 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: #903
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: 03f85e2875cd3f32b65ecf4011b9af4640128e15
gpu: AMD Radeon RX 9070
title: game.exe
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: 14820 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/903) `mastrr9:perf/d3d12x-cache-hot-hook-slots` → `main` · +117 −15 · 1 files · 1 commits · open Caches PC COM vtable slot indices per hot hook call site (`slot!(this, "Name")`) in `crates/xcl/src/hle/d3d12x/real.rs` instead of locking the global `CLASSES` mutex and scanning method names on every draw, bind, map, unmap, render-target set, and `ExecuteCommandLists` call: - Because COM vtables only append methods in derived interface versions, every hot method keeps a single fixed slot across all versions of its interface. - Adds unit tests verifying both the table invariant (`hot_methods_have_one_slot_in_every_version_of_their_interface`) and that repeated draws/binds perform one lookup per call site (`draws_and_pipeline_binds_look_their_slot_up_once`). **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: `0a1141e93c14dd348a9469ff7bad220d978e7908` (HEAD `3179fa00d420fafdab43b7ec484d1c04c1d8a8b6` 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`: **717 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/903 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: 03f85e2875cd3f32b65ecf4011b9af4640128e15 gpu: AMD Radeon RX 9070 title: game.exe 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: 14820 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.
cl_draw_instanced, cl_draw_indexed_instanced, cl_execute_indirect, the
pipeline bind, OMSetRenderTargets, ClearRenderTargetView, ClearState,
Close, Reset, resource Map / Unmap / WriteToSubresource, queue
ExecuteCommandLists, allocator Reset and fence Signal asked slot_of on
every call: the class table's global lock and a search of the
interface's method names (13 for DrawInstanced, 26 for
SetPipelineState, 60 for ExecuteIndirect). A translated draw paid it
twice (its PC DrawInstanced and its pipeline's SetPipelineState), and
every thread recording a list queued on the one lock.

A method keeps its slot in every version of its interface, so each of
these call sites keeps the first answer in a static (slot!).

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

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

Heads-up: this branch now conflicts with main.

Rebuild today: pull/903/head (29e85d2) onto current main (09940bb) hits a merge conflict in crates/xcl/src/hle/d3d12x/real.rs (main moved through the sparse/readback work since the branch was cut). CI is x86-windows only, so nothing here will catch it.

Untested until rebase; happy to re-run on RDNA3 after it lands rebased.

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/903#issuecomment-7127601738) Heads-up: this branch now conflicts with main. Rebuild today: `pull/903/head` (`29e85d2`) onto current main (`09940bb`) hits a **merge conflict in `crates/xcl/src/hle/d3d12x/real.rs`** (main moved through the sparse/readback work since the branch was cut). CI is x86-windows only, so nothing here will catch it. Untested until rebase; happy to re-run on RDNA3 after it lands rebased. **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

@⁠mastrr9 on GitHub · 2026-11-24 14:38 UTC · original

@⁠SlopTart Thanks for the heads-up! Rebased cleanly onto current main (930e8b4, PR head 0733369cc2e1389bd745e5f423b6939fce6efa07), keeping slot!(raw, "Reset") in reset_pc_allocator. Ready for your RDNA3 re-run whenever you have a moment (I'll re-run Windows RTX 5080 verification on this rebased head shortly too).

**@⁠mastrr9** on GitHub · 2026-11-24 14:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/903#issuecomment-7134698357) @⁠SlopTart Thanks for the heads-up! Rebased cleanly onto current `main` (`930e8b4`, PR head `0733369cc2e1389bd745e5f423b6939fce6efa07`), keeping `slot!(raw, "Reset")` in `reset_pc_allocator`. Ready for your RDNA3 re-run whenever you have a moment (I'll re-run Windows RTX 5080 verification on this rebased head shortly too).
Author
Owner

@⁠mastrr9 on GitHub · 2026-11-24 14:54 UTC · original

Verified rebased head 0733369cc2e1389bd745e5f423b6939fce6efa07 on Windows 11 / NVIDIA RTX 5080 (cargo test --workspace -- --test-threads=4: 753 passed / 0 failed / 41 ignored, 0 new warnings).

**@⁠mastrr9** on GitHub · 2026-11-24 14:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/903#issuecomment-7135152106) Verified rebased head `0733369cc2e1389bd745e5f423b6939fce6efa07` on Windows 11 / NVIDIA RTX 5080 (`cargo test --workspace -- --test-threads=4`: **753 passed / 0 failed / 41 ignored**, 0 new warnings).
Author
Owner

@⁠mastrr9 on GitHub · 2026-11-24 16:16 UTC · original

Rebased cleanly onto latest main (b7aa9f3, new head 03f85e2875cd3f32b65ecf4011b9af4640128e15) and re-verified on Windows 11 / NVIDIA RTX 5080:

  • cargo build --workspace: OK (0 new warnings)
  • cargo test --workspace -- --test-threads=4: 772 passed, 0 failed, 41 ignored
**@⁠mastrr9** on GitHub · 2026-11-24 16:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/903#issuecomment-7137407687) Rebased cleanly onto latest `main` (`b7aa9f3`, new head `03f85e2875cd3f32b65ecf4011b9af4640128e15`) and re-verified on Windows 11 / NVIDIA RTX 5080: - `cargo build --workspace`: OK (0 new warnings) - `cargo test --workspace -- --test-threads=4`: **772 passed, 0 failed, 41 ignored**
Author
Owner

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

Regression run of 03f85e28 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: 03f85e2875cd3f32b65ecf4011b9af4640128e15
gpu: AMD Radeon RX 9070
title: game.exe
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: 14820 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 100 % 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/903#issuecomment-7151626764) Regression run of `03f85e28` 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: 03f85e2875cd3f32b65ecf4011b9af4640128e15 gpu: AMD Radeon RX 9070 title: game.exe 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: 14820 MB ``` Against the limits in CONTRIBUTING.md: 100 % of `main`'s frames, 100 % 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

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

Empirical test report (03f85e28)

Tested xcl-dev/xcl PR #903 at 03f85e2875cd3f32b65ecf4011b9af4640128e15. The PR caches the PC vtable slot at selected D3D12.X hook call sites.

Hardware / environment

  • Windows x64 build 26200. AMD CPU (family 23, model 113, stepping 0), with 12 logical processors reported by the environment.
  • Rust 1.100.0 (0ef1bc386 2026-11-09). DXC 1.9.2609.5 (01b62ad47). Cargo used the unoptimized test profile with debug info and incremental compilation disabled.
  • Both fixtures run on the CPU using interface layout tables and a fake COM vtable. The focused run used XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1 outside Invoke-ArcTest.ps1.

Commands and results

  • cargo test --workspace --no-run built the workspace test executables and exited 0.
  • cargo test -p xcl --lib hle::d3d12x::real::slot_cache_tests:: exited 0. The log reports 2 passed, 0 failed, 0 ignored, 0 SKIPPED, and 743 filtered out.

Observed behavior

  • hot_methods_have_one_slot_in_every_version_of_their_interface passed. For each of the 15 named methods across five interface families, the slots found in the layout tables agreed on one nonzero index.
  • draws_and_pipeline_binds_look_their_slot_up_once passed. The fake PC callbacks received all three draws and the three expected pipeline handles in bind order. The fixture asserted at most two slot_of lookups across the six calls.

Not tested

The full GPU workspace suite and game smoke runs were omitted. Live D3D12 device behavior and frame-time impact were outside this run.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr903-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 06:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/903#issuecomment-7154388799) ### Empirical test report (03f85e28) Tested xcl-dev/xcl PR #903 at `03f85e2875cd3f32b65ecf4011b9af4640128e15`. The PR caches the PC vtable slot at selected D3D12.X hook call sites. **Hardware / environment** - Windows x64 build 26200. AMD CPU (family 23, model 113, stepping 0), with 12 logical processors reported by the environment. - Rust `1.100.0 (0ef1bc386 2026-11-09)`. DXC `1.9.2609.5 (01b62ad47)`. Cargo used the unoptimized test profile with debug info and incremental compilation disabled. - Both fixtures run on the CPU using interface layout tables and a fake COM vtable. The focused run used `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1` outside `Invoke-ArcTest.ps1`. **Commands and results** - `cargo test --workspace --no-run` built the workspace test executables and exited 0. - `cargo test -p xcl --lib hle::d3d12x::real::slot_cache_tests::` exited 0. The log reports 2 passed, 0 failed, 0 ignored, 0 `SKIPPED`, and 743 filtered out. **Observed behavior** - `hot_methods_have_one_slot_in_every_version_of_their_interface` passed. For each of the 15 named methods across five interface families, the slots found in the layout tables agreed on one nonzero index. - `draws_and_pipeline_binds_look_their_slot_up_once` passed. The fake PC callbacks received all three draws and the three expected pipeline handles in bind order. The fixture asserted at most two `slot_of` lookups across the six calls. **Not tested** The full GPU workspace suite and game smoke runs were omitted. Live D3D12 device behavior and frame-time impact were outside this run. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr903-focused.log` and published.
Author
Owner

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

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 09:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/903#issuecomment-7158439263) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/real.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/903/head:github-bot/gh-903'
git switch 'github-bot/gh-903'

Merge

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