Skip to content

armgit / soju

Public Imported from GitHub
0

Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.

soju ue: packaged Unreal Engine Windows builds on the CX engine (#238)

Ege BULUTe96d08e0ea15
diff --git a/README.md b/README.md
index a31c86a3b97..c15fbb2d11a 100644
--- a/README.md
+++ b/README.md
@@ -215,6 +215,10 @@ Verified 2026-08-30: install, login, library. GOG GALAXY 2.x is Qt6 + QtWebEngin
Games have not been broadly tested yet; anything that needs kernel anti-cheat (EAC/BattlEye) will not run under Wine.
+## Packaged Unreal Engine builds
+
+A Windows build of an Unreal Engine 4 or 5 game that you have as a folder (your own project's package, or a build a developer sent you) starts with `soju ue <folder>`, in a bottle of its own, on the same engine and D3DMetal as Xbox PC games. Checked with a UE5 Direct3D 12 build on an 8 GB M1; see [docs/UNREAL.md](docs/UNREAL.md).
+
## Xbox PC / Microsoft Store (Xodus backend, experimental)
Xbox Series X|S console games are a separate, earlier experiment: `soju xcl` runs [XCL](https://github.com/xcl-dev/xcl) on Soju's engine without CrossOver. Nothing is playable yet; see [docs/XCL.md](docs/XCL.md).
diff --git a/docs/UNREAL.md b/docs/UNREAL.md
new file mode 100644
index 00000000000..9215fe54633
--- /dev/null
+++ b/docs/UNREAL.md
@@ -0,0 +1,50 @@
+# Packaged Unreal Engine builds (Windows)
+
+`soju ue` starts a Windows build of an Unreal Engine 4 or 5 game that you have as a folder: your own project's
+package (File > Package Project > Windows), or a build a developer sent you to test. It runs on Soju's CX engine with
+Apple's D3DMetal, in the same environment as Xbox PC games (`scripts/xbox-wine.sh`), and each project gets a bottle
+of its own in `~/.battlenet-macos/ue-bottles/<Project>`. It needs the engine and Apple GPTK (`soju install`, then
+`soju gptk`). The game folder is only read.
+
+```sh
+soju ue ~/Games/MyProject/Windows # windowed at 1280x720
+soju ue ~/Games/MyProject/Windows -ResX=1920 -ResY=1080 -windowed # your arguments replace the default ones
+```
+
+What it does:
+
+- Starts `<Project>/Binaries/Win64/<Project>-Win64-Shipping.exe` directly. The `<Project>.exe` at the top of the
+ package only starts that file, and starting the real one is more reliable under Wine. A package without a Shipping
+ exe (Development or DebugGame) is started through the exe at the top.
+- On a new bottle, installs Microsoft's VC++ 2015-2022 x64 runtime, which Unreal builds link against. It is the same
+ installer the Xbox prefix uses: downloaded from Microsoft, checked by SHA-256, never redistributed.
+- Turns off Unreal's "known issues with graphics driver" window, as for the other Unreal games (`ue_driver_warning.py`).
+- Ctrl+C in the Terminal, or closing the Terminal window, stops everything in the bottle.
+
+## Things to know
+
+- **The first start is slow.** D3DMetal converts the game's shaders for Metal. On an M1 the first start took about
+ 6.5 minutes before the menu appeared. Leave it running.
+- **Pick the graphics preset in the game.** The build tested started on the High preset and ignored a
+ `GameUserSettings.ini` written into the bottle beforehand. Choose a preset in the game's own settings; it is kept
+ for the next start. `soju fps on` shows the frame rate.
+- **Memory.** On an 8 GB Mac the game used about 3.4 GB. With a browser open alongside, the first start swapped and
+ stalled for a while. Close large apps first.
+- **Logs.** Wine's output goes to `~/.battlenet-macos/logs/ue-<Project>.log` (replaced on every start). Unreal's own
+ log and settings are in the bottle, under
+ `drive_c/users/crossover/AppData/Local/<Project>/Saved/Logs/` and `.../Saved/Config/Windows/GameUserSettings.ini`.
+ Remove account names and personal paths before posting them.
+- Not covered: games with kernel anti-cheat; the DLSS-through-MetalFX bridge that Soju's launchers set up
+ (`gptk-dlss.sh`) is not turned on here.
+
+## What was checked (2026-11-25, MacBook Pro M1 8 GB, macOS 26.6, engine-v1.10, GPTK 3.0)
+
+| Check | Result |
+|---|---|
+| A UE5 Direct3D 12 Shipping build, `-Win64-Shipping.exe` started directly in this environment, VC++ runtime in the bottle | menu and gameplay |
+| First start | about 6.5 minutes of shader conversion |
+| Lowest preset, 1280x720 windowed | 100-110 FPS |
+| Low preset, 1280x720 windowed | 50-60 FPS |
+
+The game was played with a launcher that sets the same environment and starts the same file; `soju ue` itself is
+covered by `tests/test_ue_wine.py`. UE4 packages (`WindowsNoEditor/`) have the same layout but were not tried.
diff --git a/scripts/soju b/scripts/soju
index 2446fbe9f94..12734178870 100755
--- a/scripts/soju
+++ b/scripts/soju
@@ -36,6 +36,8 @@ Usage:
soju vr play Play D2R in VR (OXRSys client on the headset; offline characters)
soju vr play --flat Open the VR copy without VR to create offline characters with the mouse
soju vr status|remove
+ soju ue <folder> [args] Play a packaged Unreal Engine 4/5 Windows build you have as files
+ (own bottle per project; windowed 1280x720 without args)
soju xcl setup Xbox Series X|S game code through XCL (experimental, nothing playable yet;
needs your own unpacked game files): setup, run <folder>, status, remove
@@ -106,6 +108,7 @@ case "${1:-}" in
steam-install) shift; export SOJU_PLATFORMS=steam; exec bash "$ROOT/install.sh" "$@" ;;
vr) shift; exec python3 "$ROOT/scripts/d2r-vr.py" "$@" ;;
xcl) shift; exec python3 "$ROOT/scripts/xcl.py" "$@" ;;
+ ue) shift; exec bash "$ROOT/scripts/ue-wine.sh" "$@" ;;
xbox-install) exec bash "$ROOT/scripts/xbox.sh" install ;;
xbox-login) exec bash "$ROOT/scripts/xbox.sh" login ;;
xbox-logout) shift; exec bash "$ROOT/scripts/xbox.sh" logout "$@" ;;
diff --git a/scripts/ue-wine.sh b/scripts/ue-wine.sh
new file mode 100755
index 00000000000..c4ebad79af1
--- /dev/null
+++ b/scripts/ue-wine.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+# soju ue <folder> [game arguments]: start a packaged Unreal Engine 4 or 5
+# Windows build that you have as files (your own project's package, or a build
+# a developer sent you) on the CX engine with D3DMetal, in a bottle of its own
+# per project (ue-bottles/<Project>). Same engine and environment as
+# scripts/xbox-wine.sh.
+#
+# <folder> is the package (<Project>.exe next to <Project>/ and Engine/). That
+# exe only starts <Project>/Binaries/Win64/<Project>-Win64-Shipping.exe, which
+# is started directly here; the exe at the top is used when there is no
+# Shipping exe. Without game arguments the game opens windowed at 1280x720.
+set -u
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"
+ENGINE="${ENGINE:-$BASE/cx26-engine}"
+FOLDER="${1:?usage: soju ue <folder with the packaged Windows build> [game arguments]}"; shift
+[ $# -gt 0 ] || set -- -ResX=1280 -ResY=720 -windowed
+
+shopt -s nullglob
+found=("$FOLDER"/*/Binaries/Win64/*-Win64-Shipping.exe "$FOLDER"/Binaries/Win64/*-Win64-Shipping.exe)
+[ ${#found[@]} -gt 0 ] || found=("$FOLDER"/*.exe)
+shopt -u nullglob
+[ ${#found[@]} -gt 0 ] || { echo "soju: no <Project>-Win64-Shipping.exe or <Project>.exe in $FOLDER" >&2; exit 1; }
+EXE="${found[0]}"
+NAME="$(basename "$EXE" .exe)"; NAME="${NAME%-Win64-Shipping}"
+
+[ -x "$ENGINE/bin/wine" ] || { echo "soju: the engine is not installed; run: soju install" >&2; exit 1; }
+[ -f "$ENGINE/lib/external/libd3dshared.dylib" ] || { echo "soju: Unreal's Direct3D 12 needs Apple's Game Porting Toolkit; run: soju gptk" >&2; exit 1; }
+W="$ENGINE/bin/wine"; WS="$ENGINE/bin/wineserver"
+export WINEPREFIX="$BASE/ue-bottles/$NAME"
+export WINEDEBUG="${WINEDEBUG:-fixme-all}"
+export WINEMSYNC="${WINEMSYNC:-1}"
+[ -f "$BASE/fps-hud" ] && export MTL_HUD_ENABLED=1 # soju fps on
+export ROSETTA_ADVERTISE_AVX="${ROSETTA_ADVERTISE_AVX:-1}"
+[ "$ROSETTA_ADVERTISE_AVX" = 0 ] && unset ROSETTA_ADVERTISE_AVX
+export WINE_SIMULATE_WRITECOPY=1
+export CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal
+export CX_GRAPHICS_BACKEND=d3dmetal
+export CX_APPLEGPTK_LIBD3DSHARED_PATH="$ENGINE/lib/external/libd3dshared.dylib"
+export DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib"
+
+mkdir -p "$WINEPREFIX" "$BASE/logs"
+LOG="$BASE/logs/ue-$NAME.log"
+: > "$LOG"
+if [ ! -f "$WINEPREFIX/system.reg" ]; then
+ echo "Creating the bottle $WINEPREFIX"
+ "$W" wineboot -u >>"$LOG" 2>&1
+ "$WS" -w
+fi
+
+# Unreal builds link Microsoft's VC++ 2015-2022 x64 runtime. It is the installer
+# the Xbox prefix uses (scripts/xbox-prefix.py), downloaded from Microsoft and
+# checked by SHA-256, never redistributed.
+if [ ! -f "$WINEPREFIX/.soju-vcrun" ]; then
+ read -r vc_version vc_sha vc_url < <(python3 -c 'import runpy, sys
+v = runpy.run_path(sys.argv[1])["VC"]; print(v["version"], v["sha256"], v["url"])' "$DIR/xbox-prefix.py")
+ vc="$BASE/build/vc_redist.x64-$vc_version.exe"
+ if [ "$(shasum -a 256 "$vc" 2>/dev/null | cut -d' ' -f1)" != "$vc_sha" ]; then
+ echo "Downloading the Microsoft VC++ runtime"
+ mkdir -p "$BASE/build"
+ curl --fail --silent --show-error --location --proto =https --proto-redir =https --max-time 600 \
+ "$vc_url" --output "$vc.part" && mv -f "$vc.part" "$vc"
+ if [ "$(shasum -a 256 "$vc" 2>/dev/null | cut -d' ' -f1)" != "$vc_sha" ]; then
+ rm -f "$vc" "$vc.part"
+ echo "soju: the VC++ runtime download failed or did not match its checksum" >&2; exit 1
+ fi
+ fi
+ echo "Installing the VC++ runtime into the bottle"
+ "$W" "$vc" /install /quiet /norestart >>"$LOG" 2>&1; code=$?
+ "$WS" -w
+ # 1638 (a same or newer version is installed) and 3010 (restart pending) as an 8-bit exit status.
+ case "$code" in
+ 0|102|194) echo "$vc_version" > "$WINEPREFIX/.soju-vcrun" ;;
+ *) echo "soju: the VC++ runtime did not install (code $code); Wine log: $LOG" >&2; exit 1 ;;
+ esac
+fi
+
+python3 "$DIR/ue_driver_warning.py" "$WINEPREFIX" >/dev/null 2>&1 || true # no driver warning window
+
+echo "Starting $EXE"
+echo "The first start converts the game's shaders for Metal and can take several minutes. Wine log: $LOG"
+cd "$(dirname "$EXE")" || exit 1
+# The bottle holds only this game: Ctrl+C or closing the Terminal ends all of it.
+trap '"$WS" -k; exit 130' INT TERM HUP
+"$W" "$(basename "$EXE")" "$@" >>"$LOG" 2>&1 &
+wait $!
+status=$?
+"$WS" -w
+[ "$status" = 0 ] || echo "soju: the game exited with code $status; Wine log: $LOG" >&2
+exit "$status"
diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh
index c61377e3c83..5bbe1a8bf31 100755
--- a/scripts/uninstall.sh
+++ b/scripts/uninstall.sh
@@ -30,8 +30,14 @@ names_engine(){
# Stop only after this bottle's removal (or engine removal) was accepted.
stop_bottle() {
- local b="$1" ws="$ENGINE/bin/wineserver"
+ local b="$1" ws="$ENGINE/bin/wineserver" p
[ -d "$BASE/$b" ] || return 0
+ if [ "$b" = ue-bottles ]; then # soju ue: one bottle per project
+ for p in "$BASE/$b"/*/; do
+ if [ -f "$p/system.reg" ]; then stop_bottle "$b/$(basename "$p")"; fi
+ done
+ return 0
+ fi
case "$b" in ea-bottle|rockstar-bottle|ubisoft-bottle)
[ -x "$BASE/cx26-engine-launchers/bin/wineserver" ] && ws="$BASE/cx26-engine-launchers/bin/wineserver" ;;
esac
@@ -97,7 +103,7 @@ if [ "${#apps[@]}" -gt 0 ]; then
fi
# 3. Bottles (this is where installed games live; can be tens of GB).
-for b in bottle steam-bottle epic-bottle gog-bottle ea-bottle rockstar-bottle ubisoft-bottle xbox-bottle; do
+for b in bottle steam-bottle epic-bottle gog-bottle ea-bottle rockstar-bottle ubisoft-bottle xbox-bottle ue-bottles; do
d="$BASE/$b"
[ -d "$d" ] || continue
sz=$(du -sh "$d" 2>/dev/null | cut -f1)
@@ -148,7 +154,7 @@ fi
if [ -d "$ENGINE" ]; then
sz=$(du -sh "$ENGINE" 2>/dev/null | cut -f1)
if ask "Remove the engine ($sz, includes the GPTK payload; re-downloadable with soju install)?"; then
- for b in bottle epic-bottle gog-bottle ea-bottle rockstar-bottle ubisoft-bottle; do stop_bottle "$b"; done
+ for b in bottle epic-bottle gog-bottle ea-bottle rockstar-bottle ubisoft-bottle ue-bottles; do stop_bottle "$b"; done
rm -rf "$ENGINE" "$BASE/cx26-engine-launchers"; REMOVED=1; echo " removed"
fi
fi
diff --git a/tests/test_ue_wine.py b/tests/test_ue_wine.py
new file mode 100644
index 00000000000..41c1bd405c1
--- /dev/null
+++ b/tests/test_ue_wine.py
@@ -0,0 +1,113 @@
+"""soju ue: a packaged Unreal Engine Windows build on the CX engine, with a fake engine that records its calls."""
+import os
+import subprocess
+import tempfile
+import unittest
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+SCRIPT = ROOT / "scripts/ue-wine.sh"
+
+
+def fake_engine(base):
+ eng = base / "cx26-engine"
+ (eng / "bin").mkdir(parents=True)
+ (eng / "lib/external").mkdir(parents=True)
+ (eng / "lib/external/libd3dshared.dylib").write_bytes(b"dylib")
+ wine = eng / "bin/wine" # records where and how it was started instead of running Windows code
+ wine.write_text('#!/bin/sh\n[ "$1" = wineboot ] && { : > "$WINEPREFIX/system.reg"; exit 0; }\n'
+ 'echo "$PWD|$WINEPREFIX|$CX_GRAPHICS_BACKEND|$*" >> "$SOJU_BASE/wine-calls"\n')
+ server = eng / "bin/wineserver"
+ server.write_text('#!/bin/sh\necho "$WINEPREFIX $*" >> "$SOJU_BASE/wineserver-calls"\n')
+ for f in (wine, server):
+ f.chmod(0o755)
+
+
+def package(folder, project):
+ win64 = folder / project / "Binaries/Win64"
+ win64.mkdir(parents=True)
+ (win64 / (project + "-Win64-Shipping.exe")).write_bytes(b"MZ")
+ (folder / (project + ".exe")).write_bytes(b"MZ")
+ (folder / "Engine/Binaries/Win64").mkdir(parents=True)
+ (folder / "Engine/Binaries/Win64/CrashReportClient.exe").write_bytes(b"MZ")
+
+
+def ready_bottle(base, name):
+ bottle = base / "ue-bottles" / name
+ bottle.mkdir(parents=True)
+ (bottle / "system.reg").write_text("WINE REGISTRY Version 2\n")
+ (bottle / ".soju-vcrun").write_text("14\n")
+ return bottle
+
+
+class UnrealWineTests(unittest.TestCase):
+ def setUp(self):
+ self.tmp = tempfile.TemporaryDirectory()
+ self.base = Path(self.tmp.name).resolve() / "soju"
+ fake_engine(self.base)
+ env = {k: v for k, v in os.environ.items()
+ if not k.startswith(("WINE", "DYLD_", "CX_", "ROSETTA_", "MTL_")) and k != "ENGINE"}
+ self.env = dict(env, SOJU_BASE=str(self.base))
+
+ def tearDown(self):
+ self.tmp.cleanup()
+
+ def run_ue(self, *args):
+ return subprocess.run(["bash", str(SCRIPT), *map(str, args)], env=self.env, capture_output=True, text=True)
+
+ def calls(self):
+ return (self.base / "wine-calls").read_text().splitlines()
+
+ def test_shipping_exe_starts_directly_in_its_own_bottle_windowed_unless_given_arguments(self):
+ game = Path(self.tmp.name).resolve() / "Windows"
+ package(game, "MyProject")
+ bottle = ready_bottle(self.base, "MyProject")
+ self.assertEqual(self.run_ue(game).returncode, 0)
+ self.assertEqual(self.run_ue(game, "-log", "-ResX=1920").returncode, 0)
+ first, second = self.calls()
+ win64 = str(game / "MyProject/Binaries/Win64")
+ self.assertEqual(first, f"{win64}|{bottle}|d3dmetal|MyProject-Win64-Shipping.exe -ResX=1280 -ResY=720 -windowed")
+ self.assertEqual(second, f"{win64}|{bottle}|d3dmetal|MyProject-Win64-Shipping.exe -log -ResX=1920")
+ # A ready bottle is not booted again, and the launch waits for the bottle to empty.
+ self.assertIn(f"{bottle} -w", (self.base / "wineserver-calls").read_text())
+
+ def test_package_without_a_shipping_exe_uses_the_exe_at_the_top(self):
+ game = Path(self.tmp.name).resolve() / "Dev"
+ game.mkdir()
+ (game / "Game.exe").write_bytes(b"MZ")
+ bottle = ready_bottle(self.base, "Game")
+ self.assertEqual(self.run_ue(game).returncode, 0)
+ self.assertEqual(self.calls(), [f"{game}|{bottle}|d3dmetal|Game.exe -ResX=1280 -ResY=720 -windowed"])
+ empty = Path(self.tmp.name) / "empty"
+ empty.mkdir()
+ result = self.run_ue(empty)
+ self.assertEqual(result.returncode, 1)
+ self.assertIn("no <Project>-Win64-Shipping.exe", result.stderr)
+
+ def test_new_bottle_gets_the_pinned_vc_runtime_and_a_bad_download_stops_the_launch(self):
+ game = Path(self.tmp.name).resolve() / "Windows"
+ package(game, "MyProject")
+ tools = Path(self.tmp.name) / "tools"
+ tools.mkdir()
+ curl = tools / "curl" # a download that is not Microsoft's file
+ curl.write_text('#!/bin/sh\necho "$@" >> "$SOJU_BASE/curl-calls"\n'
+ 'while [ $# -gt 0 ]; do [ "$1" = --output ] && echo junk > "$2"; shift; done\n')
+ curl.chmod(0o755)
+ self.env["PATH"] = f"{tools}:{self.env['PATH']}"
+ result = self.run_ue(game)
+ self.assertEqual(result.returncode, 1)
+ self.assertIn("did not match its checksum", result.stderr)
+ bottle = self.base / "ue-bottles/MyProject"
+ self.assertTrue((bottle / "system.reg").is_file())
+ self.assertFalse((bottle / ".soju-vcrun").exists())
+ self.assertFalse((self.base / "wine-calls").exists())
+ self.assertEqual(list((self.base / "build").glob("vc_redist*")), [])
+ self.assertIn("https://download.visualstudio.microsoft.com/", (self.base / "curl-calls").read_text())
+
+ def test_cli_and_uninstall_know_it(self):
+ self.assertIn('ue) shift; exec bash "$ROOT/scripts/ue-wine.sh"', (ROOT / "scripts/soju").read_text())
+ self.assertIn("xbox-bottle ue-bottles; do", (ROOT / "scripts/uninstall.sh").read_text())
+
+
+if __name__ == "__main__":
+ unittest.main()