Skip to content

D3D12.X: a list vtable at a reused heap address gets its own methods - #2593

Open
SergeAx wants to merge 1 commit into
xcl-dev:mainfrom
SergeAx:d3d12x-heap-vtable-classes
Open

SergeAx wants to merge 1 commit into
xcl-dev:mainfrom
SergeAx:d3d12x-heap-vtable-classes

Conversation

@SergeAx

@SergeAx SergeAx commented Nov 26, 2026 •

Copy link
Copy Markdown

Fixes #2588.

With the Agility SDK 1.620, an open command list's vtable is in heap memory and goes with the list. real::class_for cached the extended vtable by the runtime vtable's address and copied the runtime's methods only once, so a direct list whose open vtable came where a released compute list's had been called the compute list's methods: its ClearDepthStencilView made Close fail with E_FAIL. That is the parallel-only failure of vram::tests::d32s8_targets_take_their_own_size_of_video_memory (#42).

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: a Class of a vtable outside any module keeps the methods it copied (copied), and class_for takes it only while they are still the ones at that address. Vtables in a module's image are looked up as before.
  • crates/xcl/src/hle/d3d12x/real.rs (class_tests): a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods.

Tested

  • NVIDIA GeForce RTX 5080, driver 621.14; AMD Ryzen 5 3500X; Windows 10 Pro 22H2 (19045.6466), D3D12 Agility SDK 1.620.2; Rust 1.100.0, debug
  • cargo test --workspace --no-fail-fast -- --test-threads=4 at 52c0802f: 1426 passed, 4 failed, 47 ignored. The 4 are DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905 (fuzz_validate_and_gpu_0.._3, seeds 70, 545, 1019 and 1507), as on main 6d12f58 (GPU test results: NVIDIA RTX 3080 (wave32) and AMD RDNA2 iGPU (no mesh shaders) #42).
  • SKIPPED (25): 21 × no wave64; 3 × wave32 per-lane form refused (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • The new test fails in 5 runs out of 5 with the lookup ignoring copied, and passes in 5 out of 5 with this change.
  • The lib tests run as --test-threads=4 hle::d3d12x hle::xgameruntime: the D32S8 test failed in 2–5 runs out of 10 on 6d12f58, and in 0 out of 12 with this change.

Regression run

main:

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 5080
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1332 (PresentX 1332)
presents per 2 s (last 3): 30 50 20
device removals: 0
crashes: 0
peak commit: 18965 MB

this PR:

xcl-smoke v1
commit: 52c0802fb8f13c4efef3b82a14bc34fd338ae7a6
gpu: NVIDIA GeForce RTX 5080
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1307 (PresentX 1307)
presents per 2 s (last 3): 44 41 10
device removals: 0
crashes: 0
peak commit: 19621 MB

Not tested

  • AMD and Intel GPUs, Windows 11, and the inbox D3D12 runtime without the Agility SDK (its vtables are in D3D12Core.dll, which this change looks up as before)
  • On AMD the new test does not reach the fix: on an RX 9070 XT (Windows 11) it was SKIPPED in 3 runs out of 3, as no direct list got a released compute list's vtable address in its 200 tries (report in the comments). On the RTX 5080 here it reaches it (above)
  • Whether it also covers the other parallel-only failures reported in GPU test results: NVIDIA RTX 3080 (wave32) and AMD RDNA2 iGPU (no mesh shaders) #42 (list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list)

AI use

  • Claude Code (Claude Opus 5.5) found the cause, wrote the change and the test, ran the tests and measurements, and wrote this description.

Agility SDK 1.620 keeps an open command list's vtable in heap memory
that is freed with the list. class_for cached the extended vtable by
the runtime vtable's address and copied the runtime's methods only the
first time, so a direct list whose open vtable came where a released
compute list's had been called the compute list's methods: its
ClearDepthStencilView made Close fail with E_FAIL. That is how vram's
D32S8 test failed in parallel runs (2-5 in 10 with hle::d3d12x and one
more module on 4 threads, RTX 5080; 0 in 12 with this change).

A class of a vtable outside any module now keeps the methods it copied
and is taken only while they are still the ones there.

Fixes xcl-dev#2588
@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

@DarkPanda69

Copy link
Copy Markdown

AMD run (listed as untested), on Windows 11 too: on an RX 9070 XT the new test skips. The reuse it waits for did not happen in 3 runs, so on this machine it passes without exercising the fix.

Head 52c0802 applied on main b49be18, debug, Windows 11 Pro 26200, RX 9070 XT (RDNA4, driver 32.0.32029.2010). The test takes the default adapter (create_device(None, ..)), which is the RX 9070 XT on this machine.

cargo test -p xcl --lib -- a_direct_list_at_a_released_compute_lists_vtable --nocapture, 3 times, each:

SKIPPED hle::d3d12x::real::class_tests::a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods: 
no direct list got a released compute list's vtable
test ... ok

So in the test's 200 tries, no direct list landed on a released compute list's vtable address here. Your report's SKIPPED list doesn't include this test, so it did run on the RTX 5080. Whether the address reuse is rarer here because of the GPU driver, Windows 11 or the heap was not looked into. This run also says nothing about whether the fix is right on AMD; it only shows the test does not reach it on this machine.

Not tested: the machine's RTX 3060 (the test always uses the default adapter), Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the test on this machine and wrote this report.

@mokkamokacaffe

Copy link
Copy Markdown

I found an additional cache-boundary case in the current implementation.

same_methods walks the historical copied.len() before deriving the replacement vtable’s current interface and scanned length. A shorter replacement can therefore be read using the older length, while a longer table sharing the old prefix can reuse stale internal method handling.

I prepared a focused follow-up at ea5a19a. It derives the live table shape first, compares the complete snapshot and metadata, preserves the image-backed fast path, and adds CPU-only coverage for:

  • Shorter replacement tables
  • Longer replacement tables
  • Changes in internal slots
  • A → B → A historical-generation reuse

Tested

  • Windows no-GPU CI on the combined tree: 1430 passed, 0 failed, 47 ignored
  • heap_classes_match_only_the_same_shape_and_methods: passed
  • git diff --check: passed

Not tested

  • The Agility SDK 1.620 heap-reuse regression skipped because the CI runner did not expose a changed heap vtable.
  • Exact-head GPU workspace tests
  • AMD, NVIDIA, or Intel hardware
  • Paired retail-title xcl-smoke runs

Exact-head GPU and smoke runs remain required after this change is folded into #2593.

AI use

  • OpenAI Codex with GPT-5.6 Sol reviewed the change, implemented the follow-up, and ran the source and Windows CI checks.

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods: passed.

Not tested: retail titles (no title data on this lane, counts only).

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

@SergeAx

SergeAx commented Nov 26, 2026

Copy link
Copy Markdown
Author

@mokkamokacaffe thanks for looking. I read class_for at 52c0802 and ea5a19a, and I don't think the extra check is needed:

  • A shorter replacement. same_methods reads copied.len() words at orig: the old class's scanned, the same words its own scan read at that address. A class is reused only when all of those words equal its snapshot; a fresh scan would then find the same words in the same module and stop no earlier, so the table cannot come out shorter.
  • A longer replacement. A fresh scan comes out longer only if the word at scanned, where the old scan stopped, now points into the same module. With the first scanned words identical, it is the same runtime class, whose table length is fixed: a word after it is heap memory past the vtable, not a method. The runtime calls only its own methods, all among the compared words, and for the title such a slot answers the same either way: the guard of an internal slot answers a title call as the stub does (logged, 0), and console_slots / console_remap give it the same handler in both cases.
  • A → B → A. Every class stays in CLASSES and the lookup matches by methods, so A's class is found again when A's table comes back.

ea5a19a runs the QI probe and the scan on every adopt of an object with a heap vtable before matching (every command list on Agility 1.620), where this PR compares scanned words. Its new test covers the new matching_class helper; it does not show a case where this PR's lookup returns the wrong class. So I'm keeping #2593 as it is.

AI use: Claude Code (Claude Opus 5.5) read both commits and wrote this reply.

@upipibi

upipibi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

NVIDIA test report for 52c0802: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.

  • a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods, --exact --test-threads=1 --nocapture, 5 runs: 5 passed; the reuse happened (no SKIPPED line) in 0 of 5, so it skipped as on the RX 9070 XT. The cause here is the D3D12 runtime, not the driver: with no Agility SDK found, create_device used the inbox D3D12Core.dll 10.0.26100.9549, whose command list vtables are in the DLL image (PC vtable D3D12Core.dll+0x30ed90 / +0x30e830). Compute and direct lists then have different static vtables, and copied is never set.
  • The same command with XCL_D3D12_DIR set to the Agility SDK 1.620.2 (NuGet Microsoft.Direct3D.D3D12 1.620.2), 5 runs: 5 passed; the list vtables were heap addresses, and the reuse happened (no SKIPPED line) in 4 of 5, so the fix is exercised on this driver. With the lookup changed to ignore copied (local edit, Agility 1.620.2), it failed 5 of 5: ClearDepthStencilView of a direct list at a compute list's vtable 0x... failed its Close.
  • hle::d3d12x::real:: at default threads, inbox runtime, 3 runs: 60 passed, 0 failed each time; the new test SKIPPED in all 3.
  • cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4 (the hle::xaudio2 tests hang on this machine, on main too), inbox runtime: 1296 passed, 0 failed, 27 ignored; 26 SKIPPED lines (21 × no wave64; 3 × wave32 per-lane form refused: V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32; pso_measurement_compiles_an_exact_synthetic_record: driver cache needs Developer Mode; and the new test).
    The RX 9070 XT report doesn't say which D3D12 runtime it loaded; if it was the inbox one, its skip has the same cause, and a run with XCL_D3D12_DIR would show whether AMD reuses the address.
    Lib tests only; no title run.
    AI-assisted (Claude Code, Claude Opus 5.5).

@mokkamokacaffe

mokkamokacaffe commented Nov 26, 2026 •

Copy link
Copy Markdown

@SergeAx Thanks for the detailed correction. I re-read class_for at 52c0802 alongside ea5a19a, and I agree that my follow-up did not establish a failing case in this PR:

  • A heap-table cache hit already requires every method in the cached scanned snapshot to match.
  • A → B → A reuse is handled because the prior A class remains in CLASSES and is selected by its method snapshot.
  • My added unit test exercised the stricter matching_class policy itself; it did not reproduce an incorrect class selection by the existing lookup.
  • Re-running QueryInterface and the vtable scan on every heap-table adoption would add work on the Agility path without a demonstrated correctness benefit.

I therefore withdraw the ea5a19a suggestion and support keeping #2593 scoped as it is. The later Agility 1.620.2 NVIDIA report also gives the important missing distinction: the regression is exercised with heap-backed vtables, while inbox-runtime/image-backed tables legitimately skip it.

Thanks for checking the proposed follow-up closely.

AI use

  • OpenAI Codex (GPT-6.2 Astra Ultra) re-read both implementations, the discussion, and the subsequent hardware reports, then drafted this reply.

@thehollowedone

Copy link
Copy Markdown
Contributor

Independent Windows/NVIDIA test of head 52c0802fb8f13c4efef3b82a14bc34fd338ae7a6. Setup: Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D, rustc 1.99.1, debug; Microsoft's signed Agility SDK 1.620.2 supplied through XCL_D3D12_DIR.

  • The exact a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods test passed in 5/5 fresh processes. It exercised the reused heap-vtable address in 3/5; the other two printed SKIPPED: no direct list got a released compute list's vtable and do not count as exercising the fix.
  • cargo build --offline --locked --workspace: passed.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4: 1,428 passed, 2 failed, 47 ignored across 37 targets. There were 25 GPU SKIPPED notices (21 no wave64, 3 refused per-lane forms, 1 no heap windows); these tests are included in Cargo's passing count, not GPU coverage. The two failures were fuzz_validate_and_gpu_3 (driver 0x8007000E at seed 1904) and console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk (DXIL not compiled yet). The new vtable test passed in this suite too.

On exact main base b49be18, the shader-cache test failed alone with the same DXIL not compiled yet error. The GPU fuzz test passed alone on base and in 3/3 isolated reruns on the PR head. A matched full base suite did not finish: four parallel GPU tests ran over 60 seconds without further output, so I stopped it. I cannot classify the suite's fuzz failure as a PR regression or declare the PR merge-ready from these runs.

No retail title, AMD, or Intel test. AI use: Codex (GPT-6.2 Sol) prepared the exact-head builds, ran the tests, and checked the logs.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #2593 at head 52c0802fb8f13c4efef3b82a14bc34fd338ae7a6 (1 commit; exact parent & merge-base: 08db8020d323bf478964fcc586152cce54959cfc, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • D3D12 runtime: Inbox D3D12Core.dll 10.0.26100.8328 (no Agility SDK 1.620+ DLL installed on this host)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (52c0802f)

Command Result
cargo test --release -p xcl a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods -- --nocapture (5 consecutive runs) 1 passed; 0 failed; 0 ignored; 1331 filtered out × 5 (0.19s × 5) — self-skipped on all 5 runs via skip_test("no direct list got a released compute list's vtable") because inbox D3D12Core.dll 10.0.26100.8328 places open command-list vtables inside the module image (D3D12Core.dll+0x30bd90, D3D12Core.dll+0x30b830) rather than on the heap
cargo test --release -p xcl hle::d3d12x::real:: -- --test-threads=1 (3 consecutive runs) 60 passed; 0 failed; 0 ignored; 1272 filtered out × 3 (2.05s × 3; 59 executed + 1 self-skipped class_tests case above)
cargo build --release -p xcl Clean build (exit 0, 0 new warnings)

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (08db8020d323bf478964fcc586152cce54959cfc, cached baseline on the same machine):

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1588 (PresentX 1588)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14000 MB

PR #2593 (52c0802fb8f13c4efef3b82a14bc34fd338ae7a6):

xcl-smoke v1
commit: 52c0802fb8f13c4efef3b82a14bc34fd338ae7a6
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1586 (PresentX 1586)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13978 MB

Runtime log observations (xcl.log)

  • 9223 log lines, 0 [ERROR] / device-removal / panic lines.
  • 13 D3D12 runtime vtables adopted during the run, all inside inbox D3D12Core.dll (module_of(orig) != 0 fast path).
  • Final draw/memory telemetry in log: 19537 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 13977 MB committed by the process; video memory 6115 MB local, 4652 MB non-local.

Limits of coverage

  • Inbox D3D12 non-regression only — Agility SDK 1.620+ heap-vtable reuse path not exercised: this host runs Windows 11 inbox D3D12Core.dll (10.0.26100.8328) without Agility SDK 1.620+, so open command-list vtables live inside D3D12Core.dll (module_of(orig) != 0) instead of heap memory. As a result, a_direct_list_at_a_released_compute_lists_vtable_records_with_its_own_methods self-skipped (5/5 standalone, 3/3 inside hle::d3d12x::real::) and did not execute the ClearDepthStencilView + Close() assertion on a reused heap vtable address.
  • This report confirms that the added Class::copied / same_methods / module_of(orig) == 0 guard builds cleanly and causes no regression on inbox D3D12Core.dll (59 executed hle::d3d12x::real:: tests × 3 and paired 60 s retail smoke on title: 29640639); independent hardware verification of the heap-vtable reuse fix itself still requires a host with Agility SDK 1.620+ loaded.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3D12.X: a direct list at a released compute list's heap vtable address gets the compute list's methods

8 participants