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: vsync control, per-setting help, and audit fixes

itsOwenbf39e328b74b
diff --git a/Scripts/build-lsfg.sh b/Scripts/build-lsfg.sh
index 8fd7fa5..eedfb7f 100755
--- a/Scripts/build-lsfg.sh
+++ b/Scripts/build-lsfg.sh
@@ -1,6 +1,12 @@
#!/bin/zsh
# builds the lsfg-metal component (rust, MIT) and packages it as renderers/lsfg for a local engine manifest
# usage: Scripts/build-lsfg.sh [tag] [path-to-lsfg-metal]
+# LSFGM_RELEASE_URL=<url> emits a manifest entry pointing at a published archive instead of
+# the local file:// path, for pinning a release the way dxmt and moltenvk are pinned.
+# The entry carries the SHA-256 of the archive built here, so the published file must be
+# this exact archive: upload it as-is. The tar is reproducible (mtime 0, uid/gid 0, PAX),
+# so rebuilding from the same source gives the same hash, but anything that recompresses
+# the upload silently produces a manifest that fails the checksum on every user's machine.
set -euo pipefail
cd "$(dirname "$0")/.."
TAG="${1:-macos-local}"
@@ -9,7 +15,7 @@ SRC="${2:-../lsfg-metal}"
export PATH="$HOME/.cargo/bin:$PATH"
# the version is compiled into the dylib (build.rs reads LSFGM_VERSION), so it must be known before the build
# and cannot contain the dylib's own hash; the SHA-256 travels as its own line in source.txt
-PORT_VERSION="lsfg-metal-$(git -C "$SRC" rev-parse --short=7 HEAD 2>/dev/null || echo nogit)"
+PORT_VERSION="${LSFGM_VERSION:-lsfg-metal-$(git -C "$SRC" rev-parse --short=7 HEAD 2>/dev/null || echo nogit)}"
export LSFGM_VERSION="$PORT_VERSION"
(cd "$SRC" && cargo build --release && cargo test --release)
DYLIB="$SRC/target/x86_64-apple-darwin/release/liblsfg_metal.dylib"
@@ -32,9 +38,10 @@ cp "$SRC/LICENSE" "$PKG/renderers/lsfg/LICENSE"
printf '%s\n' "Source: https://github.com/itsOwen/lsfg-metal" "License: MIT (see LICENSE)" \
"Dylib SHA-256: $SHA" "Version: $PORT_VERSION" \
> "$PKG/renderers/lsfg/source.txt"
-python3 - "$PKG" "dist/lsfg-$TAG.tar.xz" <<'PY'
+python3 - "$PKG" "dist/lsfg-$TAG.tar.xz" "${LSFGM_RELEASE_URL:-}" <<'PY'
import pathlib,sys,tarfile,json,hashlib
root=pathlib.Path(sys.argv[1]);archive=pathlib.Path(sys.argv[2])
+release=sys.argv[3] if len(sys.argv)>3 else ''
with tarfile.open(archive,'w:xz',format=tarfile.PAX_FORMAT) as tar:
for path in sorted(root.rglob('*')):
info=tar.gettarinfo(str(path),str(path.relative_to(root)))
@@ -44,14 +51,16 @@ with tarfile.open(archive,'w:xz',format=tarfile.PAX_FORMAT) as tar:
else:tar.addfile(info)
sha=hashlib.sha256(archive.read_bytes()).hexdigest()
manifest=json.load(open('spike/engine-manifest.json'))
-manifest['id']='x64-sikarugir10.0_6-r3-lsfg-local'
-manifest['displayName']+=' + local lsfg-metal'
-manifest['components']['lsfg']={'kind':'renderer','order':1,'version':archive.stem,
- 'url':archive.resolve().as_uri(),'sha256':sha,'size':archive.stat().st_size,
+manifest['id']='x64-sikarugir10.0_6-r3-lsfg' + ('' if release else '-local')
+manifest['displayName']+=' + lsfg-metal' if release else ' + local lsfg-metal'
+manifest['components']['lsfg']={'kind':'renderer','order':1,'version':archive.stem.removesuffix('.tar'),
+ 'url':release or archive.resolve().as_uri(),'sha256':sha,'size':archive.stat().st_size,
'license':'MIT',
'extract':{'subpath':'renderers/lsfg','into':'renderers/lsfg'}}
-manifest.setdefault('notes',[]).append('LOCAL ONLY: uses an absolute file URL on the build machine. Do not promote this manifest to the bundled public manifest.')
-output=archive.parent/'lsfg-local-engine.json';output.write_text(json.dumps(manifest,indent=2)+'\n')
+if not release:
+ manifest.setdefault('notes',[]).append('LOCAL ONLY: uses an absolute file URL on the build machine. Do not promote this manifest to the bundled public manifest.')
+name='lsfg-engine.json' if release else 'lsfg-local-engine.json'
+output=archive.parent/name;output.write_text(json.dumps(manifest,indent=2)+'\n')
print(f'{archive}: sha256 {sha}, size {archive.stat().st_size}')
-print(f'Local manifest: {output}')
+print(f'{"Release" if release else "Local"} manifest: {output}')
PY
diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swift
index 07d6285..6db2548 100644
--- a/Sources/HighballApp/BottleView.swift
+++ b/Sources/HighballApp/BottleView.swift
@@ -265,6 +265,12 @@ struct BottleSettingsSheet: View {
let bottle: Bottle
@State private var confirmDelete = false
@State private var showFrameGenInfo = false
+
+ /// small ⓘ next to a frame-generation control; the detail lives in the popover,
+ /// so "How frame generation works" stays about frame generation in general
+ private func infoIcon(_ text: String) -> some View {
+ InfoButton(text: L(text))
+ }
/// Live slider value while dragging; nil means "read the saved dpiScale". Applied on release
/// only, so dragging doesn't fire a wine registry write on every step.
@State private var dpiDraft: Double? = nil
@@ -329,7 +335,7 @@ struct BottleSettingsSheet: View {
}
}
// only engines that ship the shim get the control
- if let engine, engine.lsfgShimDir != nil {
+ if let engine, engine.resolveLsfgShimDir() != nil {
Picker(L("Frame generation (Lossless Scaling, beta)"), selection: Binding(
get: { liveBottle.settings.frameGen },
set: { newValue in
@@ -344,23 +350,46 @@ struct BottleSettingsSheet: View {
Text("3×").tag(3)
Text("4×").tag(4)
}
- Button(L("How frame generation works")) { showFrameGenInfo = true }
- .buttonStyle(.link).controlSize(.small)
+ HStack(spacing: 6) {
+ Button(L("How frame generation works")) { showFrameGenInfo = true }
+ .buttonStyle(.link).controlSize(.small)
+ infoIcon("How many frames are shown for each frame the game renders. 2× puts one generated frame between every pair of real frames, 4× puts three. Higher multipliers need more GPU headroom and only pay off on a display fast enough to show them.")
+ }
if liveBottle.settings.frameGen > 1 {
- Toggle(L("Adaptive pacing (fill the display rate, up to the multiplier)"), isOn: binding(\.frameGenAdaptive))
- Toggle(L("Performance mode (cheaper generation, lower quality)"), isOn: binding(\.frameGenPerformance))
- Picker(L("Motion estimation resolution"), selection: binding(\.frameGenFlowScale)) {
- Text("100%").tag(100)
- Text("75%").tag(75)
- Text("50%").tag(50)
+ HStack(spacing: 6) {
+ Toggle(L("Adaptive pacing"), isOn: binding(\.frameGenAdaptive))
+ infoIcon("Measures the game's own frame rate and inserts only as many frames as it takes to fill the display, up to the multiplier: a 45 fps game gets one extra frame every other frame, and a game already at the refresh rate is left alone.")
+ }
+ HStack(spacing: 6) {
+ Toggle(L("Performance mode"), isOn: binding(\.frameGenPerformance))
+ infoIcon("Uses Lossless Scaling's cheaper shader set: noticeably less GPU time per generated frame, with slightly softer interpolation around fast motion.")
+ }
+ HStack(spacing: 6) {
+ Toggle(L("Force vsync"), isOn: binding(\.frameGenForceVsync))
+ if liveBottle.settings.frameGenForceVsync {
+ infoIcon("Paces generated frames to the display. Turn it off to let the game present at its own rate instead.")
+ } else {
+ InfoButton(text: L("The game presents at its own rate. Frames beyond the display's refresh rate are discarded and the image can tear, so this only helps above 60 Hz."), warning: true)
+ }
+ }
+ HStack(spacing: 6) {
+ Picker(L("Motion estimation resolution"), selection: binding(\.frameGenFlowScale)) {
+ Text("100%").tag(100)
+ Text("75%").tag(75)
+ Text("50%").tag(50)
+ }
+ 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.")
}
}
- if case .unavailable(let why) = liveBottle.frameGenStatus(renderer: currentRenderer, engine: engine) {
+ switch liveBottle.frameGenStatus(engine: engine) {
+ case .unavailable(let why):
Text(String(format: L("Frame generation stays off: %@"), L(why)))
.font(.caption).foregroundStyle(.secondary)
- } else if case .active = liveBottle.frameGenStatus(renderer: currentRenderer, engine: engine) {
+ case .active:
Text(L("After changing this, stop the environment and relaunch so a Steam game picks it up."))
.font(.caption).foregroundStyle(.secondary)
+ case .off:
+ EmptyView()
}
}
Toggle(L("Metal performance HUD"), isOn: binding(\.metalHUD))
@@ -474,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. The generated frames are paced to your display, so it can never present more frames than your screen's refresh rate.\n\nThat means it only helps 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 gets capped to 60 and feels worse, not better.\n\nIt pays off on an external high-refresh monitor (120 Hz or more), where a 60 fps game becomes 120. It also adds a little input lag, because a real frame is held back to interpolate.\n\nAdaptive pacing measures the game's own frame rate and inserts only as many frames as it takes to fill the display, up to the multiplier: a 45 fps game gets one extra frame every other frame, and a game already at the refresh rate is left alone. It works on every graphics mode.\n\nFrame generation 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. After changing it, stop the environment and relaunch so a Steam game picks up the new setting.\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."))
+ 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."))
}
}
@@ -697,3 +726,29 @@ struct EnvEditor: View {
}
}
}
+
+/// A small ⓘ (or ⚠) that explains one setting. Click opens a popover; hovering still shows
+/// the same text as a tooltip, so it works either way.
+private struct InfoButton: View {
+ let text: String
+ var warning = false
+ @State private var showing = false
+
+ var body: some View {
+ Button { showing.toggle() } label: {
+ Image(systemName: warning ? "exclamationmark.triangle.fill" : "info.circle")
+ .foregroundStyle(warning ? Color.orange : Color.secondary)
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ .help(text)
+ .accessibilityLabel(warning ? L("Warning") : L("What this setting does"))
+ .popover(isPresented: $showing, arrowEdge: .bottom) {
+ Text(text)
+ .font(.callout)
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(width: 320, alignment: .leading)
+ .padding(14)
+ }
+ }
+}
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index a23b88f..003c44e 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -11,20 +11,29 @@ enum L10n {
static let fr: [String: String] = [
"Frame generation (Lossless Scaling, beta)": "Génération d’images (Lossless Scaling, bêta)",
"How frame generation works": "Comment fonctionne la génération d’images",
+ "Off": "Désactivé",
+ "Force vsync": "Forcer la VSync",
+ "Warning": "Avertissement",
+ "What this setting does": "Ce que fait ce réglage",
+ "How many frames are shown for each frame the game renders. 2× puts one generated frame between every pair of real frames, 4× puts three. Higher multipliers need more GPU headroom and only pay off on a display fast enough to show them.": "Nombre d'images affichées pour chaque image calculée par le jeu. 2× insère une image générée entre deux vraies images, 4× en insère trois. Les multiplicateurs élevés demandent plus de marge GPU et ne servent que sur un écran assez rapide pour les afficher.",
+ "Measures the game's own frame rate and inserts only as many frames as it takes to fill the display, up to the multiplier: a 45 fps game gets one extra frame every other frame, and a game already at the refresh rate is left alone.": "Mesure la fréquence propre du jeu et n'insère que les images nécessaires pour remplir l'écran, jusqu'au multiplicateur : un jeu à 45 fps reçoit une image supplémentaire une fois sur deux, et un jeu déjà à la fréquence de l'écran est laissé tel quel.",
+ "Uses Lossless Scaling's cheaper shader set: noticeably less GPU time per generated frame, with slightly softer interpolation around fast motion.": "Utilise le jeu de shaders économique de Lossless Scaling : nettement moins de temps GPU par image générée, avec une interpolation un peu plus douce dans les mouvements rapides.",
+ "Paces generated frames to the display. Turn it off to let the game present at its own rate instead.": "Cadence les images générées sur l'écran. Désactivez pour laisser le jeu afficher à son propre rythme.",
+ "The game presents at its own rate. Frames beyond the display's refresh rate are discarded and the image can tear, so this only helps above 60 Hz.": "Le jeu affiche à son propre rythme. Les images au-delà de la fréquence de l'écran sont abandonnées et l'image peut se déchirer : utile uniquement au-dessus de 60 Hz.",
+ "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.": "Résolution utilisée pour estimer le mouvement, en pourcentage de l'image. Plus bas coûte moins cher et peut aider un jeu limité par le GPU, au prix de la précision sur les détails fins ou rapides.",
"About frame generation": "À propos de la génération d’images",
"Got it": "Compris",
- "Adaptive pacing (fill the display rate, up to the multiplier)": "Cadence adaptative (remplir la fréquence de l’écran, jusqu’au multiplicateur)",
- "Performance mode (cheaper generation, lower quality)": "Mode performance (génération moins coûteuse, qualité moindre)",
+ "Adaptive pacing": "Cadence adaptative",
+ "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. The generated frames are paced to your display, so it can never present more frames than your screen's refresh rate.\n\nThat means it only helps 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 gets capped to 60 and feels worse, not better.\n\nIt pays off on an external high-refresh monitor (120 Hz or more), where a 60 fps game becomes 120. It also adds a little input lag, because a real frame is held back to interpolate.\n\nAdaptive pacing measures the game's own frame rate and inserts only as many frames as it takes to fill the display, up to the multiplier: a 45 fps game gets one extra frame every other frame, and a game already at the refresh rate is left alone. It works on every graphics mode.\n\nFrame generation 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. After changing it, stop the environment and relaunch so a Steam game picks up the new setting.\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.": "Lossless Scaling insère des images interpolées entre les vraies images du jeu pour rendre le mouvement plus fluide. Les images générées sont cadencées sur votre écran : elles ne peuvent jamais dépasser sa fréquence de rafraîchissement.\n\nElle n’aide donc que lorsqu’un jeu tourne EN DESSOUS de votre 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.\n\nElle est utile sur un moniteur externe à haute fréquence (120 Hz ou plus), où un jeu à 60 fps passe à 120. Elle ajoute aussi un peu de latence, car une vraie image est retenue pour l’interpolation.\n\nLa cadence adaptative mesure la fréquence propre du jeu et n’insère que les images nécessaires pour remplir l’écran, jusqu’au multiplicateur : un jeu à 45 fps reçoit une image supplémentaire une fois sur deux, et un jeu déjà à la fréquence de l’écran est laissé tel quel. Elle fonctionne avec tous les modes graphiques.\n\nLa génération d’images 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. Après l’avoir changée, arrêtez l’environnement et relancez pour qu’un jeu Steam applique le nouveau réglage.\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.",
+ "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.",
"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.",
"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).",
- "Generated frames are paced by vsync: works best when the game holds a steady frame rate that divides the display's refresh rate (60 fps → 120 Hz). A Steam game picks this up after the environment is stopped and Steam restarted.": "Les images générées suivent la synchronisation verticale. Le résultat est meilleur avec une fréquence stable divisant celle de l’écran (60 i/s → 120 Hz). Pour un jeu Steam, arrêtez l’environnement puis redémarrez Steam pour appliquer ce réglage.",
// 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 02d9f1d..a486492 100644
--- a/Sources/HighballKit/Bottle.swift
+++ b/Sources/HighballKit/Bottle.swift
@@ -341,6 +341,9 @@ public struct BottleSettings: Codable, Sendable {
public var frameGenFlowScale: Int = 100
/// lossless scaling's performance shader set: cheaper, lower quality
public var frameGenPerformance: Bool = false
+ /// force FIFO on wrapped swapchains. Off lets the game's own present mode through, so
+ /// presentation can exceed the refresh rate; only useful above 60 Hz, and it can tear.
+ public var frameGenForceVsync: Bool = true
/// Map the Mac Command keys to Windows Ctrl, so Cmd+C/Cmd+V/Cmd+A do what a Mac user expects
/// inside Windows apps. Wine's default leaves Command as Alt, which is why pasting into Steam
/// beeps instead of pasting. Option is mapped to Alt alongside it — without that, mapping both
@@ -371,7 +374,7 @@ public struct BottleSettings: Codable, Sendable {
public var recipes: [String] = []
public var created: Date = Date()
- enum CodingKeys: String, CodingKey { case formatVersion, name, engineID, renderer, rendererExplicit, windowsVersion, sync, metalHUD, advertiseAVX, dxvkAsync, fpsCap, frameGen, frameGenAdaptive, frameGenFlowScale, frameGenPerformance, commandIsControl, commandIsControlSynced, dpiScale, dllOverrides, dxvkAppConfig, dllOverridesSynced, environment, pins, recipes, created }
+ enum CodingKeys: String, CodingKey { case formatVersion, name, engineID, renderer, rendererExplicit, windowsVersion, sync, metalHUD, advertiseAVX, dxvkAsync, fpsCap, frameGen, frameGenAdaptive, frameGenFlowScale, frameGenPerformance, frameGenForceVsync, commandIsControl, commandIsControlSynced, dpiScale, dllOverrides, dxvkAppConfig, dllOverridesSynced, environment, pins, recipes, created }
public init(name: String, engineID: String) {
self.name = name
@@ -398,6 +401,7 @@ public struct BottleSettings: Codable, Sendable {
let decodedFlow = try c.decodeIfPresent(Int.self, forKey: .frameGenFlowScale) ?? 100
frameGenFlowScale = (25...100).contains(decodedFlow) ? decodedFlow : 100
frameGenPerformance = try c.decodeIfPresent(Bool.self, forKey: .frameGenPerformance) ?? false
+ frameGenForceVsync = try c.decodeIfPresent(Bool.self, forKey: .frameGenForceVsync) ?? true
// dpiScale supersedes the old retinaMode toggle (on == 200% == LogPixels 192).
if let dpi = try c.decodeIfPresent(Int.self, forKey: .dpiScale) {
dpiScale = dpi
@@ -545,7 +549,7 @@ public struct Bottle: Sendable {
}
/// derive status from the final launch environment
- public func frameGenStatus(renderer: Renderer, engine: InstalledEngine,
+ public func frameGenStatus(engine: InstalledEngine,
environment: [String: String]? = nil) -> FrameGenStatus {
guard settings.frameGen > 1 else { return .off }
let env = environment ?? settings.environment
@@ -556,7 +560,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.lsfgShimDir else {
+ guard let shim = engine.resolveLsfgShimDir() 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 {
@@ -637,9 +641,9 @@ public struct Bottle: Sendable {
merge(&env, extra)
// apply frame generation after all overrides
env.removeValue(forKey: "HB_LSFG_UNAVAILABLE")
- let frameGeneration = frameGenStatus(renderer: r, engine: engine, environment: env)
+ let frameGeneration = frameGenStatus(engine: engine, environment: env)
if case .active(let multiplier) = frameGeneration,
- let shim = engine.lsfgShimDir, let dll = losslessScalingDLL(environment: env) {
+ let shim = engine.resolveLsfgShimDir(), 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: ":")
// metal renderers get the same dylib inserted to hook CAMetalLayer, wined3d moves to vulkan
@@ -663,6 +667,7 @@ public struct Bottle: Sendable {
if env["LSFGM_PACING_MODE"] == nil { env["LSFGM_PACING_MODE"] = settings.frameGenAdaptive ? "adaptive" : "vsync" }
if env["LSFGM_FLOW_SCALE"] == nil, settings.frameGenFlowScale < 100 { env["LSFGM_FLOW_SCALE"] = String(format: "%.2f", Double(settings.frameGenFlowScale) / 100) }
if env["LSFGM_PERFORMANCE_MODE"] == nil, settings.frameGenPerformance { env["LSFGM_PERFORMANCE_MODE"] = "1" }
+ if env["LSFGM_OVERRIDE_PRESENT_MODE"] == nil, !settings.frameGenForceVsync { env["LSFGM_OVERRIDE_PRESENT_MODE"] = "0" }
if env["LSFGM_LOG_FILE"] == nil { env["LSFGM_LOG_FILE"] = dxvkLogURL.appending(path: "lsfg-metal.log").path }
} else {
env.removeValue(forKey: "LSFGM_ENV")
diff --git a/Sources/HighballKit/EngineStore.swift b/Sources/HighballKit/EngineStore.swift
index 9d77a6e..200394b 100644
--- a/Sources/HighballKit/EngineStore.swift
+++ b/Sources/HighballKit/EngineStore.swift
@@ -456,7 +456,10 @@ public struct InstalledEngine: Sendable {
public var isComplete: Bool { missingFiles.isEmpty }
/// return the usable frame generation shim directory
- public var lsfgShimDir: URL? {
+ /// 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.
+ public func resolveLsfgShimDir() -> URL? {
let dir = renderersDir.appending(path: "lsfg", directoryHint: .isDirectory)
let shim = dir.appending(path: "libMoltenVK.dylib")
guard (try? shim.resolvingSymlinksInPath().resourceValues(forKeys: [.isRegularFileKey]).isRegularFile) == true,
diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swift
index 8cf9bb9..bb60d59 100644
--- a/Sources/HighballKit/WineRunner.swift
+++ b/Sources/HighballKit/WineRunner.swift
@@ -77,7 +77,7 @@ public struct WineRunner: Sendable {
out += "# sync=\(Self.effectiveSync(env: env, settings: bottle.settings))"
out += " winver=\(bottle.settings.windowsVersion.rawValue) dpi=\(bottle.settings.dpiScale)"
out += " dxvkAsync=\(bottle.settings.dxvkAsync)"
- switch bottle.frameGenStatus(renderer: renderer, engine: engine, environment: env) {
+ switch bottle.frameGenStatus(engine: engine, environment: env) {
case .off: out += " frameGen=off\n"
case .active(let m): out += " frameGen=\(m)x(requested\(env["LSFGM_PACING_MODE"] == "adaptive" ? ", adaptive" : "")\(env["LSFGM_FLOW_SCALE"].map { ", flow \($0)" } ?? "")\(env["LSFGM_PERFORMANCE_MODE"] == "1" ? ", performance" : ""))\n"
case .unavailable: out += " frameGen=off(unavailable)\n"
@@ -142,7 +142,7 @@ public struct WineRunner: Sendable {
// what a report quotes, so the truth about the stack the game got must be in it.
if let headerNote { header += "# note: \(headerNote)\n" }
// report why frame generation is unavailable
- if case .unavailable(let why) = bottle.frameGenStatus(renderer: resolved.renderer, engine: engine, environment: env) {
+ if case .unavailable(let why) = bottle.frameGenStatus(engine: engine, environment: env) {
header += "# note: frame generation is off: \(why)\n"
onOutput?("note: frame generation is off: \(why)")
}
diff --git a/Sources/highball/main.swift b/Sources/highball/main.swift
index bacda68..fb0e6df 100644
--- a/Sources/highball/main.swift
+++ b/Sources/highball/main.swift
@@ -135,7 +135,7 @@ struct Bottle: AsyncParsableCommand {
}
struct Set: AsyncParsableCommand {
- static let configuration = CommandConfiguration(abstract: "Change a bottle setting: engine, renderer, winver, sync, hud, avx, dpi, dxvkasync, framegen, framegenadaptive, framegenflow, framegenperformance, dlloverrides, env KEY=VALUE (empty VALUE removes)")
+ static let configuration = CommandConfiguration(abstract: "Change a bottle setting: engine, renderer, winver, sync, hud, avx, dpi, dxvkasync, framegen, framegenadaptive, framegenflow, framegenperformance, framegenforcevsync, dlloverrides, env KEY=VALUE (empty VALUE removes)")
@Argument var name: String
@Argument var setting: String
@Argument var value: String
@@ -167,6 +167,7 @@ struct Bottle: AsyncParsableCommand {
b.settings.frameGen = m
case "framegenadaptive": b.settings.frameGenAdaptive = (value == "1" || value == "true")
case "framegenperformance": b.settings.frameGenPerformance = (value == "1" || value == "true")
+ case "framegenforcevsync": b.settings.frameGenForceVsync = (value == "1" || value == "true")
case "framegenflow":
guard let f = Int(value), (25...100).contains(f) else { fail("framegenflow expects a percentage 25..100") }
b.settings.frameGenFlowScale = f
diff --git a/Tests/HighballKitTests/EnvironmentTests.swift b/Tests/HighballKitTests/EnvironmentTests.swift
index 90c0347..185c51c 100644
--- a/Tests/HighballKitTests/EnvironmentTests.swift
+++ b/Tests/HighballKitTests/EnvironmentTests.swift
@@ -154,7 +154,7 @@ final class EnvironmentTests: XCTestCase {
bottle.settings.frameGen = 2
// missing shim
- XCTAssertEqual(bottle.frameGenStatus(renderer: .dxvk, engine: engine), .unavailable("This engine has no usable frame generation component. Build or install the component for this engine."))
+ XCTAssertEqual(bottle.frameGenStatus(engine: engine), .unavailable("This engine has no usable frame generation component. Build or install the component for this engine."))
var env = try bottle.environment(engine: engine, renderer: .dxvk)
XCTAssertNil(env["LSFGM_ENV"])
@@ -162,11 +162,11 @@ final class EnvironmentTests: XCTestCase {
let shim = engine.renderersDir.appending(path: "lsfg")
try FileManager.default.createDirectory(at: shim, withIntermediateDirectories: true)
try Data().write(to: shim.appending(path: "libMoltenVK.dylib"))
- XCTAssertNil(engine.lsfgShimDir, "a shim without a real driver cannot work")
+ XCTAssertNil(engine.resolveLsfgShimDir(), "a shim without a real driver cannot work")
try FileManager.default.createDirectory(at: engine.frameworksDir, withIntermediateDirectories: true)
try Data().write(to: engine.frameworksDir.appending(path: "libMoltenVK.dylib"))
- XCTAssertNotNil(engine.lsfgShimDir)
- if case .unavailable(let why) = bottle.frameGenStatus(renderer: .dxvk, engine: engine) {
+ XCTAssertNotNil(engine.resolveLsfgShimDir())
+ if case .unavailable(let why) = bottle.frameGenStatus(engine: engine) {
XCTAssertTrue(why.contains("Lossless Scaling"), why)
} else { XCTFail("expected unavailable without the DLL") }
@@ -176,7 +176,7 @@ final class EnvironmentTests: XCTestCase {
try FileManager.default.createDirectory(at: ls, withIntermediateDirectories: true)
try Data().write(to: steam.appending(path: "steam.exe"))
try Data().write(to: ls.appending(path: "lsfg-vk.dll"))
- XCTAssertEqual(bottle.frameGenStatus(renderer: .dxvk, engine: engine), .active(multiplier: 2))
+ XCTAssertEqual(bottle.frameGenStatus(engine: engine), .active(multiplier: 2))
env = try bottle.environment(engine: engine, renderer: .dxvk)
XCTAssertEqual(env["LSFGM_ENV"], "1")
XCTAssertEqual(env["LSFGM_MULTIPLIER"], "2")
@@ -188,17 +188,17 @@ final class EnvironmentTests: XCTestCase {
XCTAssertEqual(env["DYLD_LIBRARY_PATH"], shim.path)
XCTAssertTrue(env["DYLD_FALLBACK_LIBRARY_PATH"]!.contains(engine.frameworksDir.path), "the runtime's fallback path is untouched")
- // metal rendering bypasses frame generation
- if case .unavailable(let why) = bottle.frameGenStatus(renderer: .dxmt, engine: engine) {
- XCTAssertTrue(why.contains("DXMT"), why)
- } else { XCTFail("expected unavailable on dxmt") }
+ // a Metal renderer generates through the Metal hook instead of the Vulkan one
+ XCTAssertEqual(bottle.frameGenStatus(engine: engine), .active(multiplier: 2))
env = try bottle.environment(engine: engine, renderer: .dxmt)
- XCTAssertNil(env["LSFGM_ENV"])
- XCTAssertNil(env["DYLD_LIBRARY_PATH"])
+ XCTAssertEqual(env["LSFGM_ENV"], "1")
+ XCTAssertEqual(env["LSFGM_METAL"], "1")
+ XCTAssertTrue(env["DYLD_INSERT_LIBRARIES"]!.contains(shim.appending(path: "libMoltenVK.dylib").path),
+ "the Metal hook must be injected")
// off overrides installed components
bottle.settings.frameGen = 1
- XCTAssertEqual(bottle.frameGenStatus(renderer: .dxvk, engine: engine), .off)
+ XCTAssertEqual(bottle.frameGenStatus(engine: engine), .off)
XCTAssertNil(try bottle.environment(engine: engine, renderer: .dxvk)["LSFGM_ENV"])
}
diff --git a/Tests/HighballKitTests/FrameGenerationTests.swift b/Tests/HighballKitTests/FrameGenerationTests.swift
index c6f3d65..acb1852 100644
--- a/Tests/HighballKitTests/FrameGenerationTests.swift
+++ b/Tests/HighballKitTests/FrameGenerationTests.swift
@@ -25,21 +25,21 @@ private func frameGenerationChecks() throws {
let shim = engine.renderersDir.appending(path: "lsfg")
let driver = engine.frameworksDir.appending(path: "libMoltenVK.dylib")
try file(shim.appending(path: "libMoltenVK.dylib"))
- try check(engine.lsfgShimDir == nil, "Missing real driver was reported available")
+ try check(engine.resolveLsfgShimDir() == nil, "Missing real driver was reported available")
try file(driver)
try fm.removeItem(at: shim.appending(path: "libMoltenVK.dylib"))
try fm.createDirectory(at: shim.appending(path: "libMoltenVK.dylib"), withIntermediateDirectories: false)
- try check(engine.lsfgShimDir == nil, "A directory was accepted as the shim")
+ try check(engine.resolveLsfgShimDir() == nil, "A directory was accepted as the shim")
try fm.removeItem(at: shim.appending(path: "libMoltenVK.dylib"))
try file(shim.appending(path: "libMoltenVK.dylib"))
- try check(engine.lsfgShimDir?.path == shim.path, "Driver link was not healed")
+ try check(engine.resolveLsfgShimDir()?.path == shim.path, "Driver link was not healed")
let real = shim.appending(path: InstalledEngine.lsfgRealDriverName)
try fm.removeItem(at: real)
try fm.createSymbolicLink(atPath: real.path, withDestinationPath: "/missing-driver")
- try check(engine.lsfgShimDir?.path == shim.path, "Broken driver link was not healed")
+ try check(engine.resolveLsfgShimDir()?.path == shim.path, "Broken driver link was not healed")
try fm.removeItem(at: real)
try file(real, "keep this user file")
- _ = engine.lsfgShimDir
+ _ = engine.resolveLsfgShimDir()
let userFile = try String(contentsOf: real, encoding: .utf8)
try check(userFile == "keep this user file", "Driver repair deleted a regular user file")
@@ -58,7 +58,7 @@ private func frameGenerationChecks() throws {
extra: ["LSFGM_MULTIPLIER": "3", "DYLD_LIBRARY_PATH": "/custom/lib"])
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(renderer: .dxvk, engine: engine, environment: env) == .active(multiplier: 3), "Status disagrees with environment")
+ try check(bottle.frameGenStatus(engine: engine, environment: env) == .active(multiplier: 3), "Status disagrees with environment")
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")
@@ -70,7 +70,7 @@ private func frameGenerationChecks() throws {
env = try bottle.environment(engine: engine, renderer: .dxvk, extra: ["LSFGM_MOLTENVK": driver.path])
try check(env["LSFGM_ENV"] == nil, "Recursive driver leaf name was accepted")
env = try bottle.environment(engine: engine, renderer: .dxvk, extra: ["DISABLE_LSFGM": "1"])
- try check(bottle.frameGenStatus(renderer: .dxvk, engine: engine, environment: env) == .off, "Explicit disable was ignored")
+ try check(bottle.frameGenStatus(engine: engine, environment: env) == .off, "Explicit disable was ignored")
for multiplier in [2, 3, 4] {
bottle.settings.frameGen = multiplier
env = try bottle.environment(engine: engine, renderer: .dxvk)
@@ -79,6 +79,15 @@ private func frameGenerationChecks() throws {
try check(env["LSFGM_PACING_MODE"] == "vsync", "Default pacing is not fixed vsync")
try check(env["LSFGM_FLOW_SCALE"] == nil, "Full flow scale was exported")
try check(env["LSFGM_PERFORMANCE_MODE"] == nil, "Performance mode exported by default")
+ try check(env["LSFGM_OVERRIDE_PRESENT_MODE"] == nil, "Present-mode override exported while forcing vsync")
+ bottle.settings.frameGenForceVsync = false
+ env = try bottle.environment(engine: engine, renderer: .dxvk)
+ try check(env["LSFGM_OVERRIDE_PRESENT_MODE"] == "0", "Turning off forced vsync did not release the present mode")
+ bottle.settings.frameGenForceVsync = true
+ env = try bottle.environment(engine: engine, renderer: .dxvk)
+ try check(env["LSFGM_OVERRIDE_PRESENT_MODE"] == nil, "Forced vsync did not return to the default")
+ let vsyncDefault = try JSONDecoder.highball.decode(BottleSettings.self, from: Data(#"{"name":"old","engineID":"e"}"#.utf8))
+ try check(vsyncDefault.frameGenForceVsync, "A bottle saved before this setting existed did not default to forcing vsync")
bottle.settings.frameGenAdaptive = true
bottle.settings.frameGenFlowScale = 50
bottle.settings.frameGenPerformance = true
@@ -119,7 +128,7 @@ private func frameGenerationChecks() throws {
let legacy = try JSONDecoder.highball.decode(BottleSettings.self, from: Data(#"{"name":"old","engineID":"e"}"#.utf8))
try check(legacy.frameGen == 1, "Legacy bottle did not default to off")
try fm.removeItem(at: driver)
- try check(engine.lsfgShimDir == nil, "Removed driver was reported available")
+ try check(engine.resolveLsfgShimDir() == nil, "Removed driver was reported available")
}
private func localComponentChecks() async throws {