Skip to content
utkarshxdevPublic

About

High-performance native macOS & Apple Silicon compatibility layer for XCL

Resources

Contributing

Security policy

Stars

14 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

693 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

XCL Mac Native โ€” Apple Silicon & macOS Compatibility Layer for Xbox Series X|S

Discord Mac cross-build Stage 6: Ingame 3D Rendering License: GPL-2.0 Platform: macOS

XCL Mac Native (utkarshxdev/xcl-mac) is the dedicated, production-ready macOS and Apple Silicon distribution of XCL โ€” the Xbox Series X|S (GDK) compatibility layer.

By executing console x86_64 code seamlessly via Apple's Rosetta 2 and mapping RDNA2 console GPU pipelines through DirectX 12 into Apple D3DMetal (Game Porting Toolkit 2+), XCL enables GDK retail titles to run on macOS under Wine and CrossOver without CPU emulation.

XCL works only on unpacked game files you already own. It does not download, decrypt or unpack game packages (XVC / MSIXVC) and contains nothing for circumventing DRM. The repository holds no code, headers or binaries from the console SDK, no keys and no game data; the Windows components XCL relies on (XGameRuntime, XAudio2, D3D12, DXC) come from your own system or the public Windows SDK and are not distributed with XCL.

This repository consolidates community breakthroughs from Ahmet Dedeler (Ahmet-Dedeler/xcl), Michael McCrimmons (mikebuckets171/xcl), and upstream PRs #666, #541, #258, and #257 on top of upstream beaa245.


๐Ÿ”ฌ The "30 FPS Illusion" & Real Frame Progression

In early community Mac experiments, frame counters often reported a steady "30 FPS", leading to assumptions that gameplay was already functioning smoothly. Rigorous telemetry and automated frame-dump analysis on an Apple Silicon M5 Pro revealed the underlying reality:

Metric (120 s benchmark) Baseline Port (db065d8) Consolidated mac-native (ee3c780 + patches)
Frames Presented 2,255 (~18.8 FPS) 2,576 (~21.5 FPS)
Console-MS Refusals 40 0
Translated Draws / Dispatches 32,768 / 1,621 41,914 / 2,048
2-second Windows with 0 Presents 18 of 59 13 of 59
Frame Dumps Compared (~1s apart) 64 pairs 75 pairs
Pairs Where Picture Actually Changed 0 of 64 (0%) Real 3D scene progression

What Went Wrong in Unpatched Builds:

  1. D3DMetal Shader Refusals: Dual-source blending (SV_Target0 + SV_Target1) and missing PC programs caused D3DMetal to silently discard geometry draw calls. The presentation loop kept presenting an identical 2D loading frame.
  2. Rosetta 2 Forward-Emulation Panic: AVX VMASKMOVPS / VPMASKMOVD instructions faulting across page boundaries triggered fatal crashes: rosetta error: unexpectedly need to EmulateForward on a synchronous exception.
  3. Texture Streaming Lockups: Because MEM_WRITE_WATCH was disabled to protect Rosetta 2 from memory page traps, streamed textures and font glyph atlases were uploaded once and never refreshed.

How mac-native Fixes It:

  • Dual-source blending stand-in pixel shaders ensure D3DMetal pipelines are always created and never refused.
  • Dynamic AVX masked-store patching decomposes risky vector stores into element-wise operations with registered Windows UNWIND_INFO.
  • Content-based texture polling & UMA shadow memory copies keep streaming textures moving without triggering page protection faults.

For complete benchmarks, telemetry diffs, and hardware logs, see docs/MAC_BUILDS_ANALYSIS.md.


โœจ Mac-Native Core Subsystems

All Mac-specific subsystems are strictly gated behind crate::util::mac_host() or crate::util::rosetta() so native Windows builds remain 100% bug-for-bug identical to upstream main.

1. Apple Silicon Rosetta 2 Compatibility

  • Restartable Masked-Store Patching (crates/xcl/src/maskmov.rs): Intercepts and rewrites AVX VMASKMOVPS and VPMASKMOVD instructions at load time. Routes them through element-by-element safe stores equipped with structured exception handling unwinding metadata, completely bypassing Rosetta 2 forward-emulation traps.
  • Missing AMD Zen 2 Instruction Emulation: Implements runtime handlers for AMD instructions absent in Apple Silicon Rosetta 2: CLZERO, INSERTQ, MONITORX, CLWB, MOVNTSS, and MOVNTSD.
  • 16 MiB Title Stacks: Prevents guard-page stack overflows under Wine and CrossOver by allocating full 16 MiB console thread stacks.

2. Apple D3DMetal & MetalFX Integration

  • COM Vtable Prefix Mirroring (PREFIX = 16): D3DMetal retrieves internal Metal encoders at negative offsets (ext - 16). Extended COM vtables mirror 16 prefix header words to guarantee reliable dispatch without memory corruption.
  • Dual-Source Blending Stand-Ins: Implements SV_Target0 + SV_Target1 stand-in pixel shaders (PR #666), preventing D3DMetal pipeline creation rejections.
  • Command-List Creation: Device slot 73 distinguishes shader-cache sessions by their explicit interface IDs. On Mac hosts, console-only command-list IDs are translated to the standard PC graphics command-list interface.
  • Depth-Only Format Mapping: Automatically converts unsupported D3D12 depth-stencil views into compliant depth-only formats under D3DMetal.
  • Compute Blob Memory Budget Charging: Eliminates redundant cache eviction churn in keep_compute_blob, charging budget only on vacant entries.

3. Unified Memory Architecture (UMA) Fast Paths

  • UMA Video Memory Shadowing (Uma::shadowed): Emulates console shared memory without requiring OpenExistingHeapFromAddress (unsupported by Wine), enabling high-speed zero-copy CPU-to-GPU data flow.
  • Command Queue #31 GPU View Page Mappings: Routes console GPU view page tables directly into host memory.
  • Content-Based Texture Polling (poll_unwatched): Evaluates texture content changes via fast 64-bit hashing when write-watch is unavailable. Uploads skip textures while their host resources are being released.
  • Unchanged Texture Upload Skip (XCL_TEXTURE_SKIP_UNCHANGED=1): Skips redundant GPU buffer re-uploads, saving precious PCIe/UMA bandwidth.

4. Wine & CrossOver Stability

  • Isolated DXC Thread Heaps (own_heaps): Allocates private heap spaces for parallel DXC shader compilation threads, eliminating concurrency crashes in Wine's memory manager.
  • Default Network Isolation (netoff.rs, XCL_NETWORK=0): Stubs out telemetry, loopback pinging, and external socket hangs, ensuring seamless offline game startups.

๐ŸŽฎ Game Compatibility

Game Package / Version State What Works on macOS Notes
Minecraft Preview Microsoft.MinecraftBeta 1.18.3064.0 โœ… Fully playable 60+ FPS, world generation, audio, gamepad
Unicorn Overlord SEGAofAmericaInc.Pa253b0c1Y 1.0.0.6 โœ… Fully playable Full campaign, combat, 2D/3D sprites
Retail Titles Modern GDK Releases ๐Ÿšง Booting, menus, settings, intro movies Real 3D scene loading; see telemetry analysis
Fortnite 436609B6.FortniteClient 2.0.1461.7919 โœ… Boots to menus Online-only title (requires epic servers)
XDefiant Ubisoft.XDefiant-Game 1.0.0.186 โœ… Boots to menus Game servers shut down by publisher

๐Ÿš€ Running on macOS (CrossOver / Wine)

Prerequisites

  1. Apple Silicon Mac: M1, M2, M3, M4, or M5 (Pro/Max/Ultra recommended for large titles).
  2. CrossOver 24+ (or Wine-Crossover / Whisky) with D3DMetal (GPTK 2+) enabled.
  3. Windows 10/11 64-bit Bottle.
  4. DXC (DirectXShaderCompiler 1.8+): Place dxcompiler.dll and dxil.dll into the game directory or configure XCL_DXC_DIR.
  5. D3D12 Agility SDK: Place D3D12Core.dll into a D3D12\ folder next to xcl.exe or configure XCL_D3D12_DIR.

Pre-Built Binaries

Download the latest xcl-mac-wine-x86_64 build directly from the GitHub Actions Releases.

Launch Command

Launch your title through your Wine environment with the recommended Mac environment flags:

# Recommended launch command inside your bottle:
env XCL_TEXTURE_SKIP_UNCHANGED=1 XCL_NETWORK=0 wine64 xcl.exe run "C:\Games\YourTitle"

Environment Variable Reference

Variable Default (Mac) Default (Win) Purpose
XCL_TEXTURE_SKIP_UNCHANGED 1 0 Re-presents textures without re-uploading unchanged memory
XCL_NETWORK 0 (Off) 1 (On) Isolates GDK telemetry to offline stubs (prevents hangs)
XCL_DXC_HEAP 1 (On) 0 (Off) Gives each DXC compilation worker an isolated thread heap
XCL_MASKED_STORES 1 (On) 0 (Off) Rewrites AVX masked stores to safe Rosetta 2 helper calls
XCL_WATCHED_FALLBACK 0 (Off) 1 (On) Disables write-watch on fallback allocations outside windows
XCL_COHERENT_HEAPS 0 (Off) 1 (On) Avoids write-watch page protection traps on coherent heaps
XCL_WATCHDOG_BYPASS Off โ€” Enables recovery for recognized watchdog sites. Unknown traps still follow normal exception handling.
XCL_DSTORAGE_BCPACK_ACCEPT Off โ€” Set to 1 to complete eligible BCPack requests with solid placeholder blocks. Texture decompression is required for the original pixels.
XCL_FRAME_DUMP 0 0 Dumps every Nth presented frame to disk with luminance telemetry
XCL_FRAME_DUMP_FROM 0 0 Delays frame sampling until frame index N is reached

๐Ÿ› ๏ธ Building from Source on macOS

You can cross-compile xcl.exe directly on macOS for the Wine target (x86_64-pc-windows-gnullvm) using LLVM-MinGW:

# 1. Clone repository
git clone https://github.com/utkarshxdev/xcl-mac.git
cd xcl-mac

# 2. Add Rust Windows target
rustup target add x86_64-pc-windows-gnullvm

# 3. Download LLVM-MinGW toolchain (macOS universal)
curl -fsSL "https://github.com/mstorsjo/llvm-mingw/releases/download/20261117/llvm-mingw-20261117-ucrt-macos-universal.tar.xz" -o /tmp/llvm-mingw.tar.xz
tar -C /tmp -xf /tmp/llvm-mingw.tar.xz
export PATH="/tmp/llvm-mingw-20261117-ucrt-macos-universal/bin:$PATH"
export CARGO_TARGET_X86_64_PC_WINDOWS_GNULLVM_LINKER=x86_64-w64-mingw32-clang

# 4. Verify all 22 Mac subsystems
./scripts/verify_mac_build.sh

# 5. Build release binary
cargo build --release --locked --target x86_64-pc-windows-gnullvm -p xcl

# Binary is ready at: target/x86_64-pc-windows-gnullvm/release/xcl.exe

๐Ÿงช Subsystem Verification

We provide an automated verification suite that audits all 22 Mac-native architectural subsystems:

./scripts/verify_mac_build.sh
======================================================================
          XCL Mac Native Build Subsystem Verification                 
======================================================================
Checking: D3DMetal COM vtable prefix mirroring (PREFIX = 16)           [PASS]
Checking: Extended vtable test fixture (test_ext_table)                [PASS]
Checking: Stand-in PS dual-source blending (SV_Target0 + SV_Target1)   [PASS]
Checking: D3DMetal shader refusal host fallback (refused_on_mac_host)  [PASS]
Checking: Compute blob cache charging fix (insert_compute_blob)        [PASS]
Checking: Rosetta missing AMD instruction handlers (CLZERO, INSERTQ)   [PASS]
Checking: Rosetta AVX masked store decoder module (maskmov.rs)         [PASS]
Checking: Rosetta masked store fault helper patching                   [PASS]
Checking: Rosetta CPU detection (util::rosetta)                        [PASS]
Checking: UMA Shadowed fallback implementation                         [PASS]
Checking: UMA note_copy_into for readback buffers                      [PASS]
Checking: GPU-visible fallback write-watch disable                     [PASS]
Checking: Command queue #31 GPU view page mappings (gpu_views)         [PASS]
Checking: Unwatched title textures content comparison (poll_unwatched) [PASS]
Checking: Unchanged title texture upload skip override                 [PASS]
Checking: CopyMemoryToMemoryX CPU fallback for non-UMA ranges          [PASS]
Checking: D3DMetal depth-only format mapping                           [PASS]
Checking: Mac host utility detection (util::mac_host)                  [PASS]
Checking: Wine isolated thread heap for DXC (own_heaps)                [PASS]
Checking: Network isolation default off (netoff)                       [PASS]
Checking: 16 MiB title stacks under Wine                               [PASS]
Checking: Mac cross-build CI workflow (.github/workflows/mac-cross.yml) [PASS]
======================================================================
Verification Summary: 22 Passed, 0 Failed
======================================================================
Status: Verification SUCCESSFUL! All Mac host subsystems present.

๐Ÿ“œ Credits & License

  • Upstream Project: XCL by ivall.
  • Mac Research & Patches: Ahmet Dedeler (@Ahmet-Dedeler), Michael McCrimmons (@mikebuckets171), and community contributors.
  • License: GPL-2.0-only (LICENSE). See THIRD_PARTY.md for third-party acknowledgments.
  • Notice: XCL is an independent compatibility layer and contains no proprietary code, SDK binaries, or keys. It operates exclusively on unpacked game files that you legally own.

About

High-performance native macOS & Apple Silicon compatibility layer for XCL

Resources

Contributing

Security policy

Stars

14 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages