Skip to content

Memory: detect a macOS host under Wine (mac_host) - #2361

Draft
vakaobr wants to merge 1 commit into
xcl-dev:mainfrom
vakaobr:memory/mac-host-detection
Draft

vakaobr wants to merge 1 commit into
xcl-dev:mainfrom
vakaobr:memory/mac-host-detection

Conversation

@vakaobr

@vakaobr vakaobr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Adds util::mac_host(): the process runs under Wine on a Mac (CrossOver or the Game Porting Toolkit), where D3D12 is Apple's D3DMetal and the title's code runs through Rosetta 2. ntdll's wine_get_host_version names the host's system, and "Darwin" is a Mac; XCL_MAC_HOST=1 / 0 overrides it. Nothing calls it yet: two Mac changes that need to know they run there build on it (the s_barrier default and title textures on shared pages, both stacked on this). Until now only the mac7 branch from #258 had it. Part of #258.

What is in it

  • crates/xcl/src/util.rs: mac_host() (next to under_wine()), its decision in mac_host_from(forced, sysname), and the test a_mac_host_is_darwin_under_wine_unless_forced.

Tested

  • MacBook Pro M5 Pro, macOS 27.2.1, CrossOver 26.3.0, D3DMetal 3.0, Rust 1.100.0 x86_64-pc-windows-gnu, debug, at 6d6a3e3 (on main 65fc114).
  • util::tests::a_mac_host_is_darwin_under_wine_unless_forced and util::tests::dll_keys, each in its own process in the CrossOver bottle: 2 passed.
  • The detection is the same as mac7's, which has been running on this Mac.

Regression run

  • None: nothing calls the new function, so a run is the same as main's. I have no title of my own to run scripts/smoke.ps1 on.

Not tested

  • Windows (where wine_get_host_version does not exist, so it answers false), Wine on Linux, the whole suite.

AI use

  • Claude Code with Claude Opus 5.5 wrote the change and the test, ran the tests and wrote this description.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No concrete source defect found; optional Wine host-version detection and OnceLock use are sound, and this preparatory PR is behavior-neutral today. It is draft/stacked with failing description checks and lacks Windows/Wine whole-suite evidence. Also, XCL_MAC_HOST treats every value except literal "0"—including empty and "false"—as true. Document that conspicuously or accept only 0/1 to avoid accidental activation of future Mac-specific paths.

vakaobr added a commit to vakaobr/xcl that referenced this pull request Nov 26, 2026
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 30, 2026
util::mac_host(): the process runs under Wine on a Mac (CrossOver or the
Game Porting Toolkit), where D3D12 is Apple's D3DMetal and the title's
code runs through Rosetta 2. ntdll's wine_get_host_version names the
host's system; "Darwin" is a Mac. XCL_MAC_HOST=1 / 0 overrides it.

Nothing calls it yet. The Mac changes that need to know they run there
(the barrier default, title textures on shared pages) build on it; until
now only Ahmet-Dedeler's mac7 branch had it. Part of xcl-dev#258.
@vakaobr
vakaobr force-pushed the memory/mac-host-detection branch from 6d6a3e3 to 69c0b04 Compare November 30, 2026 11:59
vakaobr added a commit to vakaobr/xcl that referenced this pull request Nov 30, 2026
Apple's metal-shaderconverter, which D3DMetal runs on every pipeline,
does not handle DXIL UMul (binaryWithTwoOuts, opcode 42) in every
program: on some it overflows its stack and the compile never returns.
The direct translator emits UMul for the stride * index term of a
windowed buffer address (lower_window.rs), so on a Mac every test and
title pipeline with such an address can stop there.

On a Mac (util::mac_host), umul_wide now builds the high half from
16-bit parts, as the HLSL kernel's mul_hi_u32 does, so the window code
still needs no Int64Ops. Windows keeps UMul.

Measured on an M5 Pro, macOS 27.2.1, CrossOver 26.3 + D3DMetal, on main
9dfbe3e with xcl-dev#2361:
- gpu_memory_windows_above_4_gib,
  gpu_memory_windows_reject_out_of_uma_aliasing and
  gpu_sparse_vram_descriptors_buffers_and_xmem: on main each reports
  "has overflowed its stack" and hangs; with this change all three pass.
- umul_wide_without_umul_matches_cpu (new): passes on 32 lanes; its
  kernel has no binaryWithTwoOuts and no Int64Ops.
- window_at_lowers_to_32bit_carry_without_int64 now expects no UMul on
  a Mac: it passes, and with XCL_MAC_HOST=0 it still finds UMul, as
  before (with the Mac branch disabled it failed, measured on my Mac
  branch on 27 Nov).
- gpu_window_at_32bit_carry_edge_cases: passes.
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 69c0b04

No open or merged PR adds mac_host on its own, and main has no mac_host or wine_get_host_version. #2363 and #3525 are stacked on this commit (69c0b04). #2402 and #2492 carry an identical copy of it (6d6a3e3, same patch), so they should be rebased onto this one. Those are stacks, not duplicates.
No problems found in the diff: nothing calls mac_host() yet, and the decision logic is tested in mac_host_from.
Recommendation: keep open.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants