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: about text and cached shim lookup for the settings view

itsOwen75b0042688a0
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index c46c812..3694782 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -9,6 +9,8 @@ enum SettingsTab: Hashable { case environments, engine, troubleshooting }
@Observable @MainActor
final class AppState {
var engines: [InstalledEngine] = []
+ /// frame generation shim directory per engine id, resolved once in refresh() so the settings view does not repair links on every redraw
+ var lsfgShimDirs: [String: URL] = [:]
var bottles: [Bottle] = []
/// Directories under bottles/ that aren't loadable bottles. Shown alongside the real
/// ones so a bottle whose settings file is gone still has somewhere to be acted on (#38).
@@ -541,6 +543,7 @@ final class AppState {
if n > 0 { appendLog("pruned \(n) old log file(s)") }
}
engines = (try? engineStore.installedEngines()) ?? []
+ lsfgShimDirs = Dictionary(engines.compactMap { e in e.resolveLsfgShimDir().map { (e.id, $0) } }, uniquingKeysWith: { a, _ in a })
bottles = (try? bottleStore.list()) ?? []
damagedBottles = (try? bottleStore.damaged()) ?? []
needsOnboarding = engines.isEmpty && homeUnavailable == nil // an unplugged drive is not a first run
diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swift
index 6db2548..306b0f7 100644
--- a/Sources/HighballApp/BottleView.swift
+++ b/Sources/HighballApp/BottleView.swift
@@ -335,7 +335,7 @@ struct BottleSettingsSheet: View {
}
}
// only engines that ship the shim get the control
- if let engine, engine.resolveLsfgShimDir() != nil {
+ if let engine, let shim = state.lsfgShimDirs[engine.id] {
Picker(L("Frame generation (Lossless Scaling, beta)"), selection: Binding(
get: { liveBottle.settings.frameGen },
set: { newValue in
@@ -381,7 +381,7 @@ struct BottleSettingsSheet: View {
infoIcon("Resolution used to estimate motion, as a percentage of the frame. Lower is cheaper and can help a GPU-bound game, at the cost of accuracy around small or fast-moving detail.")
}
}
- switch liveBottle.frameGenStatus(engine: engine) {
+ switch liveBottle.frameGenStatus(shim: shim) {
case .unavailable(let why):
Text(String(format: L("Frame generation stays off: %@"), L(why)))
.font(.caption).foregroundStyle(.secondary)
@@ -503,7 +503,7 @@ struct BottleSettingsSheet: View {
.alert(L("About frame generation"), isPresented: $showFrameGenInfo) {
Button(L("Got it"), role: .cancel) {}
} message: {
- Text(L("Lossless Scaling inserts interpolated frames between the game's real frames to make motion look smoother.\n\nBy default the generated frames are paced to your display, so it never presents more than your screen's refresh rate. It therefore helps most when a game runs BELOW your refresh rate, for example a demanding game locked at 30 fps smoothed up to 60. On the built-in 60 Hz display a game already running above 60 is capped to 60 and feels worse, not better. It pays off on an external high-refresh monitor (120 Hz or more), where a 60 fps game becomes 120.\n\nIt also adds a little input lag, because a real frame is held back to interpolate.\n\nIt works with every graphics mode: DXVK and vkd3d-proton through Vulkan, DXMT and D3DMetal through Metal, and WineD3D by switching it to its Vulkan renderer.\n\nAfter changing any of these settings, stop the environment and relaunch so a Steam game picks up the new one.\n\nThis is a beta feature: some games may show artifacts, stutter or not start with it on. Turn it off if a game misbehaves.\n\nClick the ⓘ beside each setting to see what that one does."))
+ Text(L("Lossless Scaling inserts interpolated frames between the game's real frames to make motion look smoother.\n\nBy default the generated frames are paced to your display, so it never presents more than your screen's refresh rate. It therefore helps most when a game runs BELOW your refresh rate, for example a demanding game locked at 30 fps smoothed up to 60. On the built-in 60 Hz display a game already running above 60 is capped to 60 and feels worse, not better. It pays off on an external high-refresh monitor (120 Hz or more), where a 60 fps game becomes 120.\n\nIt also adds a little input lag, because a real frame is held back to interpolate.\n\nIt works with every graphics mode: DXVK and vkd3d-proton through Vulkan, DXMT and D3DMetal through Metal, and WineD3D on its own renderer, OpenGL or Vulkan.\n\nAfter changing any of these settings, stop the environment and relaunch so a Steam game picks up the new one.\n\nThis is a beta feature: some games may show artifacts, stutter or not start with it on. Turn it off if a game misbehaves.\n\nClick the ⓘ beside each setting to see what that one does."))
}
}
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index 003c44e..43e7ff3 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -27,7 +27,7 @@ enum L10n {
"Performance mode": "Mode performance",
"Motion estimation resolution": "Résolution de l’estimation du mouvement",
"After changing this, stop the environment and relaunch so a Steam game picks it up.": "Après ce changement, arrêtez l’environnement et relancez pour qu’un jeu Steam en tienne compte.",
- "Lossless Scaling inserts interpolated frames between the game's real frames to make motion look smoother.\n\nBy default the generated frames are paced to your display, so it never presents more than your screen's refresh rate. It therefore helps most when a game runs BELOW your refresh rate, for example a demanding game locked at 30 fps smoothed up to 60. On the built-in 60 Hz display a game already running above 60 is capped to 60 and feels worse, not better. It pays off on an external high-refresh monitor (120 Hz or more), where a 60 fps game becomes 120.\n\nIt also adds a little input lag, because a real frame is held back to interpolate.\n\nIt works with every graphics mode: DXVK and vkd3d-proton through Vulkan, DXMT and D3DMetal through Metal, and WineD3D by switching it to its Vulkan renderer.\n\nAfter changing any of these settings, stop the environment and relaunch so a Steam game picks up the new one.\n\nThis is a beta feature: some games may show artifacts, stutter or not start with it on. Turn it off if a game misbehaves.\n\nClick the ⓘ beside each setting to see what that one does.": "Lossless Scaling insère des images interpolées entre les vraies images du jeu pour rendre le mouvement plus fluide.\n\nPar défaut, les images générées sont cadencées sur votre écran : elles ne dépassent jamais sa fréquence de rafraîchissement. La fonction aide donc surtout quand un jeu tourne EN DESSOUS de cette fréquence, par exemple un jeu exigeant bloqué à 30 fps lissé jusqu'à 60. Sur l'écran intégré 60 Hz, un jeu déjà au-dessus de 60 est plafonné à 60 et paraît moins bon, pas meilleur. Elle est utile sur un moniteur externe à haute fréquence (120 Hz ou plus), où un jeu à 60 fps passe à 120.\n\nElle ajoute aussi un peu de latence, car une vraie image est retenue pour l'interpolation.\n\nElle fonctionne avec tous les modes graphiques : DXVK et vkd3d-proton via Vulkan, DXMT et D3DMetal via Metal, et WineD3D en le basculant sur son moteur de rendu Vulkan.\n\nAprès avoir changé un de ces réglages, arrêtez l'environnement et relancez pour qu'un jeu Steam applique le nouveau.\n\nCette fonction est en bêta : certains jeux peuvent présenter des artefacts, des saccades ou ne pas démarrer avec elle. Désactivez-la si un jeu se comporte mal.\n\nCliquez sur le ⓘ à côté de chaque réglage pour savoir ce qu'il fait.",
+ "Lossless Scaling inserts interpolated frames between the game's real frames to make motion look smoother.\n\nBy default the generated frames are paced to your display, so it never presents more than your screen's refresh rate. It therefore helps most when a game runs BELOW your refresh rate, for example a demanding game locked at 30 fps smoothed up to 60. On the built-in 60 Hz display a game already running above 60 is capped to 60 and feels worse, not better. It pays off on an external high-refresh monitor (120 Hz or more), where a 60 fps game becomes 120.\n\nIt also adds a little input lag, because a real frame is held back to interpolate.\n\nIt works with every graphics mode: DXVK and vkd3d-proton through Vulkan, DXMT and D3DMetal through Metal, and WineD3D on its own renderer, OpenGL or Vulkan.\n\nAfter changing any of these settings, stop the environment and relaunch so a Steam game picks up the new one.\n\nThis is a beta feature: some games may show artifacts, stutter or not start with it on. Turn it off if a game misbehaves.\n\nClick the ⓘ beside each setting to see what that one does.": "Lossless Scaling insère des images interpolées entre les vraies images du jeu pour rendre le mouvement plus fluide.\n\nPar défaut, les images générées sont cadencées sur votre écran : elles ne dépassent jamais sa fréquence de rafraîchissement. La fonction aide donc surtout quand un jeu tourne EN DESSOUS de cette fréquence, par exemple un jeu exigeant bloqué à 30 fps lissé jusqu'à 60. Sur l'écran intégré 60 Hz, un jeu déjà au-dessus de 60 est plafonné à 60 et paraît moins bon, pas meilleur. Elle est utile sur un moniteur externe à haute fréquence (120 Hz ou plus), où un jeu à 60 fps passe à 120.\n\nElle ajoute aussi un peu de latence, car une vraie image est retenue pour l'interpolation.\n\nElle fonctionne avec tous les modes graphiques : DXVK et vkd3d-proton via Vulkan, DXMT et D3DMetal via Metal, et WineD3D sur son propre moteur de rendu, OpenGL ou Vulkan.\n\nAprès avoir changé un de ces réglages, arrêtez l'environnement et relancez pour qu'un jeu Steam applique le nouveau.\n\nCette fonction est en bêta : certains jeux peuvent présenter des artefacts, des saccades ou ne pas démarrer avec elle. Désactivez-la si un jeu se comporte mal.\n\nCliquez sur le ⓘ à côté de chaque réglage pour savoir ce qu'il fait.",
"Frame generation stays off: %@": "La génération d’images reste désactivée : %@",
"Frame generation requires a multiplier from 1 to 4.": "La génération d’images nécessite un multiplicateur de 1 à 4.",
"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.",
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swift
index 70a17c1..b622d2b 100644
--- a/Sources/HighballKit/Bottle.swift
+++ b/Sources/HighballKit/Bottle.swift
@@ -551,6 +551,12 @@ public struct Bottle: Sendable {
/// derive status from the final launch environment
public func frameGenStatus(engine: InstalledEngine,
environment: [String: String]? = nil) -> FrameGenStatus {
+ frameGenStatus(shim: engine.resolveLsfgShimDir(), environment: environment)
+ }
+
+ /// same, with the shim directory already resolved, so a view can pass a cached one
+ public func frameGenStatus(shim shimDir: URL?,
+ environment: [String: String]? = nil) -> FrameGenStatus {
guard settings.frameGen > 1 else { return .off }
let env = environment ?? settings.environment
if let reason = env["HB_LSFG_UNAVAILABLE"] { return .unavailable(reason) }
@@ -560,7 +566,7 @@ public struct Bottle: Sendable {
return .unavailable("Frame generation requires a multiplier from 1 to 4.")
}
if multiplier == 1 || env["DISABLE_LSFGM"] != nil { return .off }
- guard let shim = engine.resolveLsfgShimDir() else {
+ guard let shim = shimDir else {
return .unavailable("This engine has no usable frame generation component. Build or install the component for this engine.")
}
if let path = env["LSFGM_MOLTENVK"], !path.isEmpty {
@@ -641,9 +647,10 @@ public struct Bottle: Sendable {
merge(&env, extra)
// apply frame generation after all overrides
env.removeValue(forKey: "HB_LSFG_UNAVAILABLE")
- let frameGeneration = frameGenStatus(engine: engine, environment: env)
+ let shimDir = engine.resolveLsfgShimDir()
+ let frameGeneration = frameGenStatus(shim: shimDir, environment: env)
if case .active(let multiplier) = frameGeneration,
- let shim = engine.resolveLsfgShimDir(), let dll = losslessScalingDLL(environment: env) {
+ let shim = shimDir, let dll = losslessScalingDLL(environment: env) {
let existing = (env["DYLD_LIBRARY_PATH"] ?? "").split(separator: ":").map(String.init)
env["DYLD_LIBRARY_PATH"] = ([shim.path] + existing.filter { $0 != shim.path }).joined(separator: ":")
// every renderer gets the same dylib inserted: metal renderers to hook CAMetalLayer, the rest for OpenGL games
diff --git a/Sources/HighballKit/EngineStore.swift b/Sources/HighballKit/EngineStore.swift
index 200394b..fb3786f 100644
--- a/Sources/HighballKit/EngineStore.swift
+++ b/Sources/HighballKit/EngineStore.swift
@@ -455,10 +455,7 @@ public struct InstalledEngine: Sendable {
}
public var isComplete: Bool { missingFiles.isEmpty }
- /// return the usable frame generation shim directory
- /// Resolve the frame-generation shim directory, repairing the real-driver symlink if a
- /// component update replaced it. This touches the filesystem, so it is a func rather
- /// than a property: do not call it from a SwiftUI body on every evaluation.
+ /// resolves the shim directory and repairs the real-driver link; it touches the disk, so the app caches it per engine
public func resolveLsfgShimDir() -> URL? {
let dir = renderersDir.appending(path: "lsfg", directoryHint: .isDirectory)
let shim = dir.appending(path: "libMoltenVK.dylib")
diff --git a/Tests/HighballKitTests/FrameGenerationTests.swift b/Tests/HighballKitTests/FrameGenerationTests.swift
index c0944dd..19304da 100644
--- a/Tests/HighballKitTests/FrameGenerationTests.swift
+++ b/Tests/HighballKitTests/FrameGenerationTests.swift
@@ -58,6 +58,8 @@ private func frameGenerationChecks() throws {
try check(env["LSFGM_MULTIPLIER"] == "3", "Launch multiplier override was ignored")
try check(env["DYLD_LIBRARY_PATH"] == shim.path + ":/custom/lib", "Shim priority or custom search path lost")
try check(bottle.frameGenStatus(engine: engine, environment: env) == .active(multiplier: 3), "Status disagrees with environment")
+ try check(bottle.frameGenStatus(shim: shim, environment: env) == .active(multiplier: 3), "Cached shim status disagrees")
+ try check(bottle.frameGenStatus(shim: nil, environment: env) == .unavailable("This engine has no usable frame generation component. Build or install the component for this engine."), "Missing cached shim was reported active")
try check(WineRunner.launchHeader(engine: engine, bottle: bottle, renderer: .dxvk, env: env, args: []).contains("frameGen=3x(requested)"), "Header uses bottle value instead of launch multiplier")
bottle.settings.environment["LSFGM_DLL_PATH"] = "Z:" + dll.path.replacingOccurrences(of: "/", with: "\\")
try check(bottle.losslessScalingDLL == dll, "Windows override was not translated")