Skip to content

Void Terrarium: fully playable on the Linux/macOS port (stacked on #47)#1

Closed
xnetcat wants to merge 2 commits into
mainfrom
void-terrarium-on-pr47
Closed

Void Terrarium: fully playable on the Linux/macOS port (stacked on #47)#1
xnetcat wants to merge 2 commits into
mainfrom
void-terrarium-on-pr47

Conversation

@xnetcat

@xnetcat xnetcat commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Based on current upstream main (includes the merged sharpemu#47); the branch is a single commit on top of it. This brings void tRrLM();++ //Void Terrarium++ [PPSA03061] from "boots to a frozen splash" to fully playable on the POSIX port: boot → title menu → New Game → intro → gameplay, verified end-to-end unattended (SHARPEMU_AUTO_CROSS=repeat:4) with clean rendering and no crash over multiple 15-minute soaks.

What's in here

GPU / AGC. The Gen5 (RDNA2) shader front end learns the instructions this game's shaders actually use: ds_write/ds_read_b96/b128 with graphics-stage LDS modeled as per-invocation private memory (the missing piece that silently dropped the scene geometry draws — the "black screen" was never a game stall), DPP, wave masks, gradient sampling, typed buffer resources, and stricter descriptor validation. Draws that still fail translation degrade (1×1 fallback texture, unresolved-scalar degradation) instead of being dropped. Texture format 50 (sampled A2R10G10B10) aliases the on-GPU render target. CPU-side detiling (GnmTiling) runs by default for the linearly-ordered base swizzle modes 1–12 with a precomputed per-block offset table; _T/_X variants stay opt-in behind SHARPEMU_DETILE=1.

Command processor. DCB submissions are queued per logical queue and pumped in order: an unsatisfied WAIT_REG_MEM suspends the queue and resumes when the label is written, instead of parsing packets out of order (this plus the sceAgcDmaDataPatchSetSrcAddressOrOffsetOrImmediate implementation fixes the one-frame-then-freeze render loop). PM4 completion and end-of-pipe writeback are modeled precisely enough for the game's fences.

Presenter. Offscreen draw batching into shared command-buffer submissions, texture/descriptor/pipeline caching with SIGSEGV-based guest-image write tracking for invalidation, flip pacing to the display cadence, MRT support for all color targets, an F1 perf overlay, and MoltenVK performance defaults (async queue submits, concurrent pipeline compilation, Metal argument buffers). Window close and Ctrl-C request cooperative guest shutdown and force a process exit if a wedged guest ignores it.

Kernel / HLE. APR file streaming (sceKernelAprResolveFilepathsToIds, sceKernelAprGetFileStat — without these, asset streaming returns NOT_FOUND and the game never leaves its splash), SCE fiber context switching (the game schedules on fibers), savedata transaction resources, pthread TLS destructor passes on thread exit, AudioOut with a CoreAudio backend and proper 5.1→stereo downmix, Ngs2, AvPlayer, message/error dialogs, and the trophy/CES/telemetry startup stubs — zero unresolved imports for this title.

Scheduler. A background Ready-thread dispatcher so a hot-spinning guest thread (this game busy-polls sceAudioOutOutput) cannot starve runnable threads; the old behavior only pumped the ready queue on blocking HLE calls and deadlocked the loader.

Input. Building on the host input seam from sharpemu#192: SHARPEMU_AUTO_CROSS=repeat[:seconds] keeps pressing Cross on an interval (release guaranteed between presses) so a headless run drives itself through the menus into gameplay; a timed-offset list (SHARPEMU_AUTO_CROSS="40,52,64") is also supported, with SHARPEMU_AUTO_CROSS_HOLD_MS and SHARPEMU_LOG_AUTO_CROSS=1 to tune/observe it. SHARPEMU_AUTO_WALK=<start-seconds> rotates a held d-pad direction for unattended tutorial/dungeon traversal (start it past the title menu). Pad and AudioOut2 accept the user id the user service hands out — a mismatch there used to strand the game with an error code as its pad handle and no working input.

Verified / performance

PPSA03061 v01.000.000 on macOS 27 (Apple M4, Rosetta 2, MoltenVK 1.4.1):

state before this branch
boot frozen splash, 0 draws full boot → gameplay, unattended
title screen 60.0 fps locked (16.7 ms)
story / gameplay scenes 13–20 fps
window close / Ctrl-C on a wedged guest headless zombie process forced exit after 2 s

In-game frame times are bound by the guest's own x86-64 code under Rosetta 2: a dotnet-trace cpu-sampling capture at 13–18 fps gameplay attributes ~100 % of self-time to unmanaged guest execution (managed emulator code ≈ 0 %), and the intro cinematic renders the same ~110 draws/frame at 55–60 fps — heavier scenes simply run 3–4× more guest CPU per frame. Total process CPU in-game is ~1–1.6 cores. dotnet test passes (26/26); Windows paths are untouched.

Known issues

  • Intermittent boot-time failure under Rosetta (~1 in 4 launches: unrecovered guest SIGSEGV or event-flag wait during loading); a relaunch gets through. Pre-existing flakiness, not introduced here — tracked separately.
  • _T/_X swizzle detile variants remain opt-in (block placement only approximated).

Summary by CodeRabbit

  • New Features
    • Added improved graphics rendering, shader compatibility, texture handling, and optional performance overlay.
    • Added native audio playback support for Linux and macOS.
    • Added broader compatibility for video, audio, error dialogs, system services, file operations, and game services.
    • Added improved TLS, threading, controller automation, and guest application argument support.
  • Bug Fixes
    • Improved synchronization, frame pacing, memory handling, GPU waits, and recovery from guest execution faults.
    • Corrected missing-file and unsupported-format handling.
  • Release
    • Standardized versioning and packaging across Windows, macOS, and Linux.

Copilot AI review requested due to automatic review settings July 15, 2026 04:07
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: af21c1b1-db80-480e-9cd6-7d4590794e8e

📥 Commits

Reviewing files that changed from the base of the PR and between fa2616d and 901c72e.

📒 Files selected for processing (58)
  • .github/workflows/workflow.yml
  • .gitignore
  • Directory.Build.props
  • src/SharpEmu.CLI/Program.cs
  • src/SharpEmu.CLI/SharpEmu.CLI.csproj
  • src/SharpEmu.Core/Cpu/CpuDispatcher.cs
  • src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.Diagnostics.cs
  • src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.Exceptions.cs
  • src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.Imports.cs
  • src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.NativeWorker.cs
  • src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.PosixSignals.cs
  • src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.cs
  • src/SharpEmu.Core/Loader/SelfImage.cs
  • src/SharpEmu.Core/Loader/SelfLoader.cs
  • src/SharpEmu.Core/Runtime/SharpEmuRuntime.cs
  • src/SharpEmu.GUI/SharpEmu.GUI.csproj
  • src/SharpEmu.HLE/CpuContext.cs
  • src/SharpEmu.HLE/GuestImageWriteTracker.cs
  • src/SharpEmu.HLE/GuestThreadExecution.cs
  • src/SharpEmu.HLE/GuestTlsTemplate.cs
  • src/SharpEmu.HLE/HostMemory.cs
  • src/SharpEmu.Libs/Agc/AgcExports.cs
  • src/SharpEmu.Libs/Agc/Gen5ShaderIr.cs
  • src/SharpEmu.Libs/Agc/Gen5ShaderMetadataReader.cs
  • src/SharpEmu.Libs/Agc/Gen5ShaderPreflightScanner.cs
  • src/SharpEmu.Libs/Agc/Gen5ShaderScalarEvaluator.cs
  • src/SharpEmu.Libs/Agc/Gen5ShaderTranslator.cs
  • src/SharpEmu.Libs/Agc/Gen5SpirvTranslator.Alu.cs
  • src/SharpEmu.Libs/Agc/Gen5SpirvTranslator.cs
  • src/SharpEmu.Libs/Agc/Gfx10UnifiedFormat.cs
  • src/SharpEmu.Libs/Agc/GnmTiling.cs
  • src/SharpEmu.Libs/Agc/GpuWaitRegistry.cs
  • src/SharpEmu.Libs/Agc/SpirvModuleBuilder.cs
  • src/SharpEmu.Libs/Ampr/AmprExports.cs
  • src/SharpEmu.Libs/Audio/AlsaAudioPort.cs
  • src/SharpEmu.Libs/Audio/AudioOut2Exports.cs
  • src/SharpEmu.Libs/Audio/CoreAudioPort.cs
  • src/SharpEmu.Libs/Audio/IHostAudioPort.cs
  • src/SharpEmu.Libs/AvPlayer/AvPlayerExports.cs
  • src/SharpEmu.Libs/Bink/Bink2MovieBridge.cs
  • src/SharpEmu.Libs/Codec/CodecExports.cs
  • src/SharpEmu.Libs/CommonDialog/ErrorDialogExports.cs
  • src/SharpEmu.Libs/CommonDialog/MsgDialogExports.cs
  • src/SharpEmu.Libs/Fiber/FiberExports.cs
  • src/SharpEmu.Libs/HostTiming.cs
  • src/SharpEmu.Libs/Kernel/KernelExports.cs
  • src/SharpEmu.Libs/Kernel/KernelFileExtendedExports.cs
  • src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs
  • src/SharpEmu.Libs/Kernel/KernelPthreadExtendedCompatExports.cs
  • src/SharpEmu.Libs/Ngs2/Ngs2Exports.cs
  • src/SharpEmu.Libs/Pad/PadExports.cs
  • src/SharpEmu.Libs/SaveData/SaveDataExports.cs
  • src/SharpEmu.Libs/SharpEmu.Libs.csproj
  • src/SharpEmu.Libs/Stubs/GameServiceStubs.cs
  • src/SharpEmu.Libs/SystemService/SystemServiceExports.cs
  • src/SharpEmu.Libs/VideoOut/PerfOverlay.cs
  • src/SharpEmu.Libs/VideoOut/VideoOutExports.cs
  • src/SharpEmu.Libs/VideoOut/VulkanVideoPresenter.cs

📝 Walkthrough

Walkthrough

This change updates release packaging, runtime execution, TLS and memory handling, AGC shader and GPU processing, audio/media compatibility, kernel exports, and Vulkan presentation synchronization.

Changes

Runtime and platform integration

Layer / File(s) Summary
Release packaging and startup configuration
.github/workflows/workflow.yml, Directory.Build.props, src/SharpEmu.CLI/*, *.csproj
Build version extraction, platform startup settings, MoltenVK configuration, and unified release artifact publishing are updated.
Native execution and guest scheduling
src/SharpEmu.Core/Cpu/*, src/SharpEmu.HLE/GuestThreadExecution.cs
Import state transfer, guest continuations, ready-thread dispatch, allocator recovery, watchdog behavior, and guest thread scheduling APIs are updated.
TLS and host memory
src/SharpEmu.Core/Loader/*, src/SharpEmu.HLE/GuestTlsTemplate.cs, src/SharpEmu.HLE/GuestImageWriteTracker.cs, src/SharpEmu.HLE/HostMemory.cs
Static and dynamic TLS registration, relocation handling, guest image dirty tracking, and cross-platform virtual memory operations are added or revised.

AGC and GPU pipeline

Layer / File(s) Summary
AGC command and shader processing
src/SharpEmu.Libs/Agc/AgcExports.cs, src/SharpEmu.Libs/Agc/Gen5*, src/SharpEmu.Libs/Agc/Gfx10UnifiedFormat.cs, src/SharpEmu.Libs/Agc/GnmTiling.cs
DCB submission, shader decoding, scalar evaluation, SPIR-V translation, unified-format decoding, and texture detiling are substantially updated.
Vulkan presentation and synchronization
src/SharpEmu.Libs/VideoOut/*
Vblank timing, frame-slot synchronization, guest image writes, texture and buffer caching, pipeline caching, compute dispatch, and Vulkan teardown are reworked.

Compatibility services

Layer / File(s) Summary
Audio, media, and dialogs
src/SharpEmu.Libs/Audio/*, src/SharpEmu.Libs/AvPlayer/*, src/SharpEmu.Libs/Bink/*, src/SharpEmu.Libs/Codec/*, src/SharpEmu.Libs/CommonDialog/*
Linux and macOS audio ports, audio pacing, media validation, Bink bridging, codec handles, and dialog state handling are added or revised.
Fibers and kernel operations
src/SharpEmu.Libs/Fiber/*, src/SharpEmu.Libs/Kernel/*, src/SharpEmu.Libs/HostTiming.cs
Fiber continuation handling, thread cleanup, file operations, descriptor duplication, polling, synchronous AIO, and host timing are implemented or updated.
Compatibility exports
src/SharpEmu.Libs/Ngs2/*, src/SharpEmu.Libs/Pad/*, src/SharpEmu.Libs/SaveData/*, src/SharpEmu.Libs/Stubs/*, src/SharpEmu.Libs/SystemService/*
NGS2 state handling, controller automation, save-data memory access, game-service stubs, and system-service string retrieval are updated.

Estimated code review effort: 5 (Critical) | ~120 minutes

Suggested reviewers: par274

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch void-terrarium-on-pr47

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@xnetcat

xnetcat commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

In-game FPS: profiled at real gameplay (story/dungeon scenes)

Captured a 30 s dotnet-trace cpu-sampling session at 13–18 fps story-scene gameplay (uncontended M4, Rosetta 2):

  • Managed emulator code: 0.0 % of CPU self-time. Every sampled thread bottoms out in UNMANAGED_CODE_TIME — the guest's own x86-64 code executing under Rosetta 2.
  • Draw recording is ~10 % of one core (draw_ms ≈ 105–128 per second at ~110 draws/frame).
  • Cross-check: the intro cinematic renders the same ~110 draws/frame at 55–60 fps; story/dungeon frames simply run ~3–4× more guest CPU per frame.

Conclusion: in-game fps is bounded by the game's simulation under Rosetta, not emulator overhead. The realistic levers are a native x86-64 host or an ARM64 recompiler — both out of scope here.

Also landed while validating: SHARPEMU_AUTO_WALK=<start-seconds> (unattended dungeon traversal for profiling), forced process exit when window-close/Ctrl-C shutdown is ignored by a wedged guest (armed before the Vulkan teardown, which can hang), and the pad/audio user-id fix that previously left the game inputless.

@xnetcat xnetcat force-pushed the linux-macos-support branch from 3739e39 to 1bfb48a Compare July 15, 2026 12:25
@xnetcat xnetcat force-pushed the void-terrarium-on-pr47 branch from 9574ffb to a7bb8cd Compare July 15, 2026 13:04
@xnetcat xnetcat changed the base branch from linux-macos-support to main July 15, 2026 13:04
par274 and others added 2 commits July 15, 2026 16:07
* [CI] Update for cross-platform support

* [CI] fix check
Brings up void tRrLM();++ //Void Terrarium++ from frozen-splash to
gameplay on the POSIX port, with unattended-run helpers and the GPU
work the title needs:

- GPU/AGC: RDNA2/Gen5 shader translation coverage (graphics-stage LDS
  via ds_read/ds_write b96/b128 modeled as private memory, DPP, wave
  masks, gradient sampling, typed resources), texture format 50
  aliasing of A2R10G10B10 render targets, default-on CPU detiling for
  base swizzle modes 1-12 (GnmTiling), draw degradation instead of
  silent draw drops on translation failures.
- Command processor: per-queue ordered DCB submission with
  WAIT_REG_MEM suspend/resume, PM4 completion and end-of-pipe
  writeback, sceAgcDmaDataPatchSetSrcAddressOrOffsetOrImmediate.
- Presenter: offscreen draw batching, texture/descriptor caching with
  SIGSEGV-based guest-image write tracking, flip pacing, MRT support,
  F1 perf overlay; window close / Ctrl-C request cooperative guest
  shutdown and force process exit if the guest ignores it.
- Kernel/HLE: APR file streaming (sceKernelAprResolveFilepathsToIds,
  sceKernelAprGetFileStat), SCE fiber context switching, savedata
  transaction resources, pthread TLS destructor passes on thread exit,
  AudioOut with CoreAudio backend and 5.1->stereo downmix, Ngs2,
  AvPlayer, dialogs, trophy/CES/telemetry startup stubs.
- Scheduler: background Ready-thread dispatcher so hot-spinning guest
  threads cannot starve runnable ones.
- Input: SHARPEMU_AUTO_CROSS=repeat[:seconds] (+_HOLD_MS, LOG) and
  SHARPEMU_AUTO_WALK=<start-seconds> for unattended menu traversal and
  dungeon wandering; pad/audio accept the user id the user service
  hands out.

Verified on macOS (M4, Rosetta 2, MoltenVK): title menu at locked
60 fps, story/gameplay scenes render cleanly; frame times there are
bound by guest x86-64 execution under Rosetta (managed emulator code
samples at ~0% CPU).
@xnetcat xnetcat force-pushed the void-terrarium-on-pr47 branch from a7bb8cd to 901c72e Compare July 15, 2026 13:16
@xnetcat

xnetcat commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the upstream PR: sharpemu#208 (same branch, rebased onto upstream main).

@xnetcat xnetcat closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants