feat(mac): Stage 6 subsystems — mesh shaders on D3DMetal, GPU indirect repack, sparse safety, and watchdog bypass #980
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!980
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/980/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@utkarshxdev on GitHub · 2026-11-24 09:51 UTC · original
utkarshxdev:mac-native→main· +7859 −424 · 43 files · 49 commits · closed without mergingDescription
This pull request consolidates and upstream-adapts the complete macOS and Apple Silicon runtime to Stage 6 (Ingame 3D Geometry Rendering & World Loading).
It synthesizes community breakthroughs across community forks (
Ahmet-Dedeler/xcl,mikebuckets171/xcl, and upstream PRs #724, #869, #666, #541, #258, #257), gating all platform-specific work strictly behindcrate::util::mac_host()orcrate::util::rosetta()so native Windows execution remains 100% untouched.utkarshxdev/xcl-macKey Subsystems & Fixes
1. D3DMetal Mesh Shader Pipeline Adaptation (PR #724)
SV_Target0andSV_Target1, and extended layout tables withinline_msanduser_data_msroot offsets for D3DMetal compatibility. HookedDispatchMesh(slot 127 / newer 129).2. GPU-Side Indirect Repack Compute Pass (PR #869)
indirect_repack.hlslcompute dispatch translating raw multi-draw console buffers into clean argument buffers before execution.3. World-Load Watchdog & Streaming Hang Bypass (
0x23cf683)0x23cf683.crates/xcl/src/hle/d3d12x/eh.rs, allowing background asset streaming threads to complete world population uninterrupted.4. DirectStorage BCPack Acceptance & Texture Fallbacks
XCL_DSTORAGE_BCPACK_ACCEPTindstorage.rswith neutral solid-color texture fallbacks, allowing game engines to continue rendering the 3D scene while custom BC-decompression decoders are developed.5. Sparse Buffer Re-entrancy Lock Safety
forget_bufferinside sparse buffer re-entrancy.try_lockguarding incrates/xcl/src/hle/d3d12x/sparse.rsto safely skip redundant drops when already held on the calling thread.6. Rosetta 2 AVX Masked Store Decoder (
maskmov.rs)VMASKMOVPS/VPMASKMOVDinstructions spanning page boundaries trigger fatal Rosetta 2 panics (unexpectedly need to EmulateForward on a synchronous exception).UNWIND_INFOto protect Rosetta 2 from memory page boundary traps.Tested
Automated 30/30 Mac subsystem verification suite (
scripts/verify_mac_build.sh):0x23cf683, BCPack acceptance, and GPU indirect repack compute pass).x86_64-pc-windows-gnullvm) passed on macOS Apple Silicon runner.Not tested
Direct execution on physical AMD RDNA4 hardware (tested on Apple Silicon M-series via D3DMetal / Rosetta 2 under Wine/Whisky).
AI use
Claude 3.5 Sonnet and Gemini were used for synthesizing community patches, generating verification harnesses, and auditing cross-platform vtable layouts.
Verification Summary
Metal makes no depth-only view of a depth + stencil texture and no view in another depth family than the texture's: its assertion ("failed assertion `Texture Creation`") ends the process where a Windows driver takes or refuses the view. Upstream now makes depth buffers typeless and reads them through R24_UNORM_X8 / R32_FLOAT_X8X24 views with stencil in plane 1 – that combination. On a native host (`device_x::depth_only`, XCL_DEPTH_STENCIL=1 restores upstream's mapping) the override sits on upstream's functions: - pc_resource_desc: R32G8X24 / R24G8 families (and the console's D16S8, which upstream maps to R24G8) → R32_TYPELESS / D32_FLOAT / R32_FLOAT (`depth_only_format`). - pc_view_format (pipelines' DSV formats, clear values, format queries) the same. - pc_shader_view_format: any depth-family or stencil view of an R32-family resource → R32_FLOAT (stencil views read the depth: the stencil plane is lost); of a 16-bit depth buffer → R16_UNORM. - pc_depth_view_format: a DSV takes the depth format of the resource's family. - XCL_TRACE_DEPTH_VIEWS=1 logs every view made of a depth-family resource, flushed. Upstream's mappings of B5G5R5A1 / B4G4R4A4 targets and of the console's 116 / 117 are as upstream has them (the local pc_format and view_format_for are gone). Co-Authored-By: Claude Mythos 5.2 <[email protected]>- XCL_BACKGROUND=1: the window opens behind the program in front, without the focus, and never holds the cursor. - XCL_REMOTE_INPUT=<file>: buttons written to that file ("A", "DOWN A") are held for 250 ms each time it changes. - XCL_FRAME_DUMP dumps the first four frames too; freed resources leave the frame trace's lists (`present::forget`); XCL_TRACE_FENCES=1 logs the first 200 fence events; the DXC memory gate says what the host reports when it holds a compile back. (The local XCL_TRACE_WINDOW is dropped.) Co-Authored-By: Claude Mythos 5.2 <[email protected]>A masked store into write-protected memory ends the process under Rosetta 2 with one line ("unexpectedly need to EmulateForward on a synchronous exception", x86_rip) and no exception anyone can look at: what the loop was writing is not known. XCL_PROBE_MOV puts a breakpoint on a `mov r64, [base + disp32]` of the title (the load of the array pointer before such a loop), does the load itself and logs the value, the registers and what memory the value points to – unified-memory window, write-watched or not, allocation and region (the first 48 times, then every 256th). XCL_PROBE's hardware breakpoints do not exist under a translator. Co-Authored-By: Claude Mythos 5.2 <[email protected]>a6f5f7a– what upstream's new mechanisms give on this host, the menus, what stops loading abb5c984887ebf1b8– the unchanged-upload skip, the terms page, what was not reached 773d352492Rosetta 2 runs VMASKMOVPS / VMASKMOVPD / VPMASKMOVD / VPMASKMOVQ to memory an element at a time and can restart one only from its first element: a fault there is delivered and resumed, a fault on a later element ends the process ("rosetta error: unexpectedly need to EmulateForward on a synchronous exception"). Measured with a native x86-64 program under Rosetta (macOS 27.3) and under CrossOver: a read-only page, a handler that makes it writable. Every store of 4 or 8 elements whose first element faults is resumed; every one that faults on element 1 or later ends the process, whichever elements the mask selects. VMOVDQU across the same boundary, REP STOS / MOVS, MASKMOVDQU and the masked loads are resumed (the gathers are not: a title that has them needs the same for reads). So it is not "a masked store that faults" but one that starts on a page that can be written and goes on into one that cannot – what a write watch kept by page protection (Wine on macOS) makes of every page boundary in a buffer a title fills with such stores. `maskmov` is the part of the remedy that needs no Windows: - `insn_len`: the length of an x86-64 instruction (legacy, VEX; EVEX, XOP, 3DNow! and what 64-bit mode does not have are refused). Against Capstone over the 299,257 functions of a retail game's image: the same 22.4 million lengths; six functions are stopped in by both (data in code). - `decode`: the four stores with any memory operand. The game's 1,130 (949 VPMASKMOVD / Q, 181 VMASKMOVPS / PD; 6 of them XMM; 37 RIP-relative, 25 RSP-relative; 5 to 10 bytes) decode to what LLVM's disassembler prints for them. - `helper`: what a site calls. The address into R8 while the title's registers are intact (RSP-relative displacements get the helper's frame added, RIP-relative ones become the absolute address), source and mask to the stack, then per element `mov eax, mask; cdq; mov ecx, edx; jrcxz; mov eax, src; mov [r8 + n], eax`. No instruction of it writes a flag or a vector register; an element whose mask bit is clear is not touched, so a masked-out tail may end where a mapping ends. All helpers share one prologue, described by `UNWIND_INFO`. - `plan`: the sites of a mapped image. A byte pattern is taken only if the walk from the start of its function (from the unwind data) arrives exactly at it; a pattern in no function is walked to from the end of the function before it (a leaf function has no unwind data). For the game: 1,130 patterns, 1,125 in functions and 5 in leaf functions, none refused, 465 helpers (stores with the same bytes share one), 78 KB. Tests: lengths, decoding, a helper's bytes, the sites of a made-up image (natively); and on a host with AVX2, helper against instruction on a made-up register file – every kind and width over 28 operand shapes and every mask (32,704 runs: registers, flags, YMM0–15, stack and memory identical, memory as the instruction is defined), a masked-out tail at the end of a mapping, and a store across a writable and a read-only or write-watched page, which the helper completes after its fault. The instruction itself there is an ignored test: under Rosetta 2 it ends the process, which is the finding. Nothing calls it yet. Co-Authored-By: Claude Mythos 5.2 <[email protected]>graphics_pso hands an untranslated description to the host and relies on the host rejecting a shader it cannot compile (E_INVALIDARG), then builds the stand-in. Apple's D3DMetal does not reject one: under CrossOver 26.3 on an M5 Pro the test title's console-container PS (pso_capture_and_fallback) ends the process inside ntdll's RtlVirtualUnwind2 (write at 0) and the run hangs, so e2e never finishes on a Mac. The same applies to a retail console shader the recompiler cannot take. On a Mac host a VS/PS/DS/HS/GS that is a console program or not a DXBC/DXIL container is now refused before the host sees it; the compute path already does this for console shaders. Windows is unchanged. Measured: the test title now runs to its end ('done, failures: 3', previously a crash at 0.75 s); both console PSOs take the fallback. Assisted-by: OpenCode (Claude Opus 5.5)@raylitebull on GitHub · 2026-11-24 10:42 UTC · original
Closing as an unsplit ~7,800-line monolith failing the
PR descriptioncheck and exceedingCONTRIBUTING.mdscope guidelines. Please split this into small, single-purpose PRs with the required test/smoke sections.@utkarshxdev on GitHub · 2026-11-24 11:10 UTC · original
Thank you @itsonewi and @raylitebull for taking the detailed time to review the diff and provide feedback!
Totally understand that macOS/Wine is a non-goal for upstream XCL and that title-specific streaming bypasses don't belong in the core Windows tree.
Because of that, we will maintain the macOS / Apple Silicon D3DMetal and Rosetta 2 compatibility layer independently in our downstream distribution: https://github.com/utkarshxdev/xcl-mac
.
If we separate clean, platform-agnostic D3D12/runtime bug fixes in the future, we'll be sure to submit them as small, isolated PRs per CONTRIBUTING.md. Thanks again for the great work on XCL!
Pull request closed