Skip to content

Releases: sharpemu/sharpemu-mac

SharpEmu v0.0.7-pulse

Choose a tag to compare

@github-actions github-actions released this 01 Nov 11:06
b246d8d

SharpEmu for macOS v0.0.7-pulse

Upstream SharpEmu dropped macOS (sharpemu#1123), and this repository is now the macOS build of the PS5 emulator. Since v0.0.6 the whole emulator has been ported to macOS on Apple silicon. That covers host memory, CPU execution, the kernel and HLE libraries, the shader compiler and the GPU backend. The fork adds 237k lines of source and 168k lines of tests on top of upstream. Upstream SharpEmu 0.0.7-pulse is merged in.

Platform

  • Native macOS host (src/platforms/macos, ~10k lines): guest memory, windowing, input and display. Per-OS host packages and SDL/Skia adapters.
  • CPU: the x86-64 guest code runs directly under Rosetta 2, and imports go through a native import path. AGC packet builders and other hot HLE entry points are answered by native stubs inside the guest.
  • Kernel and HLE: reworked kernel memory, files, sync and event queues, and the host seam and guest memory model.
    • Fibers lock per stripe instead of through one global gate.
    • The thread-local storage lookup __tls_get_addr is cached per thread.
    • User-level-thread (ULT) wakeups are targeted to the waiters that changed.
    • Pthread mutexes spin while the owner runs.
    • Short sleeps nap on an escalating schedule.
  • macOS 27: the OS reserves VA ranges that PS5 titles map. The loader relocates the affected arena bases, including GTA V's RAGE arena and Ghost of Tsushima's batch maps, and maps virtual views into the GPU carveout.
  • Spin-nap patcher: guest pause/spin loops are patched to sleep. Demon's Souls' idle job workers nap instead of spinning.
  • Display: the guest render resolution follows the chosen output. There are patches for Unity (boot.config), Unreal, KEX, GTA V, small engines compiled for 3840×2160, and Demon's Souls (its Bluepoint resolution adapter).

GPU: Metal V2

  • Metal-only renderer (SharpEmu.Gpu.Metal, ~70k lines). There is no Vulkan or MoltenVK layer, and the earlier Metal V1 backend is removed.
  • Command processing runs on its own thread by default.
    • Program resolution and prefetch run on a separate thread, with pipeline look-ahead across the submissions queued behind it.
    • Encoders are ordered by one fence instead of a barrier after each.
  • Resource materialization is native and cached. Bindless tables are memoised and kept resident. Repeated lookups skip searches that found nothing last time.
  • Image cache:
    • Single-copy retile.
    • Write-back of GPU-written images before guest stores.
    • Alias transitions fused, with dead contents discarded.
    • Memoryless stand-ins for colour targets that are only read or stored.
    • Depth/stencil reached on the device instead of through guest memory.
  • Occlusion queries are counted on the device.
  • Tessellation uses the hull kernel plus Metal's tessellator, including Ghost of Tsushima's quad-patch instanced grass.
  • Multisampling: multisampled depth goes through a one-sample proxy plus resolve. A GPU-written HTILE is no longer loaded as a clear (UE5 Nanite).
  • Pipeline cache:
    • Shaders compile into Metal binary archives, bounded by use and shared across builds.
    • Shader prewarm stores compute pipelines.
    • Guest stores are served while a draw waits for its shader compiles.
  • GPU worker: no per-draw or per-dispatch allocations, fewer guest re-reads, less lock traffic. Bench tooling is in-tree.

Shader compiler: gfx10 → MSL

  • Translator (SharpEmu.ShaderCompiler.Metal, ~25k lines) emits Metal Shading Language directly, at gfx10 ISA parity.
  • wave64 runs as two Apple simdgroups. Multi-wave compute groups are bridged across simdgroups and meet at threadgroup barriers. Upper-lane reads and LDS atomics are ordered across the halves.
  • NGG and mesh: amplified NGG subgroups run as whole mesh workgroups of real wave64 waves.
  • Ray tracing: BVH nodes are read 16 bytes at a time, with half-precision boxes widened in hardware.
  • Descriptors: records chosen at run time, branch-chosen V#s, indirect image tables of up to 256 descriptors, and stores through V#s loaded from record tables are all planned and bound.
  • Fixes: SDWA destination select, s_cmpk_*, GDS M0 addressing, FORCE_DEGAMMA samplers, min/max filter samplers, compare samples of mipmapped images, and GLC store write-through.

Split GPU process

  • The GPU backend runs in a separate native arm64 process, now the default where it can run.
    • It maps the guest's backing memory and replicates the guest's views.
    • The two processes talk over a shared-memory transport (protocol 2).
  • Page-protection tracking is per 4 KiB page. A posted call wakes a single server thread.
  • build-app.sh bundles the arm64 GPU host in Contents/MacOS/gpuhost.

App

  • The launcher is a native arm64 Avalonia app and is the bundle's main executable. Game windows and Dock tiles are named after the game.
  • Launcher settings are global, and game settings are per game, with automatic migration. GUI and CLI share one launch configuration.
  • All logs, traces and dumps go under one logs folder. Caches are kept outside the signed bundle.
  • The performance overlay shows real CPU, GPU busy time and memory for both processes.

Upstream 0.0.6 → 0.0.7-pulse

  • Tessellation, draw reuse and GNM mode.
  • XML and pattern game patches, with a patch manager.
  • Shader warm-up progress on the splash screen.
  • SPIR-V optimisation passes and UE4 ray-tracing shader-call programs.
  • Fixes for Saros, Elden Ring, Tomb Raider Legend, NGS2/ATRAC9 and AGC occlusion.
  • Simplified Chinese.

Performance (Apple M4, 1080p, in game)

Game FPS
Quake, Superliminal, Void Terrarium, Dreaming Sarah 60
The Oregon Trail ~58
Poppy Playtime ~47
GTA V (Performance) ~46
Silent Hill: The Short Message ~29
GTA V (Fidelity) ~7
Demon's Souls ~3–7 (bound by the game's own CPU work)

Known issues

  • GTA V Fidelity mode runs at about 7 fps in game. Use Performance mode.
  • Demon's Souls is limited by its own job-worker threads. It can also crash intermittently while loading (1 in 3 runs here).
  • Tested on Apple silicon (M4) only.

Contributors

macOS port

  • @xnetcat: the macOS port, Metal V2, the shader compiler, the split GPU process and the launcher
  • @gavinnolan: Ghost of Tsushima and Black Myth: Wukong on Metal V2, the native GPU process, tessellation, multisampled depth, occlusion queries and shader compiler work
  • @voidborn-astra: memory and kernel mapping fixes, shader translation and GPU/AGC correctness fixes
  • @juanfariasdev: queued mutex waiters spin for their grant before parking

Upstream fixes brought into the port
@Stoltemberg, @theantipopau, @soufian3hmdz, @Leonid749, @AtsonMelo, @yeshaswi3060, @Armi1014, @NickPom, @ajaysaagar-dev, @semirkabir, @zsigisti, @Fayberr, @SulaymanKh

Upstream SharpEmu 0.0.6 → 0.0.7-pulse
@par274, @Im-Usif, @Kuaryn, @simplehima, @Nenderus