D3D12.X: preserve native host vtable prefixes and tails #1904

Open
github-bot wants to merge 1 commit from github-bot/gh-1904 into main AGit
Owner

@⁠mikebuckets171 on GitHub · 2026-11-24 22:55 UTC · original
mikebuckets171:pr/d3dmetal-native-vtable-prefix → main · +130 −18 · 1 files · 1 commits · draft

Part of #258. This upstreams Ahmet Dedeler's focused D3DMetal host-vtable fix from ddf3be7, preserving its author and existing Claude Mythos 5.2 co-author trailer. D3DMetal is native code under Wine rather than a PE module: the existing extended vtable layout puts XCL metadata where D3DMetal expects its C++ ABI prefix and does not preserve enough host tail slots. The change mirrors the host prefix and tail only when the original methods are outside PE modules; PE-backed Windows host tables keep their existing layout.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: preserve the native host vtable prefix/tail and map extended tables back to their original table; add a focused regression test for native and PE-backed table layouts.

Tested

  • MacBook Pro M5 Pro (20-core GPU), 48 GB; macOS 27.2.1 (26B131); CrossOver 26.3.0.39832, D3DMetal 3.0, Rosetta 2; Rust/Cargo 1.100.0; LLVM-MinGW 20261117 / clang 23.1.6.
  • cargo build --workspace --locked --release --target x86_64-pc-windows-gnullvm — passed on this head.
  • cargo test -p xcl --lib --release --target x86_64-pc-windows-gnullvm hle::d3d12x::real::native_host_table_tests::a_native_hosts_table_keeps_its_prefix_and_other_tables_keep_theirs -- --exact --nocapture — 1 passed, 0 failed, 951 filtered out, under CrossOver.
  • Same retail title, same Mac host and 60-second limit, offline CrossOver bottle, separate fresh data roots:
    • main 689f2db477c3c062cf162649781640ef8a977c18:
xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB
  • PR 50768d87beca1773980745db1fbc68cf69446b92:
xcl-smoke v1
commit: 50768d87beca1773980745db1fbc68cf69446b92
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB
  • The two title runs are 0-frame against 0-frame on plain upstream main; this is a bounded no-regression check only, not evidence the title reaches the changed vtable path. Wine reports peak commit as 0 MB, so memory is unmeasured.

Not tested

  • cargo test --workspace -- --test-threads=4 and any Windows GPU run; no Windows GPU machine was available in this session. Per #258 guidance this is a Mac-host-only behavior change, so Windows remains untested pending a Windows tester.
  • Whether this exact current-main pair reaches D3DMetal vtable adoption, title rendering, or gameplay. No visual correctness claim.

AI use

  • OpenChamber with GPT-6 Luna rebased Ahmet's existing commit, ran the named Mac checks and prepared this description. The source commit retains Ahmet Dedeler as author and its existing Claude Mythos 5.2 co-author disclosure.
**@⁠mikebuckets171** on GitHub · 2026-11-24 22:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1904) `mikebuckets171:pr/d3dmetal-native-vtable-prefix` → `main` · +130 −18 · 1 files · 1 commits · draft Part of #258. This upstreams Ahmet Dedeler's focused D3DMetal host-vtable fix from [`ddf3be7`](https://github.com/Ahmet-Dedeler/xcl/commit/ddf3be714108400b7873ad179a172665eee0a50d), preserving its author and existing Claude Mythos 5.2 co-author trailer. D3DMetal is native code under Wine rather than a PE module: the existing extended vtable layout puts XCL metadata where D3DMetal expects its C++ ABI prefix and does not preserve enough host tail slots. The change mirrors the host prefix and tail only when the original methods are outside PE modules; PE-backed Windows host tables keep their existing layout. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: preserve the native host vtable prefix/tail and map extended tables back to their original table; add a focused regression test for native and PE-backed table layouts. **Tested** - MacBook Pro M5 Pro (20-core GPU), 48 GB; macOS 27.2.1 (26B131); CrossOver 26.3.0.39832, D3DMetal 3.0, Rosetta 2; Rust/Cargo 1.100.0; LLVM-MinGW 20261117 / clang 23.1.6. - `cargo build --workspace --locked --release --target x86_64-pc-windows-gnullvm` — passed on this head. - `cargo test -p xcl --lib --release --target x86_64-pc-windows-gnullvm hle::d3d12x::real::native_host_table_tests::a_native_hosts_table_keeps_its_prefix_and_other_tables_keep_theirs -- --exact --nocapture` — 1 passed, 0 failed, 951 filtered out, under CrossOver. - Same retail title, same Mac host and 60-second limit, offline CrossOver bottle, separate fresh data roots: - `main` `689f2db477c3c062cf162649781640ef8a977c18`: ``` xcl-smoke v1 commit: 689f2db477c3c062cf162649781640ef8a977c18 gpu: AMD Compatibility Mode title: retail (Xbox Series X|S package, private drive) seconds: 60 exit: 0x0 frames shown: 0 (PresentX 0) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` - PR `50768d87beca1773980745db1fbc68cf69446b92`: ``` xcl-smoke v1 commit: 50768d87beca1773980745db1fbc68cf69446b92 gpu: AMD Compatibility Mode title: retail (Xbox Series X|S package, private drive) seconds: 60 exit: 0x0 frames shown: 0 (PresentX 0) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` - The two title runs are 0-frame against 0-frame on plain upstream `main`; this is a bounded no-regression check only, not evidence the title reaches the changed vtable path. Wine reports peak commit as 0 MB, so memory is unmeasured. **Not tested** - `cargo test --workspace -- --test-threads=4` and any Windows GPU run; no Windows GPU machine was available in this session. Per #258 guidance this is a Mac-host-only behavior change, so Windows remains untested pending a Windows tester. - Whether this exact current-main pair reaches D3DMetal vtable adoption, title rendering, or gameplay. No visual correctness claim. **AI use** - OpenChamber with GPT-6 Luna rebased Ahmet's existing commit, ran the named Mac checks and prepared this description. The source commit retains Ahmet Dedeler as author and its existing Claude Mythos 5.2 co-author disclosure.
XCL gives every D3D12 object a vtable of its own: the original table's address, then the
host's methods with XCL's in between. That assumes a host whose methods are in a PE module
and which uses a table only through its public slots.

Apple's D3DMetal (the D3D12 of CrossOver and the Game Porting Toolkit on macOS) is native
code in no PE module. It reads the words in front of the table of an object it is handed
(type information, offset-to-top and the virtual-base offsets of the C++ ABI) and calls
virtual methods of its own well past the public ones. In XCL's table the word in front of
slot 0 is the original table's address, not type information, and the table ends 64 slots
after the last word the scan took for a method.

For a table whose first method is in no PE module (`module_of` is 0), `class_for` now
- puts 16 words of the host's table in front of the extended one (`table_header`), where
  the original's address is on other hosts; the original is then found through
  `NATIVE_EXTS` (`orig_table`), a list read without a lock;
- takes every slot up to `total` as the host's and guards it, since the scan for the end
  of the table cannot work there (it stops at the first word that is in a module);
- copies the host's words after `total` behind XCL's slots (up to 512 from the last public
  method), so a call of the host's own does not run off the end.

A table from a PE module is laid out as before, word for word: `table_header` returns the
original's address alone, and `orig_table` reads the word in front of the table when no
native table was made.

Test: a_native_hosts_table_keeps_its_prefix_and_other_tables_keep_theirs.

Part of #258.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
(cherry picked from commit ddf3be714108400b7873ad179a172665eee0a50d)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:08:59 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 02:15 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!

**@⁠DavidM1911** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1904#issuecomment-7150509488) 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!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1904/head:github-bot/gh-1904'
git switch 'github-bot/gh-1904'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1904'
git switch 'github-bot/gh-1904'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1904'
git switch 'github-bot/gh-1904'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1904'
git switch 'main'
git merge --squash 'github-bot/gh-1904'
git switch 'main'
git merge --ff-only 'github-bot/gh-1904'
git switch 'main'
git merge 'github-bot/gh-1904'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.