Skip to content

VKD3D-Proton macOS 5.2

Choose a tag to compare

@github-actions github-actions released this 07 Nov 03:32
· 8691 commits to main since this release
1dcaa3e

VKD3D-Proton macOS 5.2 is built from main (1dcaa3e, #17). It moves most of VKD3D-Proton's remaining SPIR-V pipelines onto Apple's Metal Shader Converter, fixes accuracy bugs found along the way, and makes draws, dispatches and pipeline creation cheaper. It also fixes Subnautica 2 and God of War Ragnarök pipeline failures.

Across the 147 tests/perf scenes (x86_64 under FEX, Apple M6), the geometric mean against 5.1 is −23% CPU, −21% GPU and −9% peak memory.

What the Metal Shader Converter now takes

In 5.1, shaders of these kinds stayed on SPIR-V. In 5.2 they go through the converter:

  • Typed buffers (Buffer<T>, RWBuffer<T>). The one exception is three-component 32-bit typed SRVs. Each D3D12 view gets an exact Metal texel view, so the converter no longer reads from element 0.
  • Mesh shaders, with or without an amplification shader (Nanite).
  • Depth-only passes: pipelines with no pixel shader, or with nothing to write at all.
  • Dual-source blending.
  • SM 6.8 draw parameters.
  • DXBC (SM 4.x/5.x) shaders, through DirectXShaderCompiler's dxilconv. This needs the new libdxbcconverter.dylib. Set METALSHARP_MSC_DXBC=0 to keep DXBC on SPIR-V.
  • The depth bounds test and min/max sampler filtering, on Apple10 GPUs with macOS 26.

Games

  • Subnautica 2: its mesh pipelines that pass a texture with a min-LOD clamp to a helper function compile now. SPIRV-Cross didn't pass the clamp word along, so those pipelines failed: 0 compile failures now.
  • God of War Ragnarök: its tessellation pipelines compile now. Before, the game quit around 80 s in with "The system is out of memory. Try increasing the size of the PageFile." That message was VKD3D-Proton's E_OUTOFMEMORY for a pipeline that failed to compile. The vertex shader packed its outputs for the hull shader in a layout the hull shader doesn't read.

Accuracy fixes

  • Depth clip: nothing in front of the near plane was clipped in any D3D game. MoltenVK ran every render pass in Metal's OpenGL mode. It now uses that mode only for the draws that need it.
  • ResourceMinLODClamp: views were moved to their clamped mip, so textures came out blurrier and GetDimensions was wrong. MoltenVK now has VK_EXT_image_view_min_lod, and both paths clamp, comparison samples included.
  • Sampler MipLODBias: it was ignored on M1 to M4 and on macOS 14 and 15. It is now applied on both paths.
  • Min/max samplers on converted shaders before Apple10: they read as linear. Those PSOs now stay on SPIR-V.
  • f32tof16 rounds toward zero and saturates to 65504. It used to round to nearest and return +inf, which can turn bright HDR values into NaNs.
  • D24 depth bias is no longer 8× too small at depth 0.1, which showed as shadow acne.
  • Cull distances: the converter drops SV_CullDistance, so shaders that write it stay on SPIR-V.
  • SV_StencilRef: the converter ignores it, so pixel shaders that write it stay on SPIR-V.
  • Barycentrics: wrong when they were a pixel shader's only input, because of an Apple driver bug. SPIRV-Cross now works around it.
  • EvaluateAttributeSnapped no longer reads 1/16 pixel low.
  • R10G10B10A2_UINT vertex attributes now make a pipeline.
  • Geometry shaders:
    • correct primitive IDs and winding on cut strips;
    • one-pixel points;
    • cut triangle strips with adjacency;
    • several streams.
  • pow2 tessellator partitioning now rounds factors up to a power of 2.
  • Stripped DXBC (no reflection) is bridged now.
  • Fixes from reviewing the branch: a use-after-free in shadow descriptor entries, and stale views keeping freed buffers' memory.

Performance (tests/perf, Apple M6, against the 5.1 lane)

  • Predication: each predicated draw used to end the render pass. 2000 predicated draws: 53 → 0.49 ms CPU and 67 → 0.91 ms GPU.
  • 64-bit atomics used a hashed spin lock. Max and min are now native, and add, sub and bitwise ops split into two 32-bit atomics. atomics64_contended: 384 → 0.08 ms CPU and 381 → 0.22 ms GPU.
  • Sampler feedback skips the lock when the write would change nothing. sampler_feedback: 22.2 → 0.32 ms GPU.
  • Geometry shaders run up to 32 input primitives per threadgroup. xfb_gs_dxbc: 11.3 → 1.0 ms GPU. Cube shadow maps: −36% to −51% GPU.
  • Cheaper bridge draws and dispatches:
    • the SPIR-V bindings are no longer flushed;
    • arguments identical to the last push aren't pushed again;
    • dispatch arguments come from a ring buffer;
    • typed views are shared between descriptors of the same range;
    • conversions are cached by blob.
  • Slower: out-of-bounds buffer loads on the converter take +50% to +100% GPU, because it loads through a null pointer. Typed views at offsets that are never reused cost more too, mostly from Metal validating each view.

Tests

  • More than 50 new tests/d3d12 tests.
  • An op-level DXIL/DXBC differential test (opdiff).
  • A converter feature sweep, written up in docs/msc-feature-coverage.md.
  • tests/run/matrix.sh runs the suite on Metal 4 and Metal 3 (METALSHARP_METAL_VERSION=3 acts as macOS 14 and 15), with and without the bridge, on native arm64 and on x86_64 under FEX. Every combination passes except d3d11on12 on native arm64, which needs the lane's DXGI.

Known gaps

  • Geometry and tessellation shaders stay on SPIR-V. The converter's emulation contract is written up in docs/msc-geometry-emulation.md.
  • Isoline tessellation makes no pipeline.
  • Tessellation followed by a geometry shader skips its draws.
  • Pipeline statistics queries read 0.
  • Aliasing barriers between draws end the render pass. Apple GPUs have no memory barriers inside a render pass.
  • ResourceMinLODClamp isn't applied to gathers.

Built from 1dcaa3e. Each package holds its files, their licenses and SHA256SUMS.

  • vkd3d-proton-v5.2-x86_64: VKD3D-Proton's d3d12.dll and d3d12core.dll, with DXVK's dxgi.dll, d3d11.dll and d3d10core.dll, for x86_64 Windows programs (x86_64-windows). Stage them together.
  • vkd3d-proton-v5.2-arm64: for an arm64 Wine that runs x86_64 programs with FEX (MetalSharp Wine): VKD3D-Proton's d3d12.dll and d3d12core.dll as ARM64X (aarch64-windows, loaded by x86_64 programs as ARM64EC), with DXVK's x86_64 dxgi.dll, d3d11.dll and d3d10core.dll (x86_64-windows), and the lane's own NGX core and NVAPI (nvngx.dll, nvapi64.dll, ARM64X), which run DLSS Super Resolution and Ray Reconstruction on MetalFX.
  • moltenvk-v5.2-universal: the universal (arm64 + x86_64), ad-hoc signed libMoltenVK.dylib and MoltenVK_icd.json both lanes run on, with Apple's Metal Shader Converter library (libmetalirconverter.dylib, unmodified, Apple-signed), which MoltenVK uses to convert DXIL compute, vertex, mesh, amplification and pixel shaders for VKD3D-Proton (METALSHARP_MSC=0 turns it off), and DirectXShaderCompiler's DXBC to DXIL converter (libdxbcconverter.dylib, NCSA), which hands it DXBC shaders too (METALSHARP_MSC_DXBC=0 keeps them on SPIR-V). It runs MetalFX's scalers for VKD3D-Proton's and DXVK's DLSS and swap chain upscaling (mvk_metalfx.h).