Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UX] Warn when Shader Pre-Cache is disabled and using umu in SD's gaming mode #4328

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions src/backend/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ import { backendEvents } from 'backend/backend_events'
import { GlobalConfig } from 'backend/config'
import { getGOGdlBin, getLegendaryBin } from 'backend/utils'
import { dirname, join } from 'path'
import { formatSystemInfo, getSystemInfo } from '../utils/systeminfo'
import {
formatSystemInfo,
getSystemInfo,
SystemInformation
} from '../utils/systeminfo'
import { appendFile, writeFile } from 'fs/promises'
import { gamesConfigPath, isWindows } from 'backend/constants'
import { gameManagerMap } from 'backend/storeManagers'
import { existsSync, mkdirSync, openSync } from 'graceful-fs'
import { Winetricks } from 'backend/tools'
import { isUmuSupported } from 'backend/utils/compatibility_layers'

export enum LogPrefix {
General = '',
Expand Down Expand Up @@ -460,6 +465,31 @@ class LogWriter {
}
}

/*
* If we are running on a SteamDeck's gaming mode and the game is configured to use umu,
* we can check the availability of the env variables added by Steam's Shared Pre-cache
* that are required by umu to work properly
*
* More details: https://github.com/Open-Wine-Components/umu-launcher/wiki/Frequently-asked-questions-(FAQ)#why-am-i-not-able-to-see-my-game-when-using-my-launcher-from-steam-mode-gaming-mode
*/
const shouldToggleShaderPreCacheOn = async (
info: SystemInformation | null,
gameSettings: GameSettings
) => {
if (!info) return false
if (!info.steamDeckInfo.isDeck) return false
if (info.steamDeckInfo.mode !== 'game') return false
if (!(await isUmuSupported(gameSettings))) return false

// check if all of the following env variables are undefined
return [
'STEAM_COMPAT_TRANSCODED_MEDIA_PATH',
'STEAM_COMPAT_MEDIA_PATH',
'STEAM_FOSSILIZE_DUMP_PATH',
'DXVK_STATE_CACHE_PATH'
].every((envVar) => !process.env[envVar])
}

class GameLogWriter extends LogWriter {
gameInfo: GameInfo

Expand Down Expand Up @@ -493,9 +523,10 @@ class GameLogWriter extends LogWriter {
`Installed in: ${installPath}\n\n`
)

let info: SystemInformation | null = null
try {
// log system information
const info = await getSystemInfo()
info = await getSystemInfo()
const systemInfo = await formatSystemInfo(info)

await appendFile(this.filePath, `System Info:\n${systemInfo}\n\n`)
Expand All @@ -516,6 +547,13 @@ class GameLogWriter extends LogWriter {
`Game Settings: ${gameSettingsString}\n\n`
)

if (await shouldToggleShaderPreCacheOn(info, gameSettings)) {
await appendFile(
this.filePath,
`Warning: Steam's Shader Pre-Caching is disabled and umu is enabled. Steam's Shader Pre-cache is required by umu to work properly on the SteamDeck's Gaming mode.\n\n`
)
}

await appendFile(
this.filePath,
`Game launched at: ${startPlayingDate}\n\n`
Expand Down
Loading