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

Open
mikebuckets171 wants to merge 1 commit from upstream-pr/1904 into main
mikebuckets171 commented 2026-11-24 22:55:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mikebuckets171 on 2026-11-24T22:55:12Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5481706562 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1904). Originally posted by [mikebuckets171](https://github.com/mikebuckets171) on 2026-11-24T22:55:12Z. --- 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.
DavidM1911 commented 2026-11-25 03:05:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:15:55Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7150509488 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1904#issuecomment-7150509488). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T02:15:55Z. --- 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!
bmjask commented 2026-11-25 21:00:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:00:31Z.

Review: COMMENTED


No confirmed source defect, but this D3DMetal ABI prerequisite is not merge-ready. Synthetic layout tests do not validate real native-host adoption/dynamic_cast or tail calls; the Mac smoke reaches zero frames and does not exercise rendering/adoption. Prefix/tail constants need target-path evidence, and IsBadReadPtr establishes mapped readability rather than actual vtable extent. Add a real D3DMetal host tail-call/adoption integration test, a non-zero-frame target run, and required Windows/current CI evidence.

<!-- greyfinch-sync:ivall/xcl:review:6064916257 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1904#pullrequestreview-6064916257). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T21:00:31Z. **Review:** COMMENTED --- No confirmed source defect, but this D3DMetal ABI prerequisite is not merge-ready. Synthetic layout tests do not validate real native-host adoption/dynamic_cast or tail calls; the Mac smoke reaches zero frames and does not exercise rendering/adoption. Prefix/tail constants need target-path evidence, and IsBadReadPtr establishes mapped readability rather than actual vtable extent. Add a real D3DMetal host tail-call/adoption integration test, a non-zero-frame target run, and required Windows/current CI evidence.
github-actions[bot] commented 2026-11-30 08:40:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:40:08Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273193661 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1904#issuecomment-7273193661). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:40:08Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:04:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:04:41Z.


Triage (#1607) – head 50768d8

No open or merged PR makes the same change. #3099 touches class_for as part of a large amd-dev rebase, but it does not keep the native host's prefix or tail.
One point in real.rs:class_for: on a native host scanned becomes total, and slots 0..total are read with *ot.add(i) without the IsBadReadPtr probe that the prefix (table_header) and the tail get. That read can run past the host table's mapping. Main's list_x.rs test (*(raw as *mut usize) = *ext.sub(1)) still reads the word before the table directly, but only in a test. The branch conflicts with main.
Recommendation: keep open.

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

<!-- greyfinch-sync:ivall/xcl:comment:7303618353 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1904#issuecomment-7303618353). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:04:41Z. --- **Triage (#1607)** – head 50768d8 No open or merged PR makes the same change. #3099 touches `class_for` as part of a large amd-dev rebase, but it does not keep the native host's prefix or tail. One point in `real.rs`:`class_for`: on a native host `scanned` becomes `total`, and slots `0..total` are read with `*ot.add(i)` without the `IsBadReadPtr` probe that the prefix (`table_header`) and the tail get. That read can run past the host table's mapping. Main's `list_x.rs` test (`*(raw as *mut usize) = *ext.sub(1)`) still reads the word before the table directly, but only in a test. The branch conflicts with main. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1904:upstream-pr/1904'
git switch 'upstream-pr/1904'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1904'
git switch 'upstream-pr/1904'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1904'
git switch 'upstream-pr/1904'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1904'
git switch 'main'
git merge --squash 'upstream-pr/1904'
git switch 'main'
git merge --ff-only 'upstream-pr/1904'
git switch 'main'
git merge 'upstream-pr/1904'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1894
No description provided.