Repository navigation
D3D12.X: preserve native host vtable prefixes and tails - #1904
mikebuckets171 wants to merge 1 commit into
Conversation
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 xcl-dev#258. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com> (cherry picked from commit ddf3be7)
…cl-dev#1904) 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 xcl-dev#258. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com> (cherry picked from commit ddf3be7)
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
bmjask
left a comment
There was a problem hiding this comment.
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.
|
Nothing has happened on this PR for 3 days, so it is marked |
|
No open or merged PR makes the same change. #3099 touches AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
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
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.main689f2db477c3c062cf162649781640ef8a977c18:50768d87beca1773980745db1fbc68cf69446b92: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=4and any Windows GPU run; no Windows GPU machine was available in this session. Per macOS (Apple Silicon, CrossOver + D3DMetal): the newer retail game reaches its first-run menus at 30 fps #258 guidance this is a Mac-host-only behavior change, so Windows remains untested pending a Windows tester.AI use