D3D12.X: patch assert-checked vtables in place under Wine (#175) #2477
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2477
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2477"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@gustavsi on GitHub · 2026-11-25 19:43 UTC · original
gustavsi:wine/vkd3d-inplace-vtables→main· +830 −52 · 9 files · 2 commits · openPatch
vkd3d-proton's assert-checked COM vtables in place under Wine so stock assertion-enabledvkd3d-protonbuilds (such as Proton Experimental) no longer abort on adopted heaps, resources, descriptor/query heaps, root signatures, pipeline states, and command signatures. Part of #175 and #1701.Stacked on #867; only the top commit (
94a05e53) belongs here. Carries forward the permitted implementation from closed #1395 (originally authored by @cmt8), composed cleanly with #867'sUnadoptGuard.Under Wine,
vkd3d-protonkeepsassert(iface->lpVtbl == &d3d12_*_vtbl)active even in release builds for these seven classes. Because their console slots sit inside the PC interface, patching their PC slots in place (saving the runtime's original function pointers inIN_PLACEfororig_fn) preserves the runtime's own vtable pointer and eliminates those aborts. All new paths are gated behindutil::under_wine(); native Windows behavior is unchanged.What is in it
crates/xcl/src/hle/d3d12x/real.rs:IN_PLACE/in_place_original/in_place_kind/patch_in_place(from closed #1395) forHeap,Resource,DescriptorHeap,RootSignature,PipelineState,QueryHeap, andCommandSignatureunder Wine.IN_PLACE_Nis published withOrdering::Releaseandregister()runs before each changed slot is written via an alignedAtomicUsize::store(..., Ordering::Release).UnadoptGuard::newskip vtables patched in place (in_place_original(cur, 0).is_some()) soext[-1]is never dereferenced on runtime-owned vtables.in_place_tests:a_vtable_patched_in_place_keeps_its_originals_and_its_neighbourconcurrent_calls_and_patches_on_readonly_vtable_never_tear_or_miss_orig_fn(4 caller threads continuously invoking slot #1 through aPAGE_READONLYvtable while 2 patcher threads race to callpatch_in_place, with a 10 s deadline instead of a fixed iteration cap so callers do not exit before the patch lands under--test-threads=4; verifies exact-once patching, zero torn entries ororig_fnmisses, andUnadoptGuard::newreturningNone).Tested
x86_64-pc-windows-msvc(clang-cl+lld-link).Proton - Experimentalvkd3d-protond3d12core.dllcontainingiface->lpVtbl == &d3d12_heap_vtblassertions; also independently reproduced by @ClosetPie107 on RX 9070 / stock Proton Experimental and by @Royalflamejlh on RTX 4070 / assertion-enabledvkd3d-proton):#867(without this PR):--exact gpu::recomp::tests::gpu_sparse_vram_descriptors_buffers_and_xmemaborts immediately withAssertion failed: iface->lpVtbl == &d3d12_heap_vtbl, file ../src-vkd3d-proton/libs/vkd3d/vkd3d_private.h, line 1077(exit3).#867:real::passed with0assertions,gpu_sparse_vram_descriptors_buffers_and_xmem+gpu_valu_float_and_intpassed2/0with0assertions, and a 20 s retail title run exited0with337frames shown and all 7 assert-checked classes patched in place.94a05e53(rebased ontomain08db8020+ updated#867e57cb659, with @Royalflamejlh's time-bounded test loop fix) underGE-Proton11-14:real::in_place_tests real::wine_vtable_tests --test-threads=4(× 25 runs): 25/25 passed (5 passed, 0 failed, 0 ignoredeach, ~0.10 s/run)hle::d3d12x::real:: --test-threads=1: 64 passed, 0 failed, 0 ignoredpwsh ./scripts/smoke.ps1:13frames shown (PresentX 13,1 1 1/2 s),exit: 0x0,0crashes,0device removals.Regression run
Produced under Wine (
GE-Proton11-14, AMD Radeon RX 9060 XT,XCL_NETWORK=0 XCL_PSO_PRELOAD=0 XCL_RUN_SECONDS=60 XCL_ACTIVITY=1,VKD3D_CONFIG=""). The PR run used unmodifiedpwsh ./scripts/smoke.ps1via a thin Wine wrapper;main(e0d93c84) crashed before writingreport.json, so its block was extracted from the samexcl.log(peak commit: 0 MBis what Wine reports inxcl.log).main(e0d93c84):This PR (
94a05e53, stacked on #867):Not tested
util::under_wine()).vkd3d-protonby @Royalflamejlh, @wayback94, and @pickles976).AI use
concurrent_calls_and_patches_on_readonly_vtable_never_tear_or_miss_orig_fn, running the 25×--test-threads=4stress verification and 60 s smoke run, and drafting this update.@gustavsi on GitHub · 2026-11-25 20:32 UTC · original
Thanks @bmjask for the review! Addressed all three points at
0c249f08(rebased ontomaine0d93c84+ updated #867f98da36d):Proton - Experimentalvkd3d-protond3d12core.dllverified to containiface->lpVtbl == &d3d12_heap_vtbl):f98da36d, without this PR):gpu_sparse_vram_descriptors_buffers_and_xmemaborts withAssertion failed: iface->lpVtbl == &d3d12_heap_vtbl, file ../src-vkd3d-proton/libs/vkd3d/vkd3d_private.h, line 1077(exit3).0c249f08):hle::d3d12x::real::63/0,gpu_sparse_vram_descriptors_buffers_and_xmem+gpu_valu_float_and_int2/0, and a 20 s retail title run exited0with 337 frames shown (337 PresentX), all 7 assert-checked classes (ID3D12Heap1,ID3D12Resource2,ID3D12DescriptorHeap,ID3D12RootSignature,ID3D12PipelineState,ID3D12QueryHeap,ID3D12CommandSignature) patched in place and0assertions.in_place_tests::concurrent_calls_and_patches_on_readonly_vtable_never_tear_or_miss_orig_fn— 4 caller threads continuously invoking slot #1 through aPAGE_READONLYvtable while 2 patcher threads race inpatch_in_place(verifies exact-once patching, zero torn entries ororig_fnmisses, andUnadoptGuard::newskipping the patched table).e0d93c84+ updated #867, verified with a fresh 60 spwsh ./scripts/smoke.ps1run (exit: 0x0,22frames,0crashes,0removals).@DavidM1911 on GitHub · 2026-11-25 20:34 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!
@ClosetPie107 on GitHub · 2026-11-25 21:03 UTC · original
Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head
0c249f08137161fc48e018cfffc179c65339f304(merged cleanly ontomain6d12f58) on stock, unmodified, assertion-enabled Proton Experimentalvkd3d-proton.Hardware & environment
experimental-11.0-20261112), stock assertion-enabledd3d12core.dll(sha256: 9356501320114773be279506644aabd9a1717ff451d480ac802a4fd4e94b2576, verifiediface->lpVtbl == &d3d12_heap_vtblassertions present), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnu(debug for tests, release for retail)Unit / GPU tests (
XCL_REQUIRE_GPU=wave64,XCL_DXC_DIR,VKD3D_CONFIG=ignore_shared_fence)hle::d3d12x::real:: --test-threads=1 --nocapture: 63 passed, 0 failed, 0 ignored (0 skipped, 0 assertions; includes bothin_place_tests)hle::d3d12x::alloc_pool:: --test-threads=4 --nocapture: 4 passed, 0 failed, 0 ignored (0 skipped, 0 assertions)--exact gpu::recomp::tests::gpu_sparse_vram_descriptors_buffers_and_xmem gpu::recomp::tests::gpu_valu_float_and_int --test-threads=1 --nocapture: 2 passed, 0 failed, 0 ignored (0 skipped, 0 assertions)hle::d3d12x(--test-threads=4and--test-threads=1): 0 assertions and 0 aborts — all 7 assert-checked classes (ID3D12Heap1,ID3D12Resource2,ID3D12DescriptorHeap,ID3D12RootSignature,ID3D12PipelineState,ID3D12QueryHeap,ID3D12CommandSignature) patched in place cleanly. (12–13 subsequent GPU tests in the full module run failed after an unrelatedradv/amdgpu: The CS has been rejectedpoisoned the singleton device on stock Proton'svkd3d-proton.)Retail title (60 s, stock assertion-enabled Proton Experimental
d3d12core.dll)XCL_DIRECT_DXIL=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_PSO_WAIT_MS=50,XCL_SPLIT_MIDLIST_WAIT=0,XCL_COHERENT_MB=1024,VKD3D_CONFIG=ignore_shared_fence,XCL_PSO_PRELOAD=0,XCL_NETWORK=0exit=0) with 0 assertions, 0 crashes, and 0 device removals:1,200+frames presented at30.0 fps,11,962translated draws,2,048dispatches,1,031Opus packets (0 errors),10.25 GiBpeak VRAM,8.1 GiBpeak RSS.vkd3d-protonclasses loggedwritten into the runtime's own vtable.Not tested
vkd3d-proton.AI use
main, swapped in stock Proton Experimentald3d12core.dll, ran the tests and 60 s retail run on this machine, and drafted this report.@gustavsi on GitHub · 2026-11-26 00:52 UTC · original
Thanks @ClosetPie107 for the independent AMD RDNA4 verification on stock assertion-enabled Proton Experimental (60 s at 30.0 fps, 0 assertions, 0 crashes) and @DavidM1911 for verifying on Windows 11!
Rebased onto
main(08db8020) + updated #867 (e57cb659, picking up theUnadoptGuardCOM reference pin and alignment guard) at96b91da5:GE-Proton11-14(RX 9060 XT):real::64/0,alloc_pool:: --test-threads=44/0,gpu_sparse_vram_descriptors_buffers_and_xmem+gpu_valu_float_and_int2/0, plus a fresh 60 spwsh ./scripts/smoke.ps1run (exit: 0x0,11frames shown,0crashes,0removals; block updated in PR description).AI use: Antigravity (Gemini 4 Neon) rebased onto
main+ updated #867, ran the Proton tests and smoke run, and drafted this comment.@DavidM1911 on GitHub · 2026-11-26 01:50 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@gustavsi on GitHub · 2026-11-26 02:16 UTC · original
Thanks @Royalflamejlh for the assertion-enabled
vkd3d-protonRTX 4070 verification and for tracking down the--test-threads=4flake, and @DavidM1911 for the Windows 11 re-verification!Applied the suggested 10 s deadline loop in
concurrent_calls_and_patches_on_readonly_vtable_never_tear_or_miss_orig_fnat94a05e53:real::in_place_tests real::wine_vtable_tests --test-threads=4(× 25 runs underGE-Proton11-14, RX 9060 XT): 25/25 passed (5 passed, 0 failed, 0 ignoredeach, ~0.10 s/run).hle::d3d12x::real:: --test-threads=1: 64 passed, 0 failed, 0 ignored.pwsh ./scripts/smoke.ps1run:exit: 0x0,13frames shown (1 1 1/2 s),0crashes,0device removals (block updated in PR description).AI use: Antigravity (Gemini 4 Neon) applied the time-bounded loop fix, ran the 25× stress test and smoke run, and drafted this comment.
@bmjask on GitHub · 2026-11-25 20:17 UTC · original · reviewed
No confirmed code-level defect found, but this is high-risk and not merge-ready. The target validation gap is material: the intended assertion-enabled stock Proton/vkd3d-proton scenario was not reproduced directly; the author run used GE-Proton with assertions disabled. Please reproduce it before merge. Also, the shared runtime vtable is patched while other threads may call it; aligned entry stores are relied upon, but there is no concurrent call/patch stress test despite the process-wide blast radius. Finally, the branch is dirty/non-mergeable and stacked on #867, so it needs a rebase and refreshed CI/test evidence.
@Royalflamejlh on GitHub · 2026-11-26 01:50 UTC · original · requested changes
The new test
concurrent_calls_and_patches_on_readonly_vtable_never_tear_or_miss_orig_fnfailed on0c249f0under Wine in 3 of 21 runs ofreal::in_place_tests real::wine_vtable_tests(4 tests) at--test-threads=4, the countscripts/test.ps1uses, atreal.rs:8070("callers must observe the patched hook"); alone and at one thread it passed 10 of 10 each. The test is unchanged at the rebased head96b91da(the loop and the assert are now at:8058and:8097); we have not rerun it there. The change itself works on Linux + NVIDIA: on a vkd3d-proton built with assertions on and without XCL's relaxed-vtable patch, #867 alone aborts before the first frame and #2477 on top runs.The callers stop after 20,000 calls each (
:8058at96b91da), so if the patch lands after they finish,hook_hitsstays 0 (a reading of the test). With the loop bounded by time instead, the same 4 tests passed 25 of 25 runs at--test-threads=4here, each in 0.02–0.04 s: the callers still stop once the hook has been seen, so the 10 s only bounds a failing run:Setup:
maine0d93c84(the commit this head is rebased on) + #684e56dbc3, then + #867f98da36, then + #24770c249f0. RTX 4070 12 GB (615.71.09), Fedora 44, Wine 11.21 Staging, release, Series X profile, 100 s,XCL_PSO_PRELOAD=0. vkd3d-protonv3.1-90-g30b0eb9bwithout the relaxed-vtable patch, assertions on (d3d12core.dll5b59f1b8…) and off.Assertion failed: iface->lpVtbl == &d3d12_heap_vtbl(vkd3d_private.h:1078), 0 frames86a10c6,c79e3b3) gave the same pattern on the assertion build: the base and #867 aborted in 2 of 2 runs each, and #2477 ran in 3 of 3.Not tested: Proton's own build; the suite; Windows.
AI use: Claude Code (Claude Opus 5.5) ran the title and the tests, tried the fix and wrote this comment.
@Alm0stSurely on GitHub · 2026-11-26 08:36 UTC · original · edited 2026-11-26 09:01 UTC
Tested on an RTX 5080 16 GB, NVIDIA 620.73.04, Linux, stock Proton Experimental (vkd3d-proton
cae8353, assertions enabled). One direct title run per revision, fresh prefixes and cold caches, same synthetic profile. Built withcargo build --locked --offline --release --target x86_64-pc-windows-gnu -p xcl --bin xcl. Ranxcl.exe run <title-directory>withVKD3D_CONFIG=single_queue,XCL_PSO_PRELOAD=0,XCL_ACTIVITY=1,XCL_NETWORK=0, a 60 s time limit and the same host memory guards.e57cb659(#867): the stock driver stopped on its heap vtable assertion before PresentX, exit 3.94a05e53(#2477): the log shows the in-place path on all seven object classes, then PresentX, a 3840×2160 swapchain and the first-frame message. The last draw counter was 256 translated draws, zero skipped. The capture showed a black window with no identifiable game scene.The parent started with 14,308 MiB free VRAM; this run started with 10,883 MiB. The local guard ended the latter at 5,045 MiB free (cutoff 5,120), about 14 s after preflight. This verifies the heap fix on this Proton build. World rendering, stability beyond that point and gameplay FPS remain unmeasured.
Follow-up on
nvidia-dev(af2cecc4), same RTX 5080 and stock Proton. The unmodified branch exits 3 on the heap identity assertion ingpu_placed_console_depth_target_with_clear_value. With the Wine heap/resource changes ported locally onto that head, the same GPU test passes in 0.79 s, with no skip (dedicated allocation fallback for the depth target). WithXCL_PREPARE=0for a direct cold title run, the next stop is the shared-fence identity assertion before PresentX. This local port covers the object classes changed here and does not carry the fence changes from #867.AI use: OpenAI Codex (gpt-6.2-astra) ran the comparison, checked the logs and capture, and wrote this report.
@safesearch77 on GitHub · 2026-11-26 14:10 UTC · original
Reviewed
94a05e53againstmain(b49be183) with#867(e57cb659) as its first commit. Theorder in
patch_in_place(publish theIN_PLACEentry andregister()before the first store,then one atomic store per entry) is right, and
orig_fnreads the saved entries lock-freeagainst that. One test gap:
The last assertion of
concurrent_calls_and_patches_on_readonly_vtable_never_tear_or_miss_orig_fncannot fail in the
CIjob.assert!(UnadoptGuard::new(obj_addr as *mut c_void).is_none(), "UnadoptGuard must skip in-place patched vtables")is meant to cover the new|| in_place_original(cur, 0).is_some()check inUnadoptGuard::new. Butnewstarts withif !crate::util::under_wine() || ... { return None; }, andunder_wine()is awine_get_versionlookup inntdll(util.rs:126), false on the Windows runner. So onCInewreturnsNoneon its first line and the assertion passes whether or not the skip exists;it only means something when someone runs the test under Wine. The
#867test avoids this bycalling the
#[cfg(test)] enter, which has no skip.Moving the condition into a small helper (
fn skips_guard(cur: usize) -> bool { !is_ext_fast(cur) || in_place_original(cur, 0).is_some() }, used bynew) and asserting on that in the test wouldmake the skip checked on Windows too.
Read only (
git apply --check, source); no GPU, Wine or Windows run.AI use: Antigravity (Claude Sonnet 5.5) read the diff and the call sites; I re-checked the point
against the source before posting.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.