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.

Add reversible per-game Steam renderer selection and compatibility follow-ups (#50)

Mikek93a2d2aa4b5c
diff --git a/.github/ISSUE_TEMPLATE/compatibility.yml b/.github/ISSUE_TEMPLATE/compatibility.yml
index 8fbf20a9088..9f5d1dd4fdf 100644
--- a/.github/ISSUE_TEMPLATE/compatibility.yml
+++ b/.github/ISSUE_TEMPLATE/compatibility.yml
@@ -30,6 +30,7 @@ body:
id: result
attributes:
label: Result
+ description: Select the furthest stage actually reached. A launcher opening does not mean the game works.
options:
- Works in-game
- Partially works
diff --git a/README.ko.md b/README.ko.md
index 632713d1bfb..a6d89b5bd6a 100644
--- a/README.ko.md
+++ b/README.ko.md
@@ -80,7 +80,7 @@ soju install # 이후: soju battlenet / soju d2r / soju steam / soju epic /
설치기는 **다운로드 전에 원하는 런처부터 선택**합니다. Steam만 선택하면 CX 엔진과 애플 GPTK를 받지 않습니다. Steam 그래픽 구성요소는 SHA-256으로 검증한 뒤 Soju 전용 Wine 11.0 환경에 자동으로 설치합니다. Battle.net·Epic·GOG는 공통 CX 엔진과 사용자가 별도로 받은 애플 GPTK를 사용합니다. 각 런처의 보틀·로그인·게임은 독립적으로 유지합니다.
-[Soju 맥 앱 다운로드](https://github.com/BCD1210/soju/releases/download/v1.6.6/Soju-1.6.6-macos-arm64.zip): 네이티브 앱 프리뷰에서 설치된 게임과 보유 게임, 스토어 검색, 즐겨찾기, 게임 실행, 플랫폼 관리를 한 화면에서 다룰 수 있습니다. [설치 안내와 요구 사항](docs/DESKTOP.md)을 확인해 주세요.
+[Soju 맥 앱 다운로드](https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip): 네이티브 앱 프리뷰에서 설치된 게임과 보유 게임, 스토어 검색, 즐겨찾기, 게임 실행, 플랫폼 관리를 한 화면에서 다룰 수 있습니다. [설치 안내와 요구 사항](docs/DESKTOP.md)을 확인해 주세요.
## 일상 명령
diff --git a/README.md b/README.md
index a9c607711f1..11d64b8eea7 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ CodeWeavers' published sources; Steam uses a separate private Wine 11 setup.
Apple's proprietary GPTK/D3DMetal is downloaded separately. Games and store
clients are not included.
-**Current release: [v1.6.6](https://github.com/BCD1210/soju/releases/tag/v1.6.6).**
+**Current release: [v1.6.7](https://github.com/BCD1210/soju/releases/tag/v1.6.7).**
The compatibility examples below were verified on M4 Pro / macOS 26.5.
D2R and Hogwarts Legacy are examples of supported games, not the scope of the project.
@@ -63,6 +63,10 @@ All verified on an M4 Pro running macOS 26.5. Separate bottles for each launcher
Will not run: anything with kernel anti-cheat (EAC, BattlEye, Vanguard). Got another game running? Post it in [Discussions](https://github.com/BCD1210/soju/discussions) or send a PR that adds a row.
+[Community compatibility reports](docs/COMPATIBILITY.md) track additional user
+results separately from the maintainer-tested examples, including D2R on M5,
+the Dark Souls III renderer workaround, and unresolved launch failures.
+
## Why this exists
Community Wine builds (Whisky, Kegworks-era engines) stopped working with modern Battle.net and D2R. The commercial option works, but the underlying Wine engine is GPL, so we built it ourselves and documented every wall we hit. The investigation and fixes are documented below:
@@ -94,7 +98,7 @@ soju install # then: soju battlenet / soju d2r / soju steam / soju epic / so
The installer asks which launchers you want **before downloading anything**. Steam-only installs skip the CX engine and Apple GPTK. Steam rendering components are downloaded with SHA-256 verification and installed in a Soju-owned Wine 11.0 runtime. Battle.net, Epic and GOG use the shared CX engine and your separately downloaded Apple GPTK. Each official client keeps its own bottle and shortcut in `~/Applications`.
-[Download Soju for Mac](https://github.com/BCD1210/soju/releases/download/v1.6.6/Soju-1.6.6-macos-arm64.zip): the native desktop preview includes installed and owned games, store search, favorites, game launching and platform management. See [desktop setup and requirements](docs/DESKTOP.md).
+[Download Soju for Mac](https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip): the native desktop preview includes installed and owned games, store search, favorites, game launching and platform management. See [desktop setup and requirements](docs/DESKTOP.md).
## Everyday commands
diff --git a/README.zh.md b/README.zh.md
index ce9d084e871..20b80171eb7 100644
--- a/README.zh.md
+++ b/README.zh.md
@@ -84,7 +84,7 @@ soju install # 然后:soju battlenet / soju d2r / soju steam / soju epic /
安装器会**先询问要安装哪些启动器,再下载对应组件**。仅选择 Steam 时,不会下载 CX 引擎或 Apple GPTK。Steam 图形组件经过 SHA-256 校验后,自动安装到 Soju 专用的 Wine 11.0 环境中。战网、Epic 和 GOG 使用共享 CX 引擎及用户单独下载的 Apple GPTK。各客户端的 bottle、账户和游戏分别保留。
-[下载 Soju Mac 应用](https://github.com/BCD1210/soju/releases/download/v1.6.6/Soju-1.6.6-macos-arm64.zip):原生桌面预览版在一个窗口中管理已安装和已拥有的游戏、商店搜索、收藏、游戏启动和平台管理。[安装说明与要求](docs/DESKTOP.md)。
+[下载 Soju Mac 应用](https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip):原生桌面预览版在一个窗口中管理已安装和已拥有的游戏、商店搜索、收藏、游戏启动和平台管理。[安装说明与要求](docs/DESKTOP.md)。
## 日常维护
diff --git a/VERSION b/VERSION
index ec70f755607..400084b1bf2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.6.6
+1.6.7
diff --git a/docs/COMPATIBILITY.md b/docs/COMPATIBILITY.md
new file mode 100644
index 00000000000..59f2617d7c6
--- /dev/null
+++ b/docs/COMPATIBILITY.md
@@ -0,0 +1,18 @@
+# Community compatibility reports
+
+These are user reports, not additional maintainer-verified games. Results can
+depend on the game build, renderer, Mac and macOS version. Opening a store client
+does not establish that its games work.
+
+| Game / store | Reported environment | Result and limits | Source |
+| --- | --- | --- | --- |
+| Diablo II: Resurrected / Battle.net | M5 Air (issue title), macOS 27, Soju 1.6.6 | Reporter reached gameplay at medium settings, 40–60 FPS. Resolution and session duration not supplied; edition name awaits clarification. | [#49](https://github.com/BCD1210/soju/issues/49) |
+| Dark Souls III / Steam | M5 Pro, macOS 26.6.2, Soju 1.6.6 | DXMT stalls for about one minute on enemy kills and Continue. Reporter says per-game DXVK + MoltenVK removes the stalls, at about 30 FPS with a CPU limit. See the opt-in [renderer switch](STEAM-GAMES.md#per-game-renderer). | [#48](https://github.com/BCD1210/soju/issues/48) |
+| Honkai: Star Rail / Epic | MacBook Pro M5, macOS 26.3, Soju 1.6.5 | White screen, cannot reach gameplay. The report's selected “Works in-game” field conflicts with its description; **not a working-game confirmation**. Exact failing process and logs are still needed. | [#47](https://github.com/BCD1210/soju/issues/47) |
+| Diablo II: Resurrected / Battle.net | M2 Max, macOS 26.0.1 | No game window. This OS is below the documented D2R minimum of 26.4. Soju 1.6.6 adds the missing preflight/diagnostic check; the reporter's result after updating macOS is still pending. | [#44](https://github.com/BCD1210/soju/issues/44) |
+
+For Honkai: Star Rail, a white screen alone does not identify a renderer,
+launcher or anti-cheat fault. Please include `soju doctor epic`, the last relevant
+launch log lines, and whether the white window belongs to Epic, HoYoPlay or the
+game. Remove account details and personal paths. The general Wine limitation for
+kernel anti-cheat still applies; this project does not supply anti-cheat bypasses.
diff --git a/docs/DESKTOP.md b/docs/DESKTOP.md
index 6db43f7951c..b5dcef1de17 100644
--- a/docs/DESKTOP.md
+++ b/docs/DESKTOP.md
@@ -1,6 +1,6 @@
# Soju for Mac
-[Download v1.6.6](https://github.com/BCD1210/soju/releases/download/v1.6.6/Soju-1.6.6-macos-arm64.zip)
+[Download v1.6.7](https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip)
1. Unzip and move **Soju.app** into Applications or ~/Applications.
2. Open **Platforms** to install or open Battle.net, Steam, Epic Games or GOG GALAXY.
diff --git a/docs/STEAM-GAMES.md b/docs/STEAM-GAMES.md
index 73350f90fb8..fd978688ed9 100644
--- a/docs/STEAM-GAMES.md
+++ b/docs/STEAM-GAMES.md
@@ -58,6 +58,46 @@ Hard-won facts, in the order they burned us:
`soju steam-install` now downloads verified prebuilt DXMT, the patched Wine driver and wrapper. Existing users can close Steam and run `soju steam-games`. A private Wine runtime preserves the Homebrew app. This component release requires macOS 26+ and Wine 11.0. See [sources and validation](STEAM-PREBUILTS.md).
+## Per-game renderer
+
+DXMT remains the default. For a **64-bit Steam game** with a renderer-specific
+problem, the CLI can select DXVK + MoltenVK for just that executable. In [#48](https://github.com/BCD1210/soju/issues/48), a Dark Souls III player reports that this avoids minute-long GPU stalls, with a lower, CPU-limited frame rate of about 30 FPS. This is a user-tested workaround, not a claim that the DXMT fault is fixed.
+
+Close Windows Steam and all its games first. Use the full **Mac path** to the game
+executable; for a default Dark Souls III install:
+
+```bash
+GAME="$HOME/.battlenet-macos/steam-bottle/drive_c/Program Files (x86)/Steam/steamapps/common/DARK SOULS III/Game/DarkSoulsIII.exe"
+soju steam-games renderer dxvk "$GAME"
+```
+
+Soju downloads the pinned [Gcenx DXVK-macOS native package](https://github.com/Gcenx/DXVK-macOS/releases/tag/v1.10.3-20230507-repack), checks the archive and DLL SHA-256 digests, backs up existing game-local DLLs and overrides, then installs only `d3d11.dll` and `d3d10core.dll` next to the game. The executable's `dxgi=native` uses Soju's existing vanilla Wine DXGI; `winemetal` is disabled for this executable. No DLLs are replaced in the shared Wine runtime or Steam client. `dxvk.conf` and async settings are left unchanged.
+
+```bash
+soju steam-games renderer status "$GAME" # inspect without changing anything
+soju steam-games renderer dxmt "$GAME" # explicitly use Soju's DXMT
+soju steam-games renderer reset "$GAME" # restore the original files and overrides
+```
+
+Restart Steam and the game after a change. Renderer setup/repair writes only the
+global defaults and Steam client profiles, so game-specific overrides remain.
+This command preserves previous settings, including a manually installed
+workaround: `reset` returns to that original configuration, whereas `dxmt`
+explicitly selects DXMT. Wine scopes overrides by executable name, so another
+game with the same executable name in this bottle cannot have a separate profile.
+Executables sharing a directory also share the local DLLs and cannot have competing
+profiles. If a game updater or another tool changes the managed DLLs/overrides,
+Soju refuses to overwrite those changes; recovery copies are kept under the
+Steam bottle's `.soju-renderers` directory.
+
+The upstream DXMT tessellation change mentioned in #48 has **not** been applied:
+the reporter also found a Wine driver deadlock with upstream main, so replacing
+the pinned runtime needs separate compatibility testing.
+
+### Renderer validation
+
+On 2026-09-28, the D3D11 hardware smoke test passed on M4 Pro / macOS 26.5 in a temporary prefix: default DXMT, per-game DXVK, DXVK after a full `--repair`, explicit DXMT, and reset to the original configuration. Each pass created a hardware device and swapchain and presented 180 frames. No installed game files were used. This verifies the switch and repair behavior; Dark Souls III gameplay and performance still require confirmation from the reporter.
+
## Building the artifacts
Based on notpop's `07-build-dxmt-fork.sh` / `08-patch-wine-visibility.sh`, with
diff --git a/docs/index.html b/docs/index.html
index 2ed86954fb1..49ed3c84b4f 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -124,7 +124,7 @@ its own login, purchases, downloads and game updates.</p>
<section id="install" aria-labelledby="install-title">
<h2 id="install-title">Choose your launchers. Get set up.</h2>
-<p><a class="btn" href="https://github.com/BCD1210/soju/releases/download/v1.6.6/Soju-1.6.6-macos-arm64.zip">Download Soju for Mac</a></p>
+<p><a class="btn" href="https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip">Download Soju for Mac</a></p>
<p>The native desktop preview combines installed and imported owned games, searches stores and manages all four launchers.
Apple Silicon · app UI: macOS 14+ · Steam component build: macOS 26+.
<a href="https://github.com/BCD1210/soju/blob/main/docs/DESKTOP.md">Setup and signing notes</a>.</p>
diff --git a/resources/steam-dxvk.json b/resources/steam-dxvk.json
new file mode 100644
index 00000000000..d522d2f3edf
--- /dev/null
+++ b/resources/steam-dxvk.json
@@ -0,0 +1,11 @@
+{
+ "version": "v1.10.3-20230507-repack",
+ "upstream": "https://github.com/Gcenx/DXVK-macOS/releases/tag/v1.10.3-20230507-repack",
+ "url": "https://github.com/Gcenx/DXVK-macOS/releases/download/v1.10.3-20230507-repack/dxvk-macOS-async-v1.10.3-20230507-repack.tar.gz",
+ "sha256": "acd1520ad105d8ef124a09c8e11a259a5dc8bdc565ad18e0e52693f9807b2477",
+ "archive_root": "dxvk-macOS-async-v1.10.3-20230507-repack",
+ "files": {
+ "d3d10core.dll": "0fa08bba860c63e3abeeabfc96d0e7aa327411a975f8f23d2dc63594ef5f796e",
+ "d3d11.dll": "0ff0b0835dde29556bd01dfce7b1ae348d7f229cb1e1a37cc71ea1a028beeca4"
+ }
+}
diff --git a/scripts/setup-steam-games.sh b/scripts/setup-steam-games.sh
index 5dce0e435a4..8a516a0812c 100755
--- a/scripts/setup-steam-games.sh
+++ b/scripts/setup-steam-games.sh
@@ -23,6 +23,10 @@
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+if [ "${1:-}" = renderer ]; then
+ shift
+ exec python3 "$ROOT/scripts/steam-renderer.py" "$@"
+fi
BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"
export WINEPREFIX="${WINEPREFIX:-$BASE/steam-bottle}"
source "$ROOT/scripts/steam-runtime.sh"
diff --git a/scripts/soju b/scripts/soju
index 25b109d47d1..38653930c8d 100755
--- a/scripts/soju
+++ b/scripts/soju
@@ -37,6 +37,8 @@ Usage:
soju steam-install Set up the Steam bottle (private Wine 11 + wrapper + Steam)
soju steam-games Download and configure verified D3D11 components
+ soju steam-games renderer <dxvk|dxmt|reset|status> <game.exe path>
+ Choose a renderer for one 64-bit game (close Steam first)
soju steam Launch Steam
soju steam-kill Stop everything in the Steam bottle
diff --git a/scripts/steam-renderer.py b/scripts/steam-renderer.py
new file mode 100644
index 00000000000..e46c895796b
--- /dev/null
+++ b/scripts/steam-renderer.py
@@ -0,0 +1,267 @@
+#!/usr/bin/env python3
+"""Select DXMT or DXVK for one 64-bit Steam game; preserve the Steam client."""
+import argparse
+import fcntl
+import hashlib
+import importlib.util
+import json
+import os
+from pathlib import Path, PurePosixPath
+import re
+import shutil
+import struct
+import subprocess
+import sys
+import tarfile
+import tempfile
+
+ROOT = Path(__file__).resolve().parents[1]
+DLLS = ("d3d11", "d3d10core", "dxgi", "winemetal")
+FILES = ("d3d11.dll", "d3d10core.dll")
+RESERVED = {"steam.exe", "steamwebhelper.exe", "steamwebhelper_real.exe",
+ "steamservice.exe", "wineboot.exe", "explorer.exe", "services.exe"}
+spec = importlib.util.spec_from_file_location("steam_session", ROOT / "scripts/steam-session.py")
+session = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(session)
+
+
+def signature(path):
+ if path.is_symlink() or (path.exists() and not path.is_file()):
+ raise ValueError("Refusing to replace a link or non-file: " + str(path))
+ return hashlib.sha256(path.read_bytes()).hexdigest() if path.exists() else None
+
+
+def atomic(path, data):
+ with tempfile.NamedTemporaryFile(dir=path.parent, delete=False) as stream:
+ temporary = Path(stream.name)
+ try:
+ stream.write(data)
+ stream.flush()
+ os.fchmod(stream.fileno(), path.stat().st_mode & 0o777 if path.exists() else 0o600)
+ os.replace(temporary, path)
+ finally:
+ temporary.unlink(missing_ok=True)
+
+
+def section(text, exe):
+ key = ("Software\\Wine\\AppDefaults\\" + exe + "\\DllOverrides").replace("\\", "\\\\")
+ lines = text.splitlines(keepends=True)
+ start = end = len(lines)
+ matches = []
+ for i, line in enumerate(lines):
+ if line.startswith("["):
+ if start < len(lines) and end == len(lines):
+ end = i
+ if line.split("]", 1)[0][1:].casefold() == key.casefold():
+ matches.append(i)
+ start, end = i, len(lines)
+ if len(matches) > 1:
+ raise ValueError("Duplicate game registry sections; no changes made")
+ return lines, start, end, key
+
+
+def overrides(text, exe):
+ lines, start, end, _ = section(text, exe)
+ result = dict.fromkeys(DLLS)
+ seen = set()
+ for line in lines[start + 1:end]:
+ match = re.match(r'^"([^"]+)"=(.*)', line)
+ if match and match[1].casefold() in result:
+ name = match[1].casefold()
+ if name in seen:
+ raise ValueError("Duplicate renderer override: " + name)
+ seen.add(name)
+ value = json.loads(match[2])
+ if not isinstance(value, str):
+ raise ValueError("Unsupported renderer registry value: " + name)
+ result[name] = value
+ return result
+
+
+def with_overrides(text, exe, values):
+ lines, start, end, key = section(text, exe)
+ kept = [line for line in lines[start + 1:end]
+ if not any(line.casefold().startswith('"' + dll + '"=') for dll in DLLS)]
+ added = [json.dumps(k) + "=" + json.dumps(v, ensure_ascii=False) + "\n"
+ for k, v in values.items() if v is not None]
+ if start == len(lines):
+ return text + ("\n[" + key + "]\n" + "".join(added) if added else "")
+ return "".join(lines[:start + 1] + added + kept + lines[end:])
+
+
+def validate_game(game):
+ if game.name.casefold() in RESERVED or not re.fullmatch(r"[\w .()+-]+\.exe", game.name, re.I):
+ raise ValueError("Choose the game's .exe, not a Steam client or system executable")
+ with game.open("rb") as stream:
+ if stream.read(2) != b"MZ":
+ raise ValueError("The game must be a 64-bit Windows executable")
+ stream.seek(0x3c)
+ offset = struct.unpack("<I", stream.read(4))[0]
+ stream.seek(offset)
+ if stream.read(6) != b"PE\0\0\x64\x86":
+ raise ValueError("Only x86-64 games are supported by this renderer switch")
+
+
+def fetch_dxvk(base):
+ manifest = json.loads((ROOT / "resources/steam-dxvk.json").read_text())
+ target = base / "steam-support" / ("dxvk-" + manifest["version"])
+ if all(signature(target / name) == sha for name, sha in manifest["files"].items()):
+ return target
+ target.parent.mkdir(parents=True, exist_ok=True)
+ with tempfile.TemporaryDirectory(dir=target.parent) as work:
+ work = Path(work)
+ archive = work / "dxvk.tar.gz"
+ subprocess.run(["/usr/bin/curl", "--fail", "--location", "--proto", "=https",
+ "--connect-timeout", "20", "--max-time", "180", "--retry", "2",
+ manifest["url"], "--output", str(archive)], check=True)
+ if signature(archive) != manifest["sha256"]:
+ raise ValueError("DXVK download checksum mismatch; game unchanged")
+ wanted = {manifest["archive_root"] + "/x64/" + name: name for name in FILES}
+ seen = set()
+ with tarfile.open(archive, "r:gz") as tar:
+ for member in tar:
+ path = PurePosixPath(member.name)
+ if path.is_absolute() or ".." in path.parts or not (member.isfile() or member.isdir()):
+ raise ValueError("Unsafe DXVK archive")
+ if member.name not in wanted:
+ continue
+ name = wanted[member.name]
+ if name in seen or not member.isfile() or member.size > 32 * 1024 * 1024:
+ raise ValueError("Invalid DXVK archive member")
+ seen.add(name)
+ with tar.extractfile(member) as source:
+ (work / name).write_bytes(source.read())
+ if seen != set(FILES) or any(signature(work / n) != sha for n, sha in manifest["files"].items()):
+ raise ValueError("DXVK files failed checksum verification")
+ target.mkdir(exist_ok=True)
+ for name in FILES:
+ atomic(target / name, (work / name).read_bytes())
+ return target
+
+
+def configure(base, prefix, runtime, game, mode):
+ game = game.expanduser().resolve(strict=True)
+ validate_game(game)
+ registry = prefix / "user.reg"
+ if not registry.is_file() or registry.is_symlink():
+ raise ValueError("Install Steam first: soju steam-install")
+ states = prefix / ".soju-renderers"
+ record = states / (hashlib.sha256(game.name.casefold().encode()).hexdigest() + ".json")
+ state = json.loads(record.read_text()) if record.exists() else None
+ if state and state["game"] != str(game):
+ raise ValueError("Another game with this executable name has a profile in this bottle. Reset it first.")
+ if states.is_dir():
+ for other in states.glob("*.json"):
+ if other != record and Path(json.loads(other.read_text())["game"]).parent == game.parent:
+ raise ValueError("Another executable in this directory owns the shared DLLs. Reset its profile first.")
+ text = registry.read_text(encoding="utf-8", errors="surrogateescape")
+ current = overrides(text, game.name)
+ if mode == "status":
+ return {"game": str(game), "renderer": state["renderer"] if state else "unmanaged",
+ "overrides": current}
+ session.require_idle(runtime)
+ # Reset remains available if the runtime has been removed or damaged.
+ if mode != "reset" and (not (runtime / ".soju-runtime").is_file() or
+ not (prefix / ".soju-steam-games").is_file()):
+ raise ValueError("Prepare the Soju Steam renderer first: soju steam-games")
+ if mode == "reset" and state is None:
+ return {"game": str(game), "renderer": "unmanaged", "message": "No Soju renderer profile to reset"}
+ paths = {name: game.parent / name for name in FILES}
+ # A case variant would be the same DLL to Wine, but a second file on some Macs.
+ for child in game.parent.iterdir():
+ if child.name.casefold() in FILES and child.name != child.name.casefold():
+ raise ValueError("Rename the existing DLL to lowercase before configuring it: " + str(child))
+ signatures = {name: signature(path) for name, path in paths.items()}
+ if state and (signatures != state["managed_files"] or current != state["managed_overrides"]):
+ raise ValueError("Game DLLs or overrides changed outside Soju; preserving them. Inspect the renderer profile before retrying.")
+ backup = states / record.stem
+ if state:
+ for name, sha in state["original_files"].items():
+ if sha is not None and signature(backup / name) != sha:
+ raise ValueError("Renderer recovery copy is missing or changed")
+ payload = fetch_dxvk(base) if mode == "dxvk" else None
+ # The download can take time. Recheck before touching the game or registry.
+ session.require_idle(runtime)
+ if registry.read_text(encoding="utf-8", errors="surrogateescape") != text or any(
+ signature(paths[n]) != signatures[n] for n in FILES):
+ raise ValueError("Steam settings or game files changed during preparation; retry after closing Steam")
+ states.mkdir(exist_ok=True)
+ if state is None:
+ backup.mkdir(exist_ok=False)
+ try:
+ for name, path in paths.items():
+ if signatures[name] is not None:
+ shutil.copy2(path, backup / name)
+ except BaseException:
+ shutil.rmtree(backup)
+ raise
+ state = {"game": str(game), "original_overrides": current, "original_files": signatures}
+ original_state = record.read_bytes() if record.exists() else None
+ before = {name: path.read_bytes() if path.exists() else None for name, path in paths.items()}
+ desired = (dict.fromkeys(DLLS, "builtin") if mode == "dxmt" else
+ {"d3d11": "native", "d3d10core": "native", "dxgi": "native", "winemetal": "disabled"}
+ if mode == "dxvk" else state["original_overrides"])
+ # Persist recovery information before modifying any game file.
+ atomic(record, json.dumps({**state, "renderer": "recovery-required",
+ "managed_files": signatures, "managed_overrides": current}, indent=2).encode())
+ try:
+ for name, path in paths.items():
+ data = ((payload / name).read_bytes() if payload else
+ (backup / name).read_bytes() if state["original_files"][name] is not None else None)
+ if data is None:
+ path.unlink(missing_ok=True)
+ else:
+ atomic(path, data)
+ atomic(registry, with_overrides(text, game.name, desired).encode("utf-8", errors="surrogateescape"))
+ if mode == "reset":
+ record.unlink()
+ else:
+ state.update(renderer=mode, managed_files={n: signature(p) for n, p in paths.items()},
+ managed_overrides=desired)
+ atomic(record, json.dumps(state, indent=2).encode())
+ except BaseException:
+ # Restore all original bytes on an interrupted/failed transaction.
+ for name, path in paths.items():
+ if before[name] is None:
+ path.unlink(missing_ok=True)
+ else:
+ atomic(path, before[name])
+ atomic(registry, text.encode("utf-8", errors="surrogateescape"))
+ if original_state is None:
+ record.unlink(missing_ok=True)
+ shutil.rmtree(backup)
+ else:
+ atomic(record, original_state)
+ raise
+ if mode == "reset":
+ shutil.rmtree(backup)
+ return {"game": str(game), "renderer": "original" if mode == "reset" else mode,
+ "message": "Restart Windows Steam and the game. Other executable profiles are unchanged."}
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("mode", choices=("dxvk", "dxmt", "reset", "status"))
+ parser.add_argument("game", type=Path, help="full Mac path to the game's 64-bit .exe")
+ args = parser.parse_args()
+ base = Path(os.environ.get("SOJU_BASE", str(Path.home() / ".battlenet-macos"))).expanduser().resolve()
+ prefix = Path(os.environ.get("WINEPREFIX", str(base / "steam-bottle"))).expanduser().resolve()
+ runtime = Path(os.environ.get("SOJU_STEAM_WINE", str(base / "steam-runtime"))).expanduser().resolve()
+ if not prefix.is_dir():
+ raise ValueError("Install Steam first: soju steam-install")
+ if args.mode == "status":
+ result = configure(base, prefix, runtime, args.game, args.mode)
+ else:
+ with (prefix / ".soju-renderer.lock").open("a") as lock:
+ fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ result = configure(base, prefix, runtime, args.game, args.mode)
+ print(json.dumps(result, indent=2))
+
+
+if __name__ == "__main__":
+ try:
+ main()
+ except (OSError, ValueError, KeyError, RuntimeError, struct.error,
+ subprocess.SubprocessError, tarfile.TarError) as error:
+ print("Steam renderer: " + str(error), file=sys.stderr)
+ sys.exit(1)
diff --git a/tests/steam_d3d11_smoke.c b/tests/steam_d3d11_smoke.c
index b65045d4d13..4d022074735 100644
--- a/tests/steam_d3d11_smoke.c
+++ b/tests/steam_d3d11_smoke.c
@@ -4,7 +4,8 @@
#include <stdio.h>
/* Hardware rendering smoke test. No store account or installed game is needed. */
-int wmain(void) {
+int wmain(int argc, wchar_t **argv) {
+ BOOL expect_dxvk = argc > 1 && wcscmp(argv[1], L"--dxvk") == 0;
HINSTANCE instance = GetModuleHandleW(NULL);
WNDCLASSW wc = {0};
wc.lpfnWndProc = DefWindowProcW;
@@ -27,7 +28,9 @@ int wmain(void) {
HRESULT hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL,
0, NULL, 0, D3D11_SDK_VERSION, &desc, &swap, &device, NULL, &context);
if (FAILED(hr)) { printf("Device/swapchain failed: %08lx\n", hr); return 2; }
- if (!GetModuleHandleW(L"winemetal.dll")) { printf("DXMT winemetal module not loaded\n"); return 6; }
+ if (!!GetModuleHandleW(L"winemetal.dll") == !!expect_dxvk) {
+ printf("Unexpected renderer: winemetal must be loaded only for DXMT\n"); return 6;
+ }
ID3D11Texture2D *buffer = NULL;
ID3D11RenderTargetView *target = NULL;
hr = IDXGISwapChain_GetBuffer(swap, 0, &IID_ID3D11Texture2D, (void **)&buffer);
diff --git a/tests/test_steam_renderer.py b/tests/test_steam_renderer.py
new file mode 100644
index 00000000000..53be6674f57
--- /dev/null
+++ b/tests/test_steam_renderer.py
@@ -0,0 +1,189 @@
+"""Game renderer changes use temporary prefixes; never launch installed games."""
+import importlib.util
+import io
+import json
+from pathlib import Path
+import struct
+import tarfile
+import tempfile
+import unittest
+from unittest.mock import patch
+
+ROOT = Path(__file__).resolve().parents[1]
+spec = importlib.util.spec_from_file_location("steam_renderer", ROOT / "scripts/steam-renderer.py")
+r = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(r)
+
+
+def pe(path, machine=b"\x64\x86"):
+ data = bytearray(128)
+ data[:2] = b"MZ"
+ struct.pack_into("<I", data, 0x3c, 64)
+ data[64:70] = b"PE\0\0" + machine
+ path.write_bytes(data)
+
+
+class RendererTests(unittest.TestCase):
+ def setUp(self):
+ temp = tempfile.TemporaryDirectory()
+ self.addCleanup(temp.cleanup)
+ self.base = Path(temp.name)
+ self.prefix = self.base / "steam-bottle"
+ self.runtime = self.base / "steam-runtime"
+ self.prefix.mkdir(); self.runtime.mkdir()
+ (self.runtime / ".soju-runtime").write_text("v1")
+ (self.prefix / ".soju-steam-games").write_text("v1")
+ self.game = self.prefix / "Dark Souls III" / "DarkSoulsIII.exe"
+ self.game.parent.mkdir(); pe(self.game)
+ self.registry = self.prefix / "user.reg"
+ self.original = ('WINE REGISTRY Version 2\n\n'
+ '[Software\\\\Wine\\\\DllOverrides]\n"d3d11"="builtin"\n\n'
+ '[Software\\\\Wine\\\\AppDefaults\\\\steam.exe\\\\DllOverrides]\n'
+ '"dxgi"="native"\n"winemetal"="disabled"\n\n')
+ self.registry.write_text(self.original)
+ self.payload = self.base / "payload"; self.payload.mkdir()
+ for name in r.FILES: (self.payload / name).write_bytes(("DXVK-" + name).encode())
+ idle = patch.object(r.session, "require_idle")
+ fetch = patch.object(r, "fetch_dxvk", return_value=self.payload)
+ self.idle = idle.start(); self.fetch = fetch.start()
+ self.addCleanup(idle.stop); self.addCleanup(fetch.stop)
+
+ def configure(self, mode, game=None):
+ return r.configure(self.base, self.prefix, self.runtime, game or self.game, mode)
+
+ def test_switch_both_directions_and_reset_preserves_custom_values_and_files(self):
+ original_values = {"d3d11": "native,builtin", "d3d10core": None,
+ "dxgi": "builtin", "winemetal": ""}
+ text = r.with_overrides(self.original, self.game.name, original_values)
+ text += '"unrelated"="keep"\n'
+ self.registry.write_text(text)
+ (self.game.parent / "d3d11.dll").write_bytes(b"original plugin")
+ self.configure("dxvk")
+ self.assertEqual(r.overrides(self.registry.read_text(), self.game.name)["dxgi"], "native")
+ self.assertEqual((self.game.parent / "d3d11.dll").read_bytes(), b"DXVK-d3d11.dll")
+ self.assertTrue(self.registry.read_text().startswith(self.original))
+ self.configure("dxmt")
+ self.assertEqual(r.overrides(self.registry.read_text(), self.game.name), dict.fromkeys(r.DLLS, "builtin"))
+ self.assertEqual((self.game.parent / "d3d11.dll").read_bytes(), b"original plugin")
+ self.assertFalse((self.game.parent / "d3d10core.dll").exists())
+ self.configure("dxvk")
+ self.configure("reset")
+ self.assertEqual(r.overrides(self.registry.read_text(), self.game.name), original_values)
+ self.assertIn('"unrelated"="keep"', self.registry.read_text())
+ self.assertEqual((self.game.parent / "d3d11.dll").read_bytes(), b"original plugin")
+ self.assertFalse(list((self.prefix / ".soju-renderers").glob("*.json")))
+
+ def test_status_and_no_profile_reset_leave_files_unchanged(self):
+ self.assertEqual(self.configure("status")["renderer"], "unmanaged")
+ self.idle.assert_not_called(); self.fetch.assert_not_called()
+ self.configure("reset")
+ self.assertEqual(self.registry.read_text(), self.original)
+ self.assertFalse((self.prefix / ".soju-renderers").exists())
+
+ def test_live_steam_blocks_change_before_download(self):
+ self.idle.side_effect = RuntimeError("Close Windows Steam")
+ with self.assertRaises(RuntimeError): self.configure("dxvk")
+ self.fetch.assert_not_called()
+ self.assertEqual(self.registry.read_text(), self.original)
+
+ def test_steam_starting_during_download_blocks_change(self):
+ self.idle.side_effect = [None, RuntimeError("Close Windows Steam")]
+ with self.assertRaises(RuntimeError): self.configure("dxvk")
+ self.assertEqual(self.registry.read_text(), self.original)
+
+ def test_changed_files_or_registry_are_not_overwritten(self):
+ self.configure("dxvk")
+ (self.game.parent / "d3d11.dll").write_bytes(b"updated by game")
+ with self.assertRaisesRegex(ValueError, "changed outside"): self.configure("reset")
+ self.assertEqual((self.game.parent / "d3d11.dll").read_bytes(), b"updated by game")
+ (self.game.parent / "d3d11.dll").write_bytes(b"DXVK-d3d11.dll")
+ self.registry.write_text(r.with_overrides(self.registry.read_text(), self.game.name, dict.fromkeys(r.DLLS, "builtin")))
+ with self.assertRaisesRegex(ValueError, "changed outside"): self.configure("dxmt")
+
+ def test_duplicate_executable_name_or_shared_game_directory_is_rejected(self):
+ self.configure("dxvk")
+ other = self.prefix / "another" / self.game.name
+ other.parent.mkdir(); pe(other)
+ with self.assertRaisesRegex(ValueError, "executable name"): self.configure("dxvk", other)
+ other = self.game.parent / "other.exe"; pe(other)
+ with self.assertRaisesRegex(ValueError, "shared DLLs"): self.configure("dxvk", other)
+
+ def test_links_and_case_aliases_are_not_replaced(self):
+ target = self.base / "unrelated"; target.write_bytes(b"keep")
+ dll = self.game.parent / "d3d11.dll"; dll.symlink_to(target)
+ with self.assertRaises(ValueError): self.configure("dxvk")
+ self.assertEqual(target.read_bytes(), b"keep")
+ dll.unlink()
+ (self.game.parent / "D3D11.dll").write_bytes(b"keep")
+ with self.assertRaisesRegex(ValueError, "lowercase"): self.configure("dxvk")
+
+ def test_steam_client_and_32_bit_game_are_rejected(self):
+ steam = self.game.parent / "Steam.exe"; pe(steam)
+ with self.assertRaises(ValueError): self.configure("dxvk", steam)
+ pe(self.game, b"\x4c\x01")
+ with self.assertRaisesRegex(ValueError, "x86-64"): self.configure("dxvk")
+
+ def test_failure_restores_all_previous_game_and_registry_bytes(self):
+ before = self.game.parent / "d3d11.dll"; before.write_bytes(b"original")
+ real = r.atomic
+ failed = False
+ def fail_once(path, data):
+ nonlocal failed
+ if path == self.registry and not failed:
+ failed = True
+ raise OSError("disk failure")
+ return real(path, data)
+ with patch.object(r, "atomic", side_effect=fail_once):
+ with self.assertRaises(OSError): self.configure("dxvk")
+ self.assertEqual(self.registry.read_text(), self.original)
+ self.assertEqual(before.read_bytes(), b"original")
+ self.assertFalse((self.game.parent / "d3d10core.dll").exists())
+ self.assertFalse(list((self.prefix / ".soju-renderers").glob("*.json")))
+ self.configure("dxvk") # failed first setup left no conflicting recovery directory
+
+ def test_reset_works_with_missing_runtime(self):
+ self.configure("dxvk")
+ (self.runtime / ".soju-runtime").unlink()
+ self.configure("reset")
+ self.assertFalse((self.game.parent / "d3d11.dll").exists())
+
+ def test_unprepared_bottle_is_not_modified(self):
+ (self.prefix / ".soju-steam-games").unlink()
+ with self.assertRaisesRegex(ValueError, "Prepare"): self.configure("dxvk")
+ self.assertEqual(self.registry.read_text(), self.original)
+ self.fetch.assert_not_called()
+
+ def test_duplicate_or_non_string_registry_override_rejected(self):
+ text = r.with_overrides(self.original, self.game.name, {"d3d11": "native"})
+ self.registry.write_text(text + '"d3d11"="builtin"\n')
+ with self.assertRaises(ValueError): self.configure("dxvk")
+ self.registry.write_text(text.replace('"native"\n', 'dword:00000001\n'))
+ with self.assertRaises(ValueError): self.configure("dxvk")
+
+
+class DownloadTests(unittest.TestCase):
+ def test_corrupt_download_does_not_install(self):
+ with tempfile.TemporaryDirectory() as temp:
+ def download(args, **kwargs):
+ Path(args[-1]).write_bytes(b"corrupt")
+ with patch.object(r.subprocess, "run", side_effect=download):
+ with self.assertRaisesRegex(ValueError, "checksum"):
+ r.fetch_dxvk(Path(temp))
+ self.assertFalse(any(Path(temp).rglob("d3d11.dll")))
+
+ def test_verified_cache_needs_no_network_and_tampering_does(self):
+ with tempfile.TemporaryDirectory() as temp:
+ base = Path(temp)
+ manifest = json.loads((ROOT / "resources/steam-dxvk.json").read_text())
+ target = base / "steam-support" / ("dxvk-" + manifest["version"])
+ target.mkdir(parents=True)
+ for name in r.FILES: (target / name).write_bytes(name.encode())
+ manifest["files"] = {name: r.signature(target / name) for name in r.FILES}
+ original = Path.read_text
+ def read(path, *args, **kwargs):
+ return json.dumps(manifest) if path.name == "steam-dxvk.json" else original(path, *args, **kwargs)
+ with patch.object(Path, "read_text", read), patch.object(r.subprocess, "run", side_effect=RuntimeError("network")) as run:
+ self.assertEqual(r.fetch_dxvk(base), target)
+ run.assert_not_called()
+ (target / "d3d11.dll").write_bytes(b"tampered")
+ with self.assertRaisesRegex(RuntimeError, "network"): r.fetch_dxvk(base)