Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

frame generation: find the shader dll in any environment, not only this one

itsOwen2b753970db6c
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index 6b186fd..6787db3 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -33,7 +33,7 @@ enum L10n {
"This engine has no usable frame generation component. Build or install the component for this engine.": "Ce moteur ne dispose pas d’un composant de génération d’images utilisable. Compilez ou installez le composant pour ce moteur.",
"The real MoltenVK override is unusable. Use a readable driver with a different filename from libMoltenVK.dylib.": "Le chemin personnalisé du véritable pilote MoltenVK est inutilisable. Utilisez un pilote lisible dont le nom diffère de libMoltenVK.dylib.",
"The shader DLL override is not a readable file. Correct LSFGM_DLL_PATH or remove the override.": "Le chemin personnalisé de la DLL de shaders ne désigne pas un fichier lisible. Corrigez LSFGM_DLL_PATH ou supprimez cette valeur.",
- "Install Lossless Scaling from Steam in this environment and select its lsfg-vk beta branch (Properties → Betas).": "Installez Lossless Scaling depuis Steam dans cet environnement et sélectionnez sa branche bêta lsfg-vk (Propriétés → Bêtas).",
+ "Install Lossless Scaling from Steam in any environment and select its lsfg-vk beta branch (Properties → Betas), or point LSFGM_DLL_PATH at its lsfg-vk.dll.": "Installez Lossless Scaling depuis Steam dans n'importe quel environnement et sélectionnez sa branche bêta lsfg-vk (Propriétés → Bêtas), ou faites pointer LSFGM_DLL_PATH vers son lsfg-vk.dll.",
// Sidebar & shell
"Update engine": "Mettre à jour le moteur",
"Installs the newer engine this version of Highball ships. Bottles on the same Wine build move to it; the others stay on their engine until you switch them in the bottle's settings. Only changed components are downloaded.": "Installe le moteur plus récent livré avec cette version de Highball. Les bouteilles sur la même version de Wine y passent ; les autres gardent leur moteur jusqu'à ce que vous le changiez dans les réglages de la bouteille. Seuls les composants modifiés sont téléchargés.",
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swift
index 9c7266f..742a2f0 100644
--- a/Sources/HighballKit/Bottle.swift
+++ b/Sources/HighballKit/Bottle.swift
@@ -528,21 +528,48 @@ public struct Bottle: Sendable {
let dll = frameGenPath(override)
return frameGenFile(dll) ? dll : nil
}
- guard let root = SteamLibrary.steamRoot(of: self) else { return nil }
- var libraries = [root]
- // check secondary steam libraries
- if let text = try? String(contentsOf: root.appending(path: "steamapps/libraryfolders.vdf"), encoding: .utf8) {
- let pattern = #/"path"\s+"((?:\\.|[^"\\])*)"/#
- for match in text.matches(of: pattern) {
- let path = String(match.1).replacingOccurrences(of: #"\\"#, with: #"\"#)
- .replacingOccurrences(of: #"\""#, with: "\"")
- libraries.append(frameGenPath(path))
+ if let root = SteamLibrary.steamRoot(of: self) {
+ var libraries = [root]
+ // check secondary steam libraries
+ if let text = try? String(contentsOf: root.appending(path: "steamapps/libraryfolders.vdf"), encoding: .utf8) {
+ let pattern = #/"path"\s+"((?:\\.|[^"\\])*)"/#
+ for match in text.matches(of: pattern) {
+ let path = String(match.1).replacingOccurrences(of: #"\\"#, with: #"\"#)
+ .replacingOccurrences(of: #"\""#, with: "\"")
+ libraries.append(frameGenPath(path))
+ }
+ }
+ for library in libraries {
+ let dll = Self.losslessScalingDLL(inLibrary: library)
+ if frameGenFile(dll) { return dll }
}
}
- for library in libraries {
- let manifest = library.appending(path: "steamapps/appmanifest_\(Self.losslessScalingAppID).acf")
- let dir = SteamLibrary.parseManifest(manifest)?.installdir ?? "Lossless Scaling"
- let dll = library.appending(path: "steamapps/common/\(dir)/lsfg-vk.dll")
+ // The DLL is bought on Steam, but it is read as a plain file: a copy installed in another
+ // bottle works just as well. Without this an Epic-only or GOG-only bottle cannot use frame
+ // generation even though the user owns Lossless Scaling one bottle over.
+ return siblingLosslessScalingDLL()
+ }
+
+ /// Path where the shader DLL would sit inside one Steam library directory, whatever the
+ /// install folder is named. Says nothing about whether the file is there.
+ private static func losslessScalingDLL(inLibrary library: URL) -> URL {
+ let manifest = library.appending(path: "steamapps/appmanifest_\(Self.losslessScalingAppID).acf")
+ let dir = SteamLibrary.parseManifest(manifest)?.installdir ?? "Lossless Scaling"
+ return library.appending(path: "steamapps/common/\(dir)/lsfg-vk.dll")
+ }
+
+ /// Default Steam library of every other bottle beside this one. Secondary libraries are not
+ /// followed there: their paths are Windows paths that only that bottle's drives can resolve.
+ /// Sorted by name so two bottles holding the DLL always resolve to the same one, whatever
+ /// order the filesystem reports.
+ private func siblingLosslessScalingDLL() -> URL? {
+ let parent = url.deletingLastPathComponent()
+ let others = (try? FileManager.default.contentsOfDirectory(
+ at: parent, includingPropertiesForKeys: nil, options: [.skipsHiddenFiles])) ?? []
+ for other in others.sorted(by: { $0.lastPathComponent < $1.lastPathComponent })
+ where other.standardizedFileURL != url.standardizedFileURL {
+ guard let root = SteamLibrary.steamRoot(driveC: other.appending(path: "drive_c")) else { continue }
+ let dll = Self.losslessScalingDLL(inLibrary: root)
if frameGenFile(dll) { return dll }
}
return nil
@@ -587,7 +614,7 @@ public struct Bottle: Sendable {
if let override = env["LSFGM_DLL_PATH"], !override.isEmpty {
return .unavailable("The shader DLL override is not a readable file. Correct LSFGM_DLL_PATH or remove the override.")
}
- return .unavailable("Install Lossless Scaling from Steam in this environment and select its lsfg-vk beta branch (Properties → Betas).")
+ return .unavailable("Install Lossless Scaling from Steam in any environment and select its lsfg-vk beta branch (Properties → Betas), or point LSFGM_DLL_PATH at its lsfg-vk.dll.")
}
return .active(multiplier: multiplier)
}
diff --git a/Sources/HighballKit/SteamLibrary.swift b/Sources/HighballKit/SteamLibrary.swift
index 3b56d1d..cca8c17 100644
--- a/Sources/HighballKit/SteamLibrary.swift
+++ b/Sources/HighballKit/SteamLibrary.swift
@@ -24,7 +24,12 @@ public struct SteamGame: Identifiable, Sendable, Hashable {
public enum SteamLibrary {
/// Path of the Windows Steam install inside a bottle, if present.
public static func steamRoot(of bottle: Bottle) -> URL? {
- let root = bottle.driveC.appending(path: "Program Files (x86)/Steam")
+ steamRoot(driveC: bottle.driveC)
+ }
+
+ /// Path of the Windows Steam install under a `drive_c` we only have the path of.
+ static func steamRoot(driveC: URL) -> URL? {
+ let root = driveC.appending(path: "Program Files (x86)/Steam")
return FileManager.default.fileExists(atPath: root.appending(path: "steam.exe").path) ? root : nil
}
diff --git a/Tests/HighballKitTests/FrameGenerationTests.swift b/Tests/HighballKitTests/FrameGenerationTests.swift
index 19304da..5d697df 100644
--- a/Tests/HighballKitTests/FrameGenerationTests.swift
+++ b/Tests/HighballKitTests/FrameGenerationTests.swift
@@ -42,6 +42,16 @@ private func frameGenerationChecks() throws {
let userFile = try String(contentsOf: real, encoding: .utf8)
try check(userFile == "keep this user file", "Driver repair deleted a regular user file")
+ // A bottle with no Steam of its own uses a copy installed in another bottle beside it.
+ let neighbourSteam = root.appending(path: "neighbour/drive_c/Program Files (x86)/Steam")
+ try file(neighbourSteam.appending(path: "steam.exe"))
+ let neighbourDLL = neighbourSteam.appending(path: "steamapps/common/Lossless Scaling/lsfg-vk.dll")
+ try check(bottle.losslessScalingDLL == nil, "A neighbour without the DLL was reported as having it")
+ try file(neighbourDLL)
+ // Enumerating the bottles directory resolves symlinks, which the temporary directory has.
+ try check(bottle.losslessScalingDLL?.resolvingSymlinksInPath() == neighbourDLL.resolvingSymlinksInPath(),
+ "A neighbouring environment's copy was not found")
+
let steam = bottle.driveC.appending(path: "Program Files (x86)/Steam")
try file(steam.appending(path: "steam.exe"))
let external = root.appending(path: "External Steam Library")