Skip to content

Commit

Permalink
Mac msync (#3630)
Browse files Browse the repository at this point in the history
* On (no branch): add_msync_backend

* mac_msyncfe

* fix_lint

* Fix: PR Comments
  • Loading branch information
Mariaboni authored Mar 21, 2024
1 parent c674e04 commit e374731
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 5 deletions.
2 changes: 2 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@
},
"general": "Sync with EGL if you have a working installation of the Epic Games Launcher elsewhere and want to import your games to avoid downloading them again.",
"mangohud": "MangoHUD is an overlay that displays and monitors FPS, temperatures, CPU/GPU load and other system resources.",
"msync": "Msync aims to reduce wineserver overhead in CPU-intensive games. Enabling may improve performance on supported Linux kernels.",
"other": {
"part4": "Use the ",
"part5": "Game Arguments",
Expand Down Expand Up @@ -655,6 +656,7 @@
"maxRecentGames": "Played Recently to Show",
"maxworkers": "Maximum Number of Workers when downloading",
"minimize-on-launch": "Minimize Heroic After Game Launch",
"msync": "Enable Msync",
"offlinemode": "Run Game Offline",
"prefered_language": "Prefered Language (Language Code)",
"preferSystemLibs": "Prefer system libraries",
Expand Down
1 change: 1 addition & 0 deletions src/backend/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ class GlobalConfigV0 extends GlobalConfig {
wineVersion: defaultWine,
enableEsync: true,
enableFsync: isLinux,
enableMsync: isMac,
eacRuntime: isLinux,
battlEyeRuntime: isLinux,
framelessWindow: false
Expand Down
2 changes: 2 additions & 0 deletions src/backend/game_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class GameConfigV0 extends GameConfig {
autoSyncSaves,
enableEsync,
enableFSR,
enableMsync,
enableFsync,
maxSharpness,
launcherArgs,
Expand Down Expand Up @@ -242,6 +243,7 @@ class GameConfigV0 extends GameConfig {
preferSystemLibs,
autoSyncSaves,
enableEsync,
enableMsync,
enableFSR,
enableFsync,
maxSharpness,
Expand Down
21 changes: 16 additions & 5 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,17 @@ function setupWineEnvVars(gameSettings: GameSettings, gameId = '0') {
if (!gameSettings.enableEsync && wineVersion.type === 'proton') {
ret.PROTON_NO_ESYNC = '1'
}
if (gameSettings.enableFsync && wineVersion.type !== 'proton') {
if (gameSettings.enableMsync && isMac) {
ret.WINEMSYNC = '1'
// This is to solve a problem with d3dmetal
if (wineVersion.type === 'toolkit') {
ret.WINEESYNC = '1'
}
}
if (isLinux && gameSettings.enableFsync && wineVersion.type !== 'proton') {
ret.WINEFSYNC = '1'
}
if (!gameSettings.enableFsync && wineVersion.type === 'proton') {
if (isLinux && !gameSettings.enableFsync && wineVersion.type === 'proton') {
ret.PROTON_NO_FSYNC = '1'
}
if (wineVersion.type === 'proton') {
Expand All @@ -585,14 +592,18 @@ function setupWineEnvVars(gameSettings: GameSettings, gameId = '0') {
ret.PROTON_DISABLE_NVAPI = '1'
}
}
if (gameSettings.autoInstallDxvkNvapi && wineVersion.type === 'wine') {
if (
isLinux &&
gameSettings.autoInstallDxvkNvapi &&
wineVersion.type === 'wine'
) {
ret.DXVK_ENABLE_NVAPI = '1'
ret.DXVK_NVAPI_ALLOW_OTHER_DRIVERS = '1'
}
if (gameSettings.eacRuntime) {
if (isLinux && gameSettings.eacRuntime) {
ret.PROTON_EAC_RUNTIME = join(runtimePath, 'eac_runtime')
}
if (gameSettings.battlEyeRuntime) {
if (isLinux && gameSettings.battlEyeRuntime) {
ret.PROTON_BATTLEYE_RUNTIME = join(runtimePath, 'battleye_runtime')
}
if (wineVersion.type === 'proton') {
Expand Down
1 change: 1 addition & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export interface GameSettings {
enableDXVKFpsLimit: boolean
enableEsync: boolean
enableFSR: boolean
enableMsync: boolean
enableFsync: boolean
gamescope: GameScopeSettings
enviromentOptions: EnviromentVariable[]
Expand Down
42 changes: 42 additions & 0 deletions src/frontend/screens/Settings/components/EnableMsync.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import ContextProvider from 'frontend/state/ContextProvider'
import React, { useContext } from 'react'
import { useTranslation } from 'react-i18next'
import SettingsContext from '../SettingsContext'
import useSetting from 'frontend/hooks/useSetting'
import { ToggleSwitch } from 'frontend/components/UI'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCircleInfo } from '@fortawesome/free-solid-svg-icons'

const EnableMsync = () => {
const { t } = useTranslation()
const { platform } = useContext(ContextProvider)
const { isMacNative } = useContext(SettingsContext)
const isMac = platform === 'darwin'
const [enableMsync, setEnableMsync] = useSetting('enableMsync', false)

if (!isMac || isMacNative) {
return <></>
}

return (
<div className="toggleRow">
<ToggleSwitch
htmlId="msyncToggle"
value={enableMsync || false}
handleChange={() => setEnableMsync(!enableMsync)}
title={t('setting.msync', 'Enable Msync')}
/>

<FontAwesomeIcon
className="helpIcon"
icon={faCircleInfo}
title={t(
'help.msync',
'Msync aims to reduce wineserver overhead in CPU-intensive games. Enabling may improve performance on supported Linux kernels.'
)}
/>
</div>
)
}

export default EnableMsync
1 change: 1 addition & 0 deletions src/frontend/screens/Settings/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export { default as EacRuntime } from './EacRuntime'
export { default as EgsSettings } from './EgsSettings'
export { default as EnableEsync } from './EnableEsync'
export { default as EnableFSR } from './EnableFSR'
export { default as EnableMsync } from './EnableMsync'
export { default as EnableFsync } from './EnableFsync'
export { default as Gamescope } from './Gamescope'
export { default as EnvVariablesTable } from './EnvVariablesTable'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
EnableEsync,
EnableFSR,
EnableFsync,
EnableMsync,
EnvVariablesTable,
GameMode,
LauncherArgs,
Expand Down Expand Up @@ -201,6 +202,7 @@ export default function GamesSettings() {
)}
<EnableEsync />
<EnableFsync />
<EnableMsync />
<EnableFSR />
<EnableDXVKFpsLimit />
<Tools />
Expand Down

0 comments on commit e374731

Please sign in to comment.