Skip to content

D3D12.X: under Wine, vkd3d-proton's assert-checked classes keep their vtable - #1395

Open
cmt8 wants to merge 1 commit into
xcl-dev:mainfrom
cmt8:wine-inplace-vtables
Open

cmt8 wants to merge 1 commit into
xcl-dev:mainfrom
cmt8:wine-inplace-vtables

Conversation

@cmt8

@cmt8 cmt8 commented Nov 24, 2026

Copy link
Copy Markdown

Under Wine, XCL writes its PC slots into vkd3d-proton's own vtables for the seven classes vkd3d-proton checks only by assertion, so those objects keep their vtable pointer. Part of #175.

vkd3d-proton accepts heaps, resources, descriptor heaps, query heaps, root signatures, pipeline states and command signatures only with its own vtable: assert(iface->lpVtbl == &…_vtbl) in each of their methods (vkd3d_private.h). The official release builds keep the asserts, so XCL's adoption, which replaces the vtable pointer, ends the process at the first heap. A guard around host calls cannot fix that (see the 14:12Z comment on #867): the asserts sit in the objects' own methods.

This complements #867: #867 covers allocators and lists (run-time checks) and fences; this covers the assert-only classes. Neither alone runs on a stock release build.

What is in it

  • One commit, crates/xcl/src/hle/d3d12x/real.rs (+152 / −2): patch_in_place, in_place_kind, in_place_original; class_for patches in place only when the object answers QueryInterface for the PC interface with itself and every slot up to that interface's method count is in the runtime's module. Everything is behind util::under_wine().
  • Unit test real::in_place_tests::a_vtable_patched_in_place_keeps_its_originals_and_its_neighbour (no GPU).

Tested

  • RX 7900 XTX, Mesa 26.3.1 RADV, Ryzen 7 7800X3D, kernel 7.3.5, Wine 11.22, DXVK 3.1.1 dxgi, DXC 1.9.2609.5, rustc 1.100.0, x86_64-pc-windows-gnu, debug.
  • vkd3d-proton: the official v3.1 release, assertions on (sha256 d3d12.dll 502694a5…, d3d12core.dll 0dfd690a…).
  • cargo test --workspace --target x86_64-pc-windows-gnu --no-fail-fast -- --test-threads=4, aborted binaries rerun one test per process; no SKIPPED:
main 930e8b4 this PR fd97d91 this PR + #867 (rebased locally)
whole suite: passed / failed / aborted / ignored 734 / 6 / 11 / 41 735 / 9 / 8 / 41 744 / 6 / 4 / 41
test title 6 [PASS], abort: heap assert (1077) 30 [PASS], abort: fence assert (705) 33 [PASS], abort: fence assert (772)

Regression run

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD Radeon RX 7900 XTX (RADV NAVI31)
title: game
seconds: 60
exit: 0x0
frames shown: 1469 (PresentX 1469)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

This PR:

xcl-smoke v1
commit: fd97d91e6c09532dfeb130280bf34201c6e28721
gpu: AMD Radeon RX 7900 XTX (RADV NAVI31)
title: game
seconds: 60
exit: 0x0
frames shown: 1488 (PresentX 1488)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

  • Windows (no Windows machine; the change is inert there by under_wine()), NVIDIA, Intel.
  • Proton's Wine and Proton's vkd3d-proton. vkd3d-proton master ec20719 was read, not run: same seven tables and asserts.
  • A retail title on a stock release build: it needs this PR and D3D12.X: preserve native vtables and wrap fences for vkd3d-proton under Wine (#175) #867 together.
  • The lock that makes in-place classes one at a time has no test; the race it closes was found by reading, never observed.

AI use

  • Claude Code. Code and tests written by Claude Opus 5.5 agents, supervised and reviewed by Claude Mythos 5.2; the description was written by Claude Mythos 5.2. Runs were made on my hardware.

🤖 Generated with Claude Code

https://claude.ai/code/session_019twRmV74bPu5j5TBXjrNug

… vtable

vkd3d-proton takes a heap, resource, descriptor heap, query heap, root signature, pipeline state
or command signature only with its own vtable: an assert(iface->lpVtbl == &..._vtbl) in each of
its methods and wherever one is passed in (vkd3d_private.h). The official release builds keep
these asserts, so adoption, which replaces the vtable pointer, ends the process (status 3) at
the first such object: under Wine with the v3.1 release DLLs the test title stops at its first
heap after 6 checks.

Under Wine (util::under_wine) these classes now get XCL's PC slots written into the runtime's
own table instead (VirtualProtect, as XAudio2's patch does), only up to the PC interface's
method count, and only when the object answered QueryInterface for that interface with itself
and every slot up to there is in the runtime's module. orig_fn finds the entries from before
by the table. Classes are made one at a time, so no thread scans a table another is writing.
The table is shared by every object of the class (swap-chain buffers too); the overrides
already take objects XCL did not create. These classes have no console slots past the PC
interface, so nothing is lost there.

Not covered, by design: fences (console xcl-dev#12 is past the PC table), command allocators and
lists (vkd3d-proton checks those at run time, E_INVALIDARG; xcl-dev#867 handles them), bundles. On
Windows nothing changes: every new path is behind under_wine(), and orig_fn's lookup has no
table there.

Part of xcl-dev#175.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head fd97d91 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: a_vtable_patched_in_place_keeps_its_originals_and_its_neighbour.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@TobiasFornell

Copy link
Copy Markdown

Tested #1395 together with #877 (2dc68c2, which includes #867/#871) plus your composition hint (UnadoptGuard::new skips in-place patched tables) on stock Proton Experimental 11.0-20261112's own vkd3d-proton 3.2.0 (assert-enabled), RX 9070 XT (RDNA4) / RADV 26.3.1, title 1.0.2.1. This covers the two items listed as untested in the description (Proton's own vkd3d-proton, and a retail title on a stock release build with #867 together).

Testing and write-up assisted by Claude (AI); runs on my own hardware.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…in-place vtables

Integrates 16 upstream PRs (ivall#1380, ivall#1383, ivall#1384, ivall#1395, ivall#1398, ivall#1400,
ivall#1404, ivall#1405, ivall#1419, ivall#1420, ivall#1421, ivall#1423, ivall#1424, ivall#1427, ivall#1428, ivall#1429)
on top of the Linux/Proton fork, plus three Proton/vkd3d-proton fixes
caught during verification:
- Recompiler (ivall#1428): flatten IO_GROUP_LIMIT early-return in compute
  shaders so vkd3d-proton v3.1 dxil-spirv accepts the emitted CFG.
- D3D12.X (ivall#1395 + ivall#867): skip UnadoptGuard on in-place-patched vtables
  and restore native vtables in runner::submit_list when a prior test
  adopted the singleton ID3D12Device.
- Tests: match Wine centered default in window_position_modes.

Verified under GE-Proton11-14 (RX 9060 XT / RADV):
- gpu_sparse_vram_descriptors_buffers_and_xmem + gpu_valu_float_and_int
  + window_position_modes: 3 passed, 0 failed
- Broad sweep (present, real, sparse, clamp, dstorage, gpu_valu,
  gpu_typed_buffer): 82 passed, 0 failed, 1 ignored, 0 skipped
- 2.5 min retail title run (XCL_MEM_LIMIT=12G): 3,000+ frames at 30.0
  fps, 6.0-6.1 GB flat committed RAM, 6.4 GB local VRAM, 0 DS failures.
@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, ~21 ignored.

Thanks!

@nicklin11

Copy link
Copy Markdown

Test report for #867 and #1395 (each head, and the two together), on RDNA2 / RADV under Wine (the test suite only, no game run).

Tested

  • AMD Radeon RX 6700, non-XT (RDNA2, 10 GB; RADV / Wine report the adapter as "RX 6700 XT", 10224 MiB), Mesa 26.3.1 RADV, Core i3-12100F, 15 GB RAM, kernel 7.3.5, Arch Linux.
  • Wine 11.22 (Staging), official vkd3d-proton v3.1 release with assertions on (sha256 d3d12.dll 502694a5…, d3d12core.dll 0dfd690a…), DXVK 3.1.1 dxgi, DXC 1.9.2609, rustc 1.100.0, x86_64-pc-windows-gnu, debug.
  • Every test in its own process (wine <test exe> --exact <name> --test-threads=1, 4 at a time), because a vkd3d-proton assertion ends the whole process. All 17 test targets of the workspace, whole suite per tree.
  • Three trees, all on main b7aa9f3 (D3D12.X: preserve native vtables and wrap fences for vkd3d-proton under Wine (#175) #867's head 6e94390 is based on it, so it needed no rebase):
main b7aa9f3 #867 6e94390 #867 + #1395 fd97d91 + guard skip (90b4b21)
tests 811 813 814
passed 749 753 763
failed 7 6 7
aborted 12 11 1
ignored 41 41 41

(passed includes 2 tests that print SKIPPED and pass: test_title_draws_with_a_root_signature_under_the_debug_layer, uploads_start_from_each_subresources_state)

The third column merges the two heads (textually clean) and adds the two-line change @cmt8 described in #1395's discussion, UnadoptGuard::new returning None when in_place_original(*(obj as *const usize), 0).is_some(). That change is mine, applied by hand and not reviewed by them.

Joined per test against main:

Not tested

AI use

  • Claude Code, Claude Sonnet 5.5: built and ran the suite, merged the two heads, wrote this report. I read it before posting.

@wayback94

Copy link
Copy Markdown

Test report for #867 and #1395 on NVIDIA under Wine, with Proton Experimental's own vkd3d-proton (assertions on). The test suite only, no game run.

With #867 (a4c5a82) and #1395 (fd97d91) together, plus the guard skip @cmt8 suggested, no vtable assertion is left in the suite on Proton's own vkd3d-proton, on an RTX 3080. That removes 12 aborts. The e2e test title now gets past the d3d12_heap_vtbl assertion and fails only on the two checks it fails on the patched build too. Neither PR alone is enough. On the patched vkd3d-proton (#257), both together change no test result.

Tested

tree / prefix tests passed failed aborted timed out ignored
A main, stock 1148 1083 5 14 0 46
B #867, stock 1150 1087 4 13 0 46
D #1395, stock 1149 1086 7 10 0 46
C #867 + #1395, stock 1151 1098 5 2 0 46
A main, patched 1148 1093 8 1 0 46
C #867 + #1395, patched 1151 1096 8 1 0 46

"Passed" includes 14 tests that print SKIPPED and pass, the same 14 on every tree:

  • 11 no wave64 (wave64 variants in gpu::recomp::lower / lower_dxil / tests);
  • lower_dxil::tests::f16_programs_on_the_gpu: the wave32 per-lane form is refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's));
  • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows);
  • pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache (Windows Developer Mode is required): Not implemented. (0x80004001)).

Per test against main on the stock prefix. Every result that differs between A and C was rerun 3 more times on both trees, and all 3 gave the same result each time:

  • Aborts on main, stock: 11 at vtable assertions (d3d12_fence_vtbl ×4, d3d12_heap_vtbl ×3, d3d12_root_signature_vtbl ×2, d3d12_resource_vtbl ×2), plus mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares (exit 5) and the two below that aren't about vtables. The e2e test fails because its title hits d3d12_heap_vtbl (vkd3d_private.h:1077).

  • D3D12.X: preserve native vtables and wrap fences for vkd3d-proton under Wine (#175) #867 alone: a_recording_outlives_the_reset_of_the_titles_allocator goes from failed to passed. mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares goes from aborted to passed. Its two new tests pass. The fence assertions are gone, and the heap / resource / root-signature ones remain (d3d12_heap_vtbl ×4, d3d12_root_signature_vtbl ×4, d3d12_resource_vtbl ×3).

  • D3D12.X: under Wine, vkd3d-proton's assert-checked classes keep their vtable #1395 alone: the heap / root-signature / resource assertions are gone, and its new test passes. The fence assertions remain (d3d12_fence_vtbl ×7). Two tests go from an abort to a failure: gpu_sparse_vram_descriptors_buffers_and_xmem (tests.rs:3993) and create_list_reset_and_clear_state_track_initial_pso_on_d3d12 (bind.rs:1501). Both pass on C.

  • Both together: all vtable assertions are gone. These 11 go from aborted to passed:

    • gpu_compute_e2e ×2
    • sparse_reinit
    • gpu_sparse_vram_descriptors_buffers_and_xmem
    • create_list_reset_and_clear_state_track_initial_pso_on_d3d12
    • mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares
    • gpu_placed_console_depth_target_with_clear_value
    • passthrough_mesh_stream_accepts_a_triangle_driver_blob
    • title_textures ×2
    • vram::d32s8_targets_take_their_own_size_of_video_memory

    a_recording_outlives_the_reset_of_the_titles_allocator goes from failed to passed, and all three new tests pass. No test that passes on main fails or aborts.

  • predication_e2e::set_predication_buffer_state_and_kickoff goes from an abort (d3d12_resource_vtbl) to a failure (EQUAL_ZERO(0) must skip dst[0], predication_e2e.rs:360), as @nicklin11 saw on RADV. It fails the same way on main with the patched build, so the assertion was only hiding it.

  • e2e on C, stock: the title runs, and the test fails on the same two checks as on the patched build (user32 … W: not cloaked, XMA2 GetState: ctx=0x0, queued=1).

  • C on the stock prefix without VKD3D_CONFIG=ignore_shared_fence: the same result for all 1151 tests as with it.

Not about these PRs, the same on every tree:

Not tested

AI use

  • Claude Code (Claude Opus 5.5) built the trees, made the prefix, wrote the per-test runner and the script that counts and compares its output, ran the tests and wrote this report.

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.

6 participants