Skip to content

D3D12.X: keep vkd3d-proton's vtables under Wine and wrap the title's fences (#175) - #3492

Open
Royalflamejlh wants to merge 1 commit into
xcl-dev:mainfrom
Royalflamejlh:fix/wine-native-vtables
Open

Royalflamejlh wants to merge 1 commit into
xcl-dev:mainfrom
Royalflamejlh:fix/wine-native-vtables

Conversation

@Royalflamejlh

@Royalflamejlh Royalflamejlh commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Under Wine, vkd3d-proton takes an object only with its own vtable, and XCL replaces the vtable of every object it adopts. This carries #867 and #2477 by gustavsi (both closed unmerged on 2026-11-29: "anyone is welcome to rebase and reuse these commits") onto the current main, as one commit with gustavsi as co-author. Part of #175 and #3067.

#3099 does the fence and guard part against amd-dev; this one is against main and also has #2477's in-place tables.

What is in it

  • real.rs: under Wine, heaps, resources, descriptor and query heaps, root signatures, pipeline states and command signatures keep the runtime's table, with XCL's PC slots written into it (D3D12.X: patch assert-checked vtables in place under Wine (#175) #2477). UnadoptGuard gives a list, allocator, heap or pipeline its native table back for the host call that takes it as an argument, and the title's fences are proxies unwrapped at the queue's Signal and Wait (D3D12.X: preserve native vtables and wrap fences for vkd3d-proton under Wine (#175) #867).
  • real.rs, list_x.rs, sparse.rs, alloc_pool.rs, vram.rs, present.rs, title_textures.rs, late_release.rs, cpu_writes.rs, bind.rs: the submit, reset and fence sites main has gained since those PRs (native_queue_execute, the sparse queues, the two-pass feedback poll, the own-work submit, the retire and upload fences) get the same guard or create_raw_fence.
  • One test new on main (gpu_clear_uav_of_a_stencil_uav_clears_the_twin) signalled a device fence on a PC queue; it takes a raw fence.
  • It is one PR of about 890 lines because the two halves cannot be tested apart on an unpatched vkd3d-proton: without the in-place tables the first heap ends the process in an assertion.

Tested

  • Linux only: Fedora 44, Wine 11.21 Staging, stock vkd3d-proton master 71cae091 (assertions on), RTX 4060 Ti 16 GB (driver 615.71.09), rustc 1.98.0, release build for x86_64-pc-windows-gnu. Base 9335bc0d, head 3bd9a664.
  • Head 0797336e (2026-12-01): under Wine the device's CreateSharedHandle and SetEventOnMultipleFenceCompletion hand vkd3d-proton its own fence too (one new test, with stand-in objects; not on a device or in a title). cargo test --lib -- fence vtable wine unadopt, RTX 4060 Ti: 57 passed, 0 failed in 5 of 6 runs; in the first, bind::tests::wait_oldest_fenced_reclaims_in_flight_buffer_before_refusing failed once while a title was running on the same card (it passes alone, 3 of 3).
  • Head 76427620 (2026-12-01), after a second review: UnadoptGuard::new and the tests now run the same body, so the Windows CI runs the shipped guard (the Wine-only guard test became a case of one that runs everywhere); the list of native tables warns once past its 64 entries, where it dropped a table silently. cargo test --lib -- fence vtable wine unadopt, RTX 4060 Ti: 56 passed, 0 failed. 997 added lines.
  • Head 313f55e8 (2026-12-01), after a review: the fence proxy's GetCompletedValue, SetEventOnCompletion and Signal are now main's hooks, run on vkd3d-proton's own fence (they went straight to vkd3d-proton before, so a title's fence skipped the readback settling main gained on 2026-11-25); fences XCL makes inside its own work are not wrapped; the queue's Signal / Wait overrides are under under_wine() again, so Windows takes main's path; three new tests. cargo test --lib -- fence vtable wine unadopt: 57 passed, 0 failed. --lib hle::d3d12x::real::: 178 passed, 3 failed (an_older_process_cannot_remove_a_replacement_blob, a_copy_of_a_destroyed_resources_view_is_the_null_view, dev_create_root_signature_strips_xbox_flags_and_keeps_parameters; all three fail the same way on the head before it). 1,042 added lines now. In a title, the change of this head on another tree that carries this pull request beside other unmerged ones (1 run each, 600 s asked, RTX 4060 Ti, XCL_GPU_PROFILE=1): with it 630 s, 1,880 frames, no crash, no device removal; without it 673 s, 1,520 frames, no crash. Not run in a title on this branch alone: the title numbers below are from the heads they name.
  • Rebased on 2026-12-01 onto main 7d86c5d2 (head ebc21f2e): main's CreateFence now drops console-only flag bits; the Wine path here passes the same cleaned flags. cargo test --lib -- fence vtable wine: 54 passed, 0 failed. The numbers below are from the heads they name.
  • Head 0f347f68 (2026-11-30): the cause of the rare trap with 4 test threads. Under vkd3d-proton every test gets the same device object, and some tests adopt it. A test that then makes a fence or a list from it gets XCL's proxy or an adopted list, and its own PC queue cannot take either. bind::tests::closed_list_replay_keeps_two_pass_buffer_across_fence_and_idle_trim beside create_list_reset_and_clear_state_track_initial_pso_on_d3d12 ended that way 10 of 12 times; with a raw fence and the guard at its two submits, 0 of 20, and hle::d3d12x::bind::tests at 4 threads ran through 10 of 10 (4 of 16 ended early before).
  • Head c817f425 (2026-11-30): bind::tests::execute_indirect_reads_the_arguments_written_before_it, a test new on main that adopts its list and submits it on a PC queue, takes the guard at that submit. It ended in the read at 0x2b28 on 19e8fd50 (found on an RX 9070 by ClosetPie107, below; the same here) and passes now.
  • Rebased on 2026-11-30 onto main f97120dc (head 19e8fd50): main's rewritten late-release seal and its InListReset in cl_reset conflicted; both keep the raw fence and the guards. On the new head the release build and these modules were rerun, with the same results as before: late_release 8 passed, real::wine_vtable_tests 4, real::in_place_tests 2, real::depth_uav_twin_tests 3, title_textures 65, sparse::tests 140, list_x::tests 101 passed and 3 failed (the three that fail on the base). The counts and title runs below are on 3bd9a664.
  • The hle::d3d12x unit tests, each test module in a process of its own with --test-threads=4 (96 modules, 1 pass of each tree; a whole-suite run ends early in a page fault on both trees):
base 9335bc0d this PR 3bd9a664
passed 1,013 1,172
failed 78 17
modules that ended in a page fault 2 (list_x::tests, tests) 1 (tests)

The base's list_x::tests ends after 5 tests in vkd3d-proton's list check (a read at 0x2b28); with this PR it runs through. hle::d3d12x::tests ends the same way on both, a null read after a D3D12SerializeRootSignature call with an invalid version. Of this PR's 17 failures, 15 fail on the base too; the other two are in list_x::tests, which the base does not get to in this pass, and both failed on the base in an earlier whole-suite run.

  • A retail title, same machine and vkd3d-proton, 1 run each (the base's launch pass translated from empty, this head's from the base's caches): on the base it ends at boot with 0 frames, a breakpoint at game+0x2478b7b with E_INVALIDARG in rax (the failure Wine: raw internal fences + native-vtable guards at host-runtime calls (rebased on amd-dev) #3099 describes); on this head it presented until the run's 300 s limit ended it (1,430 frames by then, lit, the last ones the loading pictures), with no crash and no device removal.
  • The same changes have been in our Linux branch (Linux (Wine + vkd3d-proton): status and tracking #3067), where a retail title reaches its world on this vkd3d-proton.
  • AMD under Wine, by ClosetPie107 (two reports below; RX 9070, RADV 26.3.1, stock vkd3d-proton master 71cae091, debug build): the lib suite at 2 threads without gpu:: and six tests that end the process or run out of memory there, 1,715 passed and 16 failed at 0f347f68 against 1,609 and 116 on the base f97120dc; no test fails with this PR that passes on the base.

Regression run

  • Not run yet: no Windows machine was reachable today. The two xcl-smoke blocks will be added.

Not tested

  • Windows: nothing. Each branch is behind under_wine(), but the suite and the smoke pair have not run there.
  • AMD on Windows; on RADV the gpu:: tests and a title run.
  • The title past its loading pictures on this head: the run was 300 s. Under Wine the title's own window is not hidden without user: hide title console window when DWM cloaking is unavailable (#175) #794, which this PR does not include.
  • Other tests that make a fence or a list from the shared device and submit on a PC queue of their own can still meet the same thing at 4 threads when a device-adopting test runs beside them (one run of hle::d3d12x::sparse::tests in 20 did on the first head). It is between tests: the title's device is always adopted, and its queues with it.

AI use

  • Claude Code with Claude Fable 5.2: carried the two commits onto main, ran the tests above and wrote this description. The merge resolutions it starts from were made on our Linux branch with Claude Opus 5.5.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) labels Nov 30, 2026
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 30, 2026
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Royalflamejlh
Royalflamejlh marked this pull request as ready for review November 30, 2026 03:31
@github-actions github-actions Bot added the needs-rebase Has merge conflicts with its base branch label Nov 30, 2026
@Royalflamejlh
Royalflamejlh force-pushed the fix/wine-native-vtables branch from 3bd9a66 to 19e8fd5 Compare November 30, 2026 03:46
@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-rebase Has merge conflicts with its base branch labels Nov 30, 2026
@ClosetPie107

Copy link
Copy Markdown

Test report for #3492 at 19e8fd50, against its base main f97120dc, under Wine. It wasn't run on Windows.

Tested

  • RX 9070 16 GB (RDNA4), Mesa 26.3.1 RADV, Ryzen 5 9600X, CachyOS. Proton Experimental experimental-11.0-20261112, stock vkd3d-proton master 71cae091. Debug build, x86_64-pc-windows-gnu.
  • Command: cargo test --locked -p xcl --lib --target x86_64-pc-windows-gnu -- <filter>, always with --skip gpu:: --skip failed_restore_stops_before_importing_an_unbacked_window --skip grooming_leaves_a_window_under_1_gib_only_its_hole (the last two run out of memory here).
f97120dc #3492 19e8fd50
hle::d3d12x:: at 2 threads 913 passed, 98 failed, then exit 5 at the crash below 471 passed, 10 failed, then the -14 CS rejection after list_x::…write_buffer_immediate_on_open_existing_heap_visible_to_cpu (the leak #1520 fixes; #3492 doesn't include it)
the lib suite at 2 threads, + #1520's test change (lab only) not run 886 passed, 12 failed, then -14 at real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state
the lib suite at 1 thread, + #1520's test change (lab only) not run 889 passed, 8 failed, no rejection, then exit 5 at the crash below
bind::…create_list_reset_and_clear_state_track_initial_pso_on_d3d12 alone fails (CreateCommandList refuses the list) passes
title_textures::…a_placed_texture_gets_the_pages_of_a_level_with_its_texels alone fails passes
bind::…execute_indirect_reads_the_arguments_written_before_it alone crashes crashes: access violation at d3d12core.dll+0x56215d, read of 0x2b28
  • Most of main's failures under Wine are gone with D3D12.X: keep vkd3d-proton's vtables under Wine and wrap the title's fences (#175) #3492 (98 → 10 in hle::d3d12x before the run ends). The cascade of refused list creations doesn't happen.
  • hle::d3d12x::sparse::tests at 4 threads, 20 runs: no trap in vkd3d-proton's list check. a_tile_of_a_gpu_view_shows_the_page_mapped_there failed 4 of 20 (!v.s.mapped.contains_key(&(w + TILE)), sparse.rs:12315). Alone it passed 20 of 20.
  • Crash that is not from this PR: hle::d3d12x::tests::serialize_root_signature_strips_console_flags_and_preserves_pc_flags crashes the process alone on f97120dc as well.
  • -14 at the coherent test: that test VirtualFrees memory while late_release still holds the resource. Under Wine that succeeds, and RADV rejects the next submission (Linux (Wine + vkd3d-proton): status and tracking #3067). That isn't from this PR either.

Not tested

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@Royalflamejlh
Royalflamejlh force-pushed the fix/wine-native-vtables branch from 19e8fd5 to c817f42 Compare November 30, 2026 12:58
@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 30, 2026
@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

@ClosetPie107 thank you, that is the run this needed. bind::tests::execute_indirect_reads_the_arguments_written_before_it crashes the same way here on NVIDIA at 19e8fd50. It is the test's own submit: it adopts its list (to record as XCL does) and then calls ExecuteCommandLists on a plain PC queue. c817f425 puts the guard around that submit, as #867 did for the older tests of that shape; it passes here now (RTX 4060 Ti, stock vkd3d-proton master 71cae091, 1 run alone).

One thing is still open and you may see it too: with 4 test threads, 1 of 4 runs of hle::d3d12x::bind::tests at c817f425 ended in the read at 0x2b28 (the other 3: 115 passed, 1 failed; main d52ff48c: 106 passed, 10 failed, 4 of 4). With one thread I have not seen it. The description says so under Not tested.

Your sparse::tests::a_tile_of_a_gpu_view_shows_the_page_mapped_there failure at 4 threads (4 of 20, never alone) I have not looked at yet.

AI use: Claude Code (Claude Fable 5.2) made the runs and wrote this.

Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 30, 2026
…submit (xcl-dev#3492 c817f42)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Royalflamejlh
Royalflamejlh force-pushed the fix/wine-native-vtables branch from c817f42 to 0f347f6 Compare November 30, 2026 13:30
@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 30, 2026
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 30, 2026
… list at its PC submits (xcl-dev#3492 0f347f6)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@ClosetPie107

Copy link
Copy Markdown

Test report for #3492 at 0f347f685f059f26749e8113f7ae8ff57af43bef, against its merge-base with main, f97120dc, under Wine on AMD.

Tested

Not tested

  • native Windows
  • NVIDIA
  • the gpu:: tests in the suite runs
  • the workspace's other crates and integration tests (only -p xcl --lib)
  • a game run (no regression block)

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head ebc21f2, diff read, not a merge-check: PR description fails (no smoke blocks, no Windows suite run), so not built or run here):

  • Under Wine, title fences skip XCL's fence hooks. The fence proxy's slots 8 / 9 jump straight to vkd3d-proton and slot 10 only forwards and notes (real.rs ~5147-5157), so title fences skip main's fence_get_completed_value (settle_readbacks_try, title_textures::safe_fence_value), fence_set_event_on_completion (async sparse readbacks) and the send_pending step in fence_signal (~4358-4362, ~12359-12440). A title could see a fence complete before its texture downloads or sparse readbacks have landed and read stale memory.
  • Windows changes too: the queue now overrides Signal / Wait (~4342, ~12241) outside under_wine(), so XCL's own Signal / Wait on adopted queues take the CLASSES lock through slot_of on every call (same result, extra lock).
  • UnadoptGuard::new (~1461) calls readable() and takes the global UNADOPTED lock before skips_guard, on every bind_pipeline_exact, reset and execute; checking skips_guard first would avoid that.
  • Detection is under_wine() (any Wine), not vkd3d-proton specifically. Patching vkd3d-proton's vtables in place makes XCL's Release hooks run for every object of those classes, including XCL's own resources that main deliberately leaves unadopted; please say whether that's intended.
  • Nothing tests the queue Signal / Wait unwrapping or the fence-hook behaviour. At 969 lines, the create_raw_fence swaps across 9 files and the test-site guards could go first as a preparation PR.

Fine: in-place patching happens once per table under a lock and keeps the original entries, the guard pins a reference and does the final release through XCL's Release hook, and the proxy frees itself on the last release.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

Thanks. Point by point, at head 313f55e8:

  • Title fences skipping the fence hooks: right. The proxy was written before main's hooks gained the readback settling. Its GetCompletedValue, SetEventOnCompletion and Signal are now main's hooks, run on vkd3d-proton's own fence; XCL's own fence queries unwrap the proxy first and skip the hook, as on main. Fences made inside XCL's own work are no longer wrapped.
  • Windows changes too: right. The queue's Signal / Wait overrides are under under_wine() again, so Windows takes main's path; under Wine they no longer take the class lock.
  • UnadoptGuard::new: not as proposed: checking skips_guard first would skip an object whose native table another thread's guard has put in, and that guard's drop would then restore XCL's table in the middle of this call. A lock-free pre-check that is equivalent was added instead.
  • Any Wine, and the Release hooks: intended. Without vkd3d-proton, Wine's d3d12 is upstream vkd3d, which checks the same vtables but only logs where vkd3d-proton asserts; the path is the same there (not run on it). For an object XCL never recorded each Release hook finds nothing and forwards; the one difference is that XCL's own resources are kept until the queues finish their work.
  • Tests: three added, for the proxy's hooks and the queue unwrapping; two fail without the change.
  • Size: a clean split exists (the guard and create_raw_fence with their call sites first, about 500 lines; then the tables, the proxy and the queue unwrap), but the first part alone still stops at vkd3d-proton's assertion. I can split it if that is wanted.

cargo test --lib -- fence vtable wine unadopt, RTX 4060 Ti under Wine: 57 passed, 0 failed. Not run in a title on this head yet; the Windows suite and the smoke pair are still owed.

AI use: Claude Code. Claude Opus 5.5 checked the points and wrote the changes; Claude Fable 5.2 ran the tests on the card and wrote this reply.

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 313f55e, diff read, not a merge-check; PR description red, no Windows run):

  • Native Windows: I found no behaviour change (from reading). Every new path is behind under_wine(), which looks for ntdll!wine_get_version and caches the answer. Title fences aren't wrapped on Windows. The queue's Signal / Wait overrides are Wine-only. With in-place tables off, the table sizes in make_class match main. What Windows still pays is one OnceLock load per orig_fn call, per UnadoptGuard::new and per unwrap_fence. That includes every pipeline bind (bind_pipeline_exact) and every ExecuteCommandLists. It's small, but the suite and the smoke pair on Windows are what would show it, and neither has run (the description says so).
  • Size. It is +1042/-78. The stated reason, that the halves can't be tested apart on an unpatched vkd3d-proton, is about testing on Wine, not about review. It splits cleanly into a stack:
    1. create_raw_fence at the ~15 call sites (same behaviour on Windows);
    2. the in-place tables (class_for / patch_in_place);
    3. UnadoptGuard;
    4. the fence proxy.
  • Tests on Windows CI barely reach the shipped code. The guard tests use a test-only UnadoptGuard::enter (real.rs ~1492) that copies new's body. a_guard_on_an_object_... (~15668) returns early off Wine. The Wine branches of class_for (~1604) and dev_create_fence (~5282) aren't covered.
  • Wine-only, unverified:
    • Patching vkd3d-proton's shared tables hooks every object of those classes, XCL's own-work resources included, so is_adopted becomes true for them.
    • While a guard is active, other threads' calls on that object skip XCL's hooks.
    • uma_driver.rs (~529, ~627) still calls dev.CreateFence and may hand a proxy to vkd3d-proton.
    • The fixed caps (IN_PLACE_MAX 32, the 64-entry fast tables) fail silently when exceeded.
  • Overlap: Wine: raw internal fences + native-vtable guards at host-runtime calls (rebased on amd-dev) #3099 does the same raw-fence and guard part against amd-dev. One should be picked. This carries over D3D12.X: preserve native vtables and wrap fences for vkd3d-proton under Wine (#175) #867 and D3D12.X: patch assert-checked vtables in place under Wine (#175) #2477, which were closed unmerged.

Fine: track_end_title_fence (real.rs ~5248) is a no-op on Windows, because dev_create_fence already tracked the fence. The proxy shares the real fence's reference count and is freed with it. patch_in_place saves the entries under a lock before writing.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@Royalflamejlh
Royalflamejlh force-pushed the fix/wine-native-vtables branch from 313f55e to 7642762 Compare December 1, 2026 09:48
@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

Thanks. On the Wine-only list and the tests, at head 76427620:

  • uma_driver.rs fences: not so. Those calls run in open_uma, before the device is adopted, so the fence is vkd3d-proton's own. Every other remaining CreateFence reaches the runtime only through a Signal / Wait that unwraps the proxy.
  • Fixed caps: right for one of three. The list of native tables dropped a table silently past 64 entries; it now warns once. Of the other two, one falls back to the locked set and the other already warned. vkd3d-proton has 4 and 7 such tables.
  • Other threads during a guard, and is_adopted: both true, and neither gives a wrong result: under Wine only lists and allocators get guards, the title may not call one while it is an argument, and Release is pinned; is_adopted only picks orig_fn, which for an in-place table is the runtime's own entry.
  • Tests: right. UnadoptGuard::new and the tests now run the same body, so the Windows CI runs the shipped guard, and the Wine-only test became a case of one that runs everywhere. The Wine branches of class_for and dev_create_fence stay uncovered off Wine.
  • Windows cost: confirmed as a few atomic or OnceLock loads a call, no allocation, and one lock write per new sync-graph cell fence. The suite and the smoke pair on Windows are still owed.
  • Found while checking: SetEventOnMultipleFenceCompletion with two or more fences, or CreateSharedHandle on a fence, would still hand vkd3d-proton the proxy. Not hooked yet; now in the description.

On the split and #3099: the four parts build in the order you give, and under Wine nothing improves before the last. #3099 is the same guard and proxy in an older form against amd-dev, without the in-place tables. I will leave which of the two goes forward, and whether to stack this one, to the maintainers and the author of #3099.

cargo test --lib -- fence vtable wine unadopt, RTX 4060 Ti under Wine: 56 passed, 0 failed.

AI use: Claude Code. Claude Opus 5.5 checked the points and wrote the changes; Claude Fable 5.2 ran the tests on the card and wrote this reply.

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Re-review (head 7642762; the diff from 313f55e, which I reviewed, read: real.rs +18 / -63). Not a merge-check: PR description is still red.

  • The guard tests now reach the shipped code: fixed. UnadoptGuard::new and the tests share one body, so Windows CI runs the guard that ships. The Wine-only guard test became a case of a test that runs everywhere.
  • The silent cap: fixed. The native-table list warns once past its 64 entries instead of dropping a table without a word.
  • Still open from my first review:
  • The new known gap the description names is worth a test or a hook before merge. SetEventOnMultipleFenceCompletion with two or more fences, or CreateSharedHandle on a fence, would hand vkd3d-proton the proxy.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

…fences (xcl-dev#175)

vkd3d-proton takes an object only with its own vtable. For command lists and
allocators it checks at run time and returns NULL, which its submit path then
reads (`NULL+0x2b28`); for heaps, resources, descriptor and query heaps, root
signatures, pipeline states and command signatures an assertion ends the
process; a fence is cast without a check on its queue thread.

Under Wine only:
- the assert-checked classes keep the runtime's table and XCL's PC slots are
  written into it, with the entries it had kept for `orig_fn`;
- `UnadoptGuard` gives a list, allocator, heap or pipeline its native table
  back for the length of the host call that takes it as an argument;
- the title's fences are thin proxies over the runtime's fence, unwrapped at
  the queue's Signal and Wait and the device's CreateSharedHandle and
  SetEventOnMultipleFenceCompletion; their GetCompletedValue,
  SetEventOnCompletion and Signal run XCL's fence hooks on the runtime's
  fence, as an adopted fence's do on Windows. XCL's own fences
  (`create_raw_fence`, and those made in its own work) stay the runtime's, as
  `main` leaves them unadopted.

This is xcl-dev#867 and xcl-dev#2477 by gustavsi, which were closed unmerged, carried onto
the current `main`: the submit, fence and reset sites `main` has gained since
(`native_queue_execute`, the sparse queues, the two-pass feedback poll, the
own-work submit, the retire and upload fences) get the same guard or raw
fence. One test new on `main` signalled a device fence on a PC queue and takes
a raw fence now.

On Windows nothing changes: `under_wine()` gates each branch.

Co-authored-by: gustavsi <86445165+gustavsi@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Royalflamejlh
Royalflamejlh force-pushed the fix/wine-native-vtables branch from 7642762 to 0797336 Compare December 1, 2026 10:10
@Royalflamejlh

Royalflamejlh commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

The gap is closed at head 0797336e: under Wine the device's CreateSharedHandle and SetEventOnMultipleFenceCompletion now unwrap the proxy and hand vkd3d-proton its own fence (one new test, red without either unwrap; tested with stand-in objects, not on a device or in a title). The other paths were checked against vkd3d-proton's source and left: residency calls only ask whether an object is a heap or a resource, EnqueueMakeResident only calls the fence's Signal through its vtable, and OpenSharedHandle returns the runtime's own fence.

cargo test --lib -- fence vtable wine unadopt, RTX 4060 Ti under Wine: 57 passed, 0 failed in 5 of 6 runs; in the first, bind::tests::wait_oldest_fenced_reclaims_in_flight_buffer_before_refusing failed once while a title was running on the same card (it passes alone, 3 of 3). The Windows suite and smoke pair are still owed.

AI use: Claude Code. Claude Opus 5.5 wrote the change; Claude Fable 5.2 ran the tests on the card and wrote this reply.

Edited: the first run of that command had one failure, which I had not read when I posted "0 failed"; the counts above are the corrected ones.

@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Follow-up (head 0797336; the 57-line diff from 7642762 read). The gap is covered: under Wine, device #31 CreateSharedHandle and #45 SetEventOnMultipleFenceCompletion now unwrap a fence proxy before the runtime sees it, and the overrides are added only under under_wine(). The test checks both, with a proxy and a plain object mixed in one array, and that off Wine the proxy passes through unchanged. The other open points from my last comment (a Windows suite run and smoke pair, the size / stack, #3099) stand.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 0797336

Overlaps #3099 (D260): both carry UnadoptGuard, FenceProxy and create_raw_fence for vkd3d-proton's vtable checks under Wine. #3099 targets amd-dev, is a 151-file / 82k-line branch diff and conflicts. This PR targets main, adds #2477's in-place vtables (patch_in_place, in_place_kind), and covers main's newer fence and submit sites (sparse, vram, late_release, cpu_writes, present, title_textures, bind::poll_two_pass_feedback, sparse::pc_execute). For main, this is the one to review.
No problems found in the parts read. The failing check is the PR description check: the smoke pair is still owed. The new top commit 0797336 closes the gap the description listed: under Wine, CreateSharedHandle (#31) and SetEventOnMultipleFenceCompletion (#45) now unwrap fence proxies before calling the runtime, with a test.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Royalflamejlh added a commit to Royalflamejlh/xcl-linux that referenced this pull request Dec 1, 2026
…ton's fence

The change of xcl-dev/xcl#3492 at 313f55e8: a title's fence went straight
to vkd3d-proton and skipped the readback settling the hooks do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants