From ada91bf04281f0d57c5e92209b5276ccb960dd1e Mon Sep 17 00:00:00 2001 From: The412Banner <205237651+The412Banner@users.noreply.github.com> Date: Sat, 5 Dec 2026 03:07:58 +0000 Subject: [PATCH] fix(game-env): full FEX x87 precision for PlayStation PC SDK games --- docs/development/game-environment.md | 8 +++++ .../overlay/usr/local/bin/droiddeck-game-env | 16 ++++++++++ tools/tests/test_game_environment.py | 32 +++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/docs/development/game-environment.md b/docs/development/game-environment.md index 6036cc3a7a..a712867cb7 100644 --- a/docs/development/game-environment.md +++ b/docs/development/game-environment.md @@ -193,6 +193,14 @@ A Unity game under FEX (`UnityPlayer.dll` for Windows builds under Proton, turns it off: without TSO such games can deadlock or crash (seen with Megabonk and Crab Game). A FEX preset chosen for the game itself still applies. +A game that ships the PlayStation PC SDK runtime installer +(`install_pspc_sdk_runtime.bat`, `PsPcSdkRuntimeInstaller.msi` or +`PsPcSdkRuntimeManager.msi`, next to the executable, one folder below, or in an +Unreal launcher's `/Binaries/Win64`) gets FEX's full x87 precision. +The SDK's obfuscated x87 code depends on full precision; with reduced precision +the game crashes or hangs at startup (FEX-Emu/FEX#4556, FEX-Emu/FEX#5988). A +FEX preset or value chosen for the game itself still applies. + An Inno Setup installer added as a game runs with the Stability preset's FEX settings (full TSO, full x87 precision, no multiblock). Under the default Performance + TSO preset the 32-bit setup stub corrupts its own paths and stops diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 04992da01b..bc4c7c73c8 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -91,6 +91,7 @@ XBOX_BACK_COMPAT_ENV = dict( VKD3D_INTEROP_PRESENT="1", VKD3D_PACKED_422="1", ) +PSPC_SDK_FILES = {"install_pspc_sdk_runtime.bat", "pspcsdkruntimeinstaller.msi", "pspcsdkruntimemanager.msi"} # Setup loader offset-table IDs, as innoextract's known_setup_loader_versions lists them. Loaders # from 5.1.5 keep the table in a resource; older ones also put "Inno" at file offset 0x30. INNO_LOADER_IDS = (b"rDlPtS", b"nS5W7dT\x83\xaa\x1b\x0fj") @@ -173,6 +174,15 @@ def game_files(exe): return names +def unreal_binary_files(exe): + project = os.path.splitext(os.path.basename(exe))[0] + try: + with os.scandir(os.path.join(os.path.dirname(exe), project, "Binaries", "Win64")) as folder: + return {entry.name.lower() for entry in folder} + except OSError: + return set() + + def xbox_identity(exe): """The identity name in the MicrosoftGame.config of the Xbox package the executable is in, or "".""" folder = os.path.dirname(exe) @@ -305,6 +315,12 @@ def arkham_city_x87(game): return {"FEX_X87REDUCEDPRECISION": "0"}, [], "Batman: Arkham City: FEX with full x87 precision" +@fix +def playstation_pc_sdk_x87(game): + if PSPC_SDK_FILES & (game.files | unreal_binary_files(game.exe)): + return {"FEX_X87REDUCEDPRECISION": "0"}, [], "PlayStation PC SDK: FEX with full x87 precision" + + @fix def split_second_x87_fip(game): if game.app_id == "297860" or game.stem == "splitsecond": diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 55cf9d29da..2895b9a042 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -1793,6 +1793,38 @@ class GameEnvironmentTest(unittest.TestCase): (asylum / name).touch() self.assertEqual(MODULE["engine_fixes"](str(asylum / "BmLauncher.exe"), []), ({}, [], [])) + def test_playstation_pc_sdk_games_get_full_x87_precision_over_the_preset(self): + with tempfile.TemporaryDirectory() as tmp: + unreal = Path(tmp) / "StellarBlade" + binaries = unreal / "SB/Binaries/Win64" + binaries.mkdir(parents=True) + for name in ("SB-Win64-Shipping.exe", "PsPcSdkRuntimeInstaller.msi"): + (binaries / name).touch() + (unreal / "SB.exe").touch() + for exe in (unreal / "SB.exe", binaries / "SB-Win64-Shipping.exe"): + env, extra, notes = MODULE["engine_fixes"](str(exe), []) + self.assertEqual((env, extra), ({"FEX_X87REDUCEDPRECISION": "0"}, [])) + self.assertIn("PlayStation PC SDK: FEX with full x87 precision", notes) + config = {"version": 1, "shared": {"FEX_X87REDUCEDPRECISION": "1"}} + self.assertEqual(MODULE["apply_config"]({}, config, "3489700", env)["FEX_X87REDUCEDPRECISION"], "0") + config["games"] = {"3489700": {"FEX_X87REDUCEDPRECISION": "1"}} + self.assertEqual(MODULE["apply_config"]({}, config, "3489700", env)["FEX_X87REDUCEDPRECISION"], "1") + + port = Path(tmp) / "Port" + port.mkdir() + for name in ("Game.exe", "install_pspc_sdk_runtime.bat"): + (port / name).touch() + self.assertEqual(MODULE["engine_fixes"](str(port / "Game.exe"), [])[0], {"FEX_X87REDUCEDPRECISION": "0"}) + + other = Path(tmp) / "OtherUnreal" + other_binaries = other / "Other/Binaries/Win64" + other_binaries.mkdir(parents=True) + (other_binaries / "Other-Win64-Shipping.exe").touch() + (other / "Other.exe").touch() + (other / "Other/Binaries/Win64/PsPcSdkRuntimeInstaller.txt").touch() + for exe in (other / "Other.exe", other_binaries / "Other-Win64-Shipping.exe"): + self.assertEqual(MODULE["engine_fixes"](str(exe), []), ({}, [], [])) + def test_store_launcher_resolves_the_game_executable_from_the_sidecar(self): with tempfile.TemporaryDirectory() as tmp: root = Path(tmp) / "BatmanArkhamCity"