Wine: raw internal fences + native-vtable guards at host-runtime calls (rebased on amd-dev) #3099
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3099"
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?
Imported from ivall/xcl. Originally posted by crazymanjared on 2026-11-28T05:10:03Z.
What
Makes XCL's internal D3D12.X object usage correct against a host vkd3d-proton that identifies its own objects by vtable-table equality — which is exactly what happens when XCL runs on Wine with d3d12/d3d12core as native vkd3d-proton DLLs. Two violation classes, 6 commits, each a single-variable step. Run data for every claim lives in #846 (I'm
crazymanjaredthere; the run-numbered entries in commit messages map 1:1 to that thread).Rebased 2026-11-29: the branch is now the guard/fence stack ported onto current
amd-dev(36e16cf4, includes #3369 and thesubmit_thread/#3304split-entry machinery) as 6 clean commits. The previous 7c-based head (fe6a8c26, a 292-commit face against the then-base) is superseded; everything it proved still stands, see Results.Why this fails on Wine today
d3d12_command_list_from_iface-style checks comparelpVtblagainst its own embedded/default/profiled tables and return NULL for ext-table objects; several call sites then dereference without a NULL check. Bareamd-dev(7c-era, same face as runs 85/86 on the 8942 base) dies at title boot on Wine withE_INVALIDARGint-3 (game+0x2478b7b/game+0x2474ce1), 0.5 s after prep completes, 0 presents — deterministic 2/2. WithoutUnadoptGuard(git log -S UnadoptGuardfinds nothing upstream) nothing else on this path is even testable.FenceProxyobjects reaching the host submission path. vkd3d-proton's submission worker blind-casts fences it receives — a vtable-swapped proxy faults. XCL hands fences into queue Signals from the vram retire/seal machinery (vram.rs, run88 wall at t22.783) and from sparse copy-back submits (GreemSC hit the same class independently — #846 comment 7225087672).vkd3d_submission_has_query_reset_hazardcallsd3d12_command_list_from_iface(command_lists[i])and dereferenceslist->query_ranges.countwithout a NULL check — an XCL ext-table list in an ECL batch = AV read atNULL+0x2b28(observed atd3d12core+0x4c75d7, run 87 at t126.817 on the 8942 base). This PR makes XCL's sparse readback/upload lists and allocs unwrapped runtime objects at creation; a host-side NULL check next to that scan would be the complementary fix.The stack (on amd-dev
36e16cf4)ec26e0accreate_raw_fence(orig-slot pattern) — helper for everything below; the tree has the vtable machinery but not this helper48438cddUnadoptGuard+FenceProxycore: guard machinery (fast tables, orig-fn native-table passthrough) + guarded host-call sites (CreateCommandList, placed resources, heap, RTV, PSO bind, allocator Reset incl.reset_pc_allocator, ExecuteCommandLists both paths) + queue Signal/Wait fences unwrapped (queue_signal_now/queue_wait_now/ PC-caller entries)dfeaac47list_x/alloc_poolsites: kickoff_x exec/reset, split/deferred_segment/record_deferred/reset_list guards + sync-graph, copy_scratch and alloc_pool.executed fences →create_raw_fencee9e44984CLASSESlock conversion from the RwLock switch (compile follow-up)66a49b3cnew_stateupload slots / rb list /take_or_alloc_rb_job— kills the query-hazard class (3) at the sourceb8ec6a4fvram.rs: device-queue signal + heap-retirement fence sites →create_raw_fence(run88 wall:signal_device_queuesfanned FenceProxy ptrs into queue Signals → dual AV)Rebase notes (deltas vs the 7c-era face): the XG
CopyFromSubresource7-arg ABI commit is gone as content — current amd-dev carries the newer 4-argument-copy_argsform natively;readback_after's bounded-wait guard is gone — the function was refactored into the async rb-queue design;ExecuteCommandListsnow goes through the base's caller-split entries with the UnadoptGuards kept inside both branches;queue_wait_nowgained the fence unwrap the base only had on the Signal side.Results on Wine (GE-Proton11-14, RX 6950 XT / RDNA2, vkd3d-proton master, RADV 26.3.1)
Every commit's content is proven by an actual GTA6 title run on this box (run numbers in messages ↔ #846), first on the 7c lineage, then re-proven end-to-end on the 8942 lineage:
48438cdd-class guards (run87): boot assert cleared, hazard wall reached66a49b3c-class raw lists (run88): hazard wall passed, 764 list-writes, zero from_iface faultsb8ec6a4f-class vram raw fences (run89): all walls cleared — world entry, 30 fps cruise, 3,046 presents, first presenting in-world run on this hardwareThe rebased chain here compiles clean (
cargo build --release -p xcl --target x86_64-pc-windows-gnu, 0 errors); the run-proven trees it ports from are runs 87–90. Not NVIDIA/Windows-tested — these paths only activate where the host runtime is vkd3d-proton under Wine, so Windows/NVIDIA behavior should be untouched by construction (guards adopt/unwrap only in ext contexts); would appreciate a maintainer sanity pass on that framing.Follow-up candidates (deliberately NOT in this PR):
sparse.rs's async-rb fences on the new base (lines ~2948/~4041,dev.CreateFence— the FenceProxy design may cover them, pending our own fault data on this base);vram.rssite ~917 (unported, no observed face).Review request: @GreemSC — you independently hit class (2); a second pair of eyes on the vram + ECL guard sites would be great. @tiagonleal — per #846 this is the guard-set landing place including the
Reset(allocator, pso)coverage you asked for (reset_pc_allocatorwraps the raw allocator reset inUnadoptGuard).Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-29T18:37:17Z.
merge-check
base:
36e16cf44dhead:
b8ec6a4fc3merge: clean (the head sits on
amd-dev36e16cf4; tested as it is)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2153 passed, 18 failed, 48 ignored; SKIPPED: 23; failing: 15 distinct tests, every one of which also fails on the base on this PC (base alone, one run: 2141 passed, 30 failed, 48 ignored, 27 distinct).
amd-devis not clean on NVIDIA here to begin with (the fourfuzz_validate_and_gpu_*,gpu_fract_f32_edges,f32_programs_on_the_gpu, severalsparseandtitle_texturestests withPoisonErrorafter a first failure), so this says "no new failure in one run", not more.review: whole diff read (+439/-49). You asked whether Windows is untouched by construction. Partly. Three things are behind
under_wine():UnadoptGuard::newreturnsNoneoff Wine (real.rs:963), fences are wrapped in aFenceProxyonly under Wine, andunwrap_fencedoes nothing off Wine. These are not gated, and run on Windows too:q_execute_command_listsnow sends every submit made insideown_work()straight to the PCExecuteCommandLists(real.rs, the new|| is_own_work()at the top). On the base those submits went on through the rest of the function. The comment gives a deadlock reason that has nothing to do with Wine, and the commit table in the description does not list it. It deserves its own PR or at least its own line, with what bookkeeping it now skips.create_raw_fence(real.rs:5054) takes the originalCreateFenceslot whenever the device is adopted, which it is on Windows. So the fences of the sync graph,copy_scratch,alloc_pool.executed, the device-queue signal and the heap retirement invram.rs, anddrain_gpuare no longer adopted on Windows either, and theirSignalno longer goes through the hookedfence_signal.create_raw_command_allocator/create_raw_command_list, used for the sparse upload and readback lists (sparse.rs), are unconditional in the same way.Signal/Waitoverrides (q_signal_pc,q_wait_pc), andreset_pc_allocatornow also callsconsole_list::allocator_reset.Whether 2 and 3 change anything that matters on Windows I could not settle by reading; if the base already makes those objects inside
own_work()they were never adopted anyway. Gating them onunder_wine()would make the claim true without that question. No test covers the raw objects or the new submit path, andUnadoptGuard::enter(#[cfg(test)]) is never called.For whoever merges: five of the six commit subjects start with
Local:and one says "Not for merge"; thePR descriptioncheck is red because the body has no Tested, Not tested and AI use sections and noxcl-smokeblocks; the body names the title.performance: on Windows a branch per guard site, an atomic load per vtable read, and
orig_fn+slot_ofon every queueSignal/WaitXCL makes.scripts/smoke.ps1 -Seconds 60(retail title, menus, release,XCL_PREPARE=0): this head 1709 frames, peak commit 13591 MB; base 1693 and 1707 frames, 12671 and 13174 MB. No difference outside the spread of the base. The menus do not exercise the sparse readback path much, and I did not run the world on this branch.verdict: not yet: the description check is red, and items 1 to 4 run on Windows although the description says nothing does; gate or justify them
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (617.42), AMD Ryzen 7 9800X3D, Windows 11 Pro 26300, rustc 1.100.0, debug suite and release smoke; nothing run under Wine / Claude Code: Claude Fable 5.2 ran the builds, suites and smoke; Claude Opus 5.5 read the diff.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:30:04Z.
Triage (#1607) – head
b8ec6a4This PR targets
amd-dev.UnadoptGuard,FenceProxyandcreate_raw_fenceare not onamd-devormain. #3492 makes the same Wine/vkd3d-proton fix againstmain: it ports #867 and #2477 and also adds in-place vtables, and its description points to this PR for the amd-dev side. The lines shared with #3111/#3112/#3335/#3361 are amd-dev history, not this change.No problems found in the diff (read the guard/fence code in real.rs). The swap of a shared object's vtable during a host call is the riskiest part, and it only runs under Wine.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:36:23Z.
Review (head
b8ec6a4f, diff read, not a merge-check; baseamd-dev, conflicts with it,PR descriptionred):create_raw_command_*,real.rs~5156 / ~5173,sparse.rs~1379, ~2802); #3492 guards those submits instead. Worth agreeing with #3492's author on one PR.create_raw_fence(~5054) and the raw list helpers skip adoption on Windows too, and the queue's Signal / Wait overrides are installed on every queue (~4330); #3492 now gates those onunder_wine().alloc_pool.rs,list_x.rs,real.rsandvram.rs, and itsallocator_resetchange is already on amd-dev.Fine: the Wine-only parts (
UnadoptGuard::new, wrapping and unwrapping of fences) are gated, and the Wine runs in the description show what it fixes.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.