Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
frame generation: optional interpolation through a renderer component
itsOwen9dd5aab26666
diff --git a/Scripts/build-lsfg.sh b/Scripts/build-lsfg.shnew file mode 100755index 0000000..8fd7fa5--- /dev/null+++ b/Scripts/build-lsfg.sh@@ -0,0 +1,57 @@+#!/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]+set -euo pipefail+cd "$(dirname "$0")/.."+TAG="${1:-macos-local}"+[[ "$TAG" =~ ^[A-Za-z0-9._-]+$ ]] || { echo "invalid tag" >&2; exit 1; }+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)"+export LSFGM_VERSION="$PORT_VERSION"+(cd "$SRC" && cargo build --release && cargo test --release)+DYLIB="$SRC/target/x86_64-apple-darwin/release/liblsfg_metal.dylib"+# exactly four exported text symbols, the names Wine dlsyms (objc2 class statics are data, not T)+SYMBOLS="$(nm -gU "$DYLIB" | awk '$2=="T"')"+COUNT="$(printf '%s\n' "$SYMBOLS" | grep -c . || true)"+[[ "$COUNT" -eq 4 ]] || { echo "expected 4 exported functions, found $COUNT:" >&2; printf '%s\n' "$SYMBOLS" >&2; exit 1; }+for symbol in vkGetInstanceProcAddr vkGetDeviceProcAddr vkCreateMetalSurfaceEXT vkCreateMacOSSurfaceMVK; do+ printf '%s\n' "$SYMBOLS" | grep -q " _$symbol\$" || { echo "missing export: $symbol" >&2; exit 1; }+done+WORK="$(mktemp -d)"+trap 'rm -rf "$WORK"' EXIT+PKG="$WORK/pkg"+mkdir -p "$PKG/renderers/lsfg" dist+cp "$DYLIB" "$PKG/renderers/lsfg/libMoltenVK.dylib"+codesign -s - -f "$PKG/renderers/lsfg/libMoltenVK.dylib"+SHA="$(shasum -a 256 "$PKG/renderers/lsfg/libMoltenVK.dylib" | awk '{print $1}')"+ln -s ../../frameworks/libMoltenVK.dylib "$PKG/renderers/lsfg/libMoltenVK.real.dylib"+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'+import pathlib,sys,tarfile,json,hashlib+root=pathlib.Path(sys.argv[1]);archive=pathlib.Path(sys.argv[2])+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)))+ info.uid=info.gid=0;info.uname=info.gname='';info.mtime=0;info.pax_headers={}+ if info.isfile():+ with path.open('rb') as content:tar.addfile(info,content)+ 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,+ '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')+print(f'{archive}: sha256 {sha}, size {archive.stat().st_size}')+print(f'Local manifest: {output}')+PYdiff --git a/Scripts/check-framegen.sh b/Scripts/check-framegen.shnew file mode 100755index 0000000..8a94964--- /dev/null+++ b/Scripts/check-framegen.sh@@ -0,0 +1,11 @@+#!/bin/bash+# run integration checks without xcode+set -euo pipefail+cd "$(dirname "$0")/.."+swift build --product highball+CHECK_DIR="$(mktemp -d)"+trap 'rm -rf "$CHECK_DIR"' EXIT+swiftc -D FRAMEGEN_STANDALONE -parse-as-library -I .build/debug \+ Tests/HighballKitTests/FrameGenerationTests.swift .build/debug/HighballKit.o \+ -o "$CHECK_DIR/check-framegen"+"$CHECK_DIR/check-framegen"diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swiftindex 9d0db1a..07d6285 100644--- a/Sources/HighballApp/BottleView.swift+++ b/Sources/HighballApp/BottleView.swift@@ -264,13 +264,15 @@ struct BottleSettingsSheet: View {@Environment(\.dismiss) private var dismisslet bottle: Bottle@State private var confirmDelete = false+ @State private var showFrameGenInfo = false/// 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? = nilprivate var currentDpi: Int { (state.bottles.first { $0.name == bottle.name } ?? bottle).settings.dpiScale }- private var currentRenderer: Renderer { (state.bottles.first { $0.name == bottle.name } ?? bottle).settings.renderer }- private var engine: InstalledEngine? { state.engine(for: bottle) }+ private var liveBottle: Bottle { state.bottles.first { $0.name == bottle.name } ?? bottle }+ private var currentRenderer: Renderer { liveBottle.settings.renderer }+ private var engine: InstalledEngine? { state.engine(for: liveBottle) }private var d3dmetalAvailable: Bool { engine?.rendererDir("d3dmetal") != nil }private var vkd3dAvailable: Bool { engine?.rendererDir("vkd3d") != nil }private var d3dmetalPossible: Bool {@@ -326,6 +328,41 @@ struct BottleSettingsSheet: View {}.controlSize(.small)}}+ // only engines that ship the shim get the control+ if let engine, engine.lsfgShimDir != nil {+ Picker(L("Frame generation (Lossless Scaling, beta)"), selection: Binding(+ get: { liveBottle.settings.frameGen },+ set: { newValue in+ let turnedOn = liveBottle.settings.frameGen <= 1 && newValue > 1+ var copy = state.bottles.first { $0.name == bottle.name } ?? bottle+ copy.settings.frameGen = newValue+ Task { @MainActor in state.update(copy) }+ if turnedOn { showFrameGenInfo = true }+ })) {+ Text(L("Off")).tag(1)+ Text("2×").tag(2)+ Text("3×").tag(3)+ Text("4×").tag(4)+ }+ Button(L("How frame generation works")) { showFrameGenInfo = true }+ .buttonStyle(.link).controlSize(.small)+ 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)+ }+ }+ if case .unavailable(let why) = liveBottle.frameGenStatus(renderer: currentRenderer, engine: engine) {+ Text(String(format: L("Frame generation stays off: %@"), L(why)))+ .font(.caption).foregroundStyle(.secondary)+ } else if case .active = liveBottle.frameGenStatus(renderer: currentRenderer, engine: engine) {+ Text(L("After changing this, stop the environment and relaunch so a Steam game picks it up."))+ .font(.caption).foregroundStyle(.secondary)+ }+ }Toggle(L("Metal performance HUD"), isOn: binding(\.metalHUD))Toggle(L("DXVK async shader compilation (experimental — can skip draws while a shader compiles)"), isOn: binding(\.dxvkAsync))Picker(L("Frame rate cap"), selection: binding(\.fpsCap)) {@@ -434,6 +471,11 @@ struct BottleSettingsSheet: View {Button(L("Delete"), role: .destructive) { dismiss(); state.deleteBottle(bottle.name) }Button(L("Cancel"), role: .cancel) {}}+ .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."))+ }}private func binding<T>(_ keyPath: WritableKeyPath<BottleSettings, T>) -> Binding<T> {diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swiftindex 11cbd19..a23b88f 100644--- a/Sources/HighballApp/L10n.swift+++ b/Sources/HighballApp/L10n.swift@@ -9,6 +9,22 @@ func L(_ en: String) -> String {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",+ "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)",+ "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.",+ "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.swiftindex 3e0088e..02d9f1d 100644--- a/Sources/HighballKit/Bottle.swift+++ b/Sources/HighballKit/Bottle.swift@@ -333,6 +333,14 @@ public struct BottleSettings: Codable, Sendable {public var dxvkAsync: Bool = false/// Cap the frame rate (0 = uncapped). Applied per renderer (DXVK_FRAME_RATE / DXMT_CONFIG).public var fpsCap: Int = 0+ /// frame generation multiplier; 1 disables it+ public var frameGen: Int = 1+ /// adaptive pacing: fill display slots per source frame, the multiplier is the cap+ public var frameGenAdaptive: Bool = false+ /// flow estimation resolution as a percentage of the frame, 25 to 100+ public var frameGenFlowScale: Int = 100+ /// lossless scaling's performance shader set: cheaper, lower quality+ public var frameGenPerformance: Bool = false/// 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@@ -363,7 +371,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, 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, commandIsControl, commandIsControlSynced, dpiScale, dllOverrides, dxvkAppConfig, dllOverridesSynced, environment, pins, recipes, created }public init(name: String, engineID: String) {self.name = name@@ -384,6 +392,12 @@ public struct BottleSettings: Codable, Sendable {advertiseAVX = try c.decodeIfPresent(Bool.self, forKey: .advertiseAVX) ?? falsedxvkAsync = try c.decodeIfPresent(Bool.self, forKey: .dxvkAsync) ?? falsefpsCap = try c.decodeIfPresent(Int.self, forKey: .fpsCap) ?? 0+ let decodedFrameGen = try c.decodeIfPresent(Int.self, forKey: .frameGen) ?? 1+ frameGen = (1...4).contains(decodedFrameGen) ? decodedFrameGen : 1+ frameGenAdaptive = try c.decodeIfPresent(Bool.self, forKey: .frameGenAdaptive) ?? false+ 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// dpiScale supersedes the old retinaMode toggle (on == 200% == LogPixels 192).if let dpi = try c.decodeIfPresent(Int.self, forKey: .dpiScale) {dpiScale = dpi@@ -474,6 +488,93 @@ public struct Bottle: Sendable {return (instead, "running with \(Renderer.displayName(instead)) instead of \(Renderer.displayName(wanted)): \(why)")}+ /// lossless scaling app id+ public static let losslessScalingAppID = 993090++ /// resolve native paths and wine drive mappings+ private func frameGenPath(_ path: String) -> URL {+ if path.hasPrefix("/") { return URL(fileURLWithPath: path) }+ let pieces = path.replacingOccurrences(of: "\\", with: "/").split(separator: ":", maxSplits: 1)+ if pieces.count == 2, pieces[0].count == 1 {+ let drive = String(pieces[0]).lowercased()+ if drive == "c" || drive == "z" { return resolve(windowsPath: path) }+ return url.appending(path: "dosdevices/\(drive):")+ .appending(path: String(pieces[1]).trimmingCharacters(in: CharacterSet(charactersIn: "/")))+ .resolvingSymlinksInPath()+ }+ return URL(fileURLWithPath: path, relativeTo: url).standardizedFileURL+ }++ private func frameGenFile(_ url: URL) -> Bool {+ (try? url.resolvingSymlinksInPath().resourceValues(forKeys: [.isRegularFileKey]).isRegularFile) == true+ && FileManager.default.isReadableFile(atPath: url.path)+ }++ public var losslessScalingDLL: URL? { losslessScalingDLL(environment: settings.environment) }++ private func losslessScalingDLL(environment: [String: String]) -> URL? {+ if let override = environment["LSFGM_DLL_PATH"], !override.isEmpty {+ 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))+ }+ }+ 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")+ if frameGenFile(dll) { return dll }+ }+ return nil+ }++ public enum FrameGenStatus: Equatable, Sendable {+ case off+ /// requested for this launch; runtime fallback is still possible+ case active(multiplier: Int)+ case unavailable(String)+ }++ /// derive status from the final launch environment+ public func frameGenStatus(renderer: Renderer, engine: InstalledEngine,+ 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) }+ guard (1...4).contains(settings.frameGen),+ let multiplier = Int(env["LSFGM_MULTIPLIER"] ?? String(settings.frameGen)),+ (1...4).contains(multiplier) else {+ 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 {+ 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 {+ let driver = frameGenPath(path)+ guard driver.lastPathComponent != "libMoltenVK.dylib", frameGenFile(driver),+ driver.resolvingSymlinksInPath() != shim.appending(path: "libMoltenVK.dylib").resolvingSymlinksInPath() else {+ return .unavailable("The real MoltenVK override is unusable. Use a readable driver with a different filename from libMoltenVK.dylib.")+ }+ }+ guard losslessScalingDLL(environment: env) != nil else {+ 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 .active(multiplier: multiplier)+ }+public func environment(engine: InstalledEngine, renderer: Renderer? = nil, extra: [String: String] = [:]) throws -> [String: String] {let effective = try effectiveRenderer(requested: renderer, engine: engine).renderervar env = engine.baseEnvironment()@@ -534,6 +635,43 @@ public struct Bottle: Sendable {merge(&env, settings.environment)merge(&env, try effective.environment(engine: engine))merge(&env, extra)+ // apply frame generation after all overrides+ env.removeValue(forKey: "HB_LSFG_UNAVAILABLE")+ let frameGeneration = frameGenStatus(renderer: r, engine: engine, environment: env)+ if case .active(let multiplier) = frameGeneration,+ let shim = engine.lsfgShimDir, 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+ switch r {+ case .dxmt, .d3dmetal:+ env["LSFGM_METAL"] = "1"+ let dylib = shim.appending(path: "libMoltenVK.dylib").path+ let inserted = (env["DYLD_INSERT_LIBRARIES"] ?? "").split(separator: ":").map(String.init)+ env["DYLD_INSERT_LIBRARIES"] = ([dylib] + inserted.filter { $0 != dylib }).joined(separator: ":")+ case .wined3d:+ let options = (env["WINE_D3D_CONFIG"] ?? "").split(separator: ",").map(String.init)+ env["WINE_D3D_CONFIG"] = (["renderer=vulkan"] + options.filter { !$0.hasPrefix("renderer=") }).joined(separator: ",")+ case .dxvk, .vkd3d:+ env.removeValue(forKey: "LSFGM_METAL")+ }+ env["LSFGM_MOLTENVK"] = env["LSFGM_MOLTENVK"].flatMap { $0.isEmpty ? nil : frameGenPath($0).path }+ ?? shim.appending(path: InstalledEngine.lsfgRealDriverName).path+ env["LSFGM_ENV"] = "1"+ env["LSFGM_MULTIPLIER"] = String(multiplier)+ env["LSFGM_DLL_PATH"] = dll.path+ 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_LOG_FILE"] == nil { env["LSFGM_LOG_FILE"] = dxvkLogURL.appending(path: "lsfg-metal.log").path }+ } else {+ env.removeValue(forKey: "LSFGM_ENV")+ env.removeValue(forKey: "LSFGM_PROFILE")+ env.removeValue(forKey: "LSFGM_METAL")+ // keep unavailable settings disabled+ env["DISABLE_LSFGM"] = "1"+ if case .unavailable(let reason) = frameGeneration { env["HB_LSFG_UNAVAILABLE"] = reason }+ }return env}diff --git a/Sources/HighballKit/EngineStore.swift b/Sources/HighballKit/EngineStore.swiftindex 4069d61..9d77a6e 100644--- a/Sources/HighballKit/EngineStore.swift+++ b/Sources/HighballKit/EngineStore.swift@@ -218,6 +218,15 @@ public struct EngineStore: Sendable {/// stalled connection from hanging forever.public func download(_ component: EngineManifest.Component, name: String, progress: DownloadProgress? = nil) async throws -> URL {try paths.ensure()+ // verify local archives too+ if component.url.isFileURL {+ let actual = try sha256(of: component.url)+ guard actual == component.sha256.lowercased() else {+ throw HighballError.checksumMismatch(file: component.url.lastPathComponent,+ expected: component.sha256, actual: actual)+ }+ return component.url+ }let dest = paths.downloads.appending(path: component.url.lastPathComponent)if FileManager.default.fileExists(atPath: dest.path), try sha256(of: dest) == component.sha256.lowercased() {return dest@@ -446,6 +455,35 @@ public struct InstalledEngine: Sendable {}public var isComplete: Bool { missingFiles.isEmpty }+ /// return the usable frame generation shim directory+ public var lsfgShimDir: 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,+ FileManager.default.isReadableFile(atPath: shim.path) else { return nil }+ // use a different filename to avoid loading the shim recursively+ let fm = FileManager.default+ let driver = frameworksDir.appending(path: "libMoltenVK.dylib")+ guard (try? driver.resourceValues(forKeys: [.isRegularFileKey]).isRegularFile) == true,+ fm.isReadableFile(atPath: driver.path) else { return nil }+ let link = dir.appending(path: Self.lsfgRealDriverName)+ let target = "../../frameworks/libMoltenVK.dylib"+ let current = try? fm.destinationOfSymbolicLink(atPath: link.path)+ // repair links without replacing regular files+ if current != target && (current != nil || !fm.fileExists(atPath: link.path)) {+ do {+ if current != nil { try fm.removeItem(at: link) }+ try fm.createSymbolicLink(atPath: link.path, withDestinationPath: target)+ } catch { return nil }+ }+ guard fm.isReadableFile(atPath: link.path),+ (try? link.resolvingSymlinksInPath().resourceValues(forKeys: [.isRegularFileKey]).isRegularFile) == true,+ link.resolvingSymlinksInPath() != dir.appending(path: "libMoltenVK.dylib").resolvingSymlinksInPath() else { return nil }+ return dir+ }++ /// alternate filename for the real driver+ public static let lsfgRealDriverName = "libMoltenVK.real.dylib"public var winetricks: URL? {let t = root.appending(path: "tools/winetricks")return FileManager.default.fileExists(atPath: t.path) ? t : nildiff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swiftindex 53b721f..8cf9bb9 100644--- a/Sources/HighballKit/WineRunner.swift+++ b/Sources/HighballKit/WineRunner.swift@@ -76,8 +76,13 @@ public struct WineRunner: Sendable {out += "# wine \(args.joined(separator: " "))\n"out += "# sync=\(Self.effectiveSync(env: env, settings: bottle.settings))"out += " winver=\(bottle.settings.windowsVersion.rawValue) dpi=\(bottle.settings.dpiScale)"- out += " dxvkAsync=\(bottle.settings.dxvkAsync)\n"- for key in ["WINEDLLPATH_PREPEND", "WINEDLLOVERRIDES", "ROSETTA_ADVERTISE_AVX", "MTL_HUD_ENABLED", "CX_FWD_COMPAT_GL_CTX", "DXVK_CONFIG_FILE", "DXVK_LOG_PATH"] {+ out += " dxvkAsync=\(bottle.settings.dxvkAsync)"+ switch bottle.frameGenStatus(renderer: renderer, 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"+ }+ for key in ["WINEDLLPATH_PREPEND", "WINEDLLOVERRIDES", "ROSETTA_ADVERTISE_AVX", "MTL_HUD_ENABLED", "CX_FWD_COMPAT_GL_CTX", "DXVK_CONFIG_FILE", "DXVK_LOG_PATH", "LSFGM_MULTIPLIER", "LSFGM_PACING_MODE", "LSFGM_FLOW_SCALE", "LSFGM_DLL_PATH"] {if let value = env[key] { out += "# \(key)=\(value)\n" }}// The generated dxvk.conf decides per-game behaviour, so quote it rather than making the@@ -136,12 +141,20 @@ public struct WineRunner: Sendable {// The caller's own caveat, e.g. a Steam client kept with another renderer: the header is// 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) {+ header += "# note: frame generation is off: \(why)\n"+ onOutput?("note: frame generation is off: \(why)")+ }logHandle.write(Data(header.utf8))let process = Process()process.executableURL = engine.wineBinaryprocess.arguments = args- process.environment = ProcessInfo.processInfo.environment.merging(env) { $1 }+ let inherited = ProcessInfo.processInfo.environment.filter {+ !$0.key.hasPrefix("LSFGM_") && $0.key != "DISABLE_LSFGM"+ }+ process.environment = inherited.merging(env) { $1 }// drive_c only exists after the first wineboot — fall back to the bottle root on fresh prefixes.process.currentDirectoryURL = workingDirectory?? (FileManager.default.fileExists(atPath: bottle.driveC.path) ? bottle.driveC : bottle.url)diff --git a/Sources/highball/main.swift b/Sources/highball/main.swiftindex 0076ccd..bacda68 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, 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, dlloverrides, env KEY=VALUE (empty VALUE removes)")@Argument var name: String@Argument var setting: String@Argument var value: String@@ -162,6 +162,14 @@ struct Bottle: AsyncParsableCommand {case "hud": b.settings.metalHUD = (value == "1" || value == "true")case "avx": b.settings.advertiseAVX = (value == "1" || value == "true")case "dxvkasync": b.settings.dxvkAsync = (value == "1" || value == "true")+ case "framegen":+ guard let m = Int(value), (1...4).contains(m) else { fail("framegen expects a multiplier 1..4 (1 = off)") }+ b.settings.frameGen = m+ case "framegenadaptive": b.settings.frameGenAdaptive = (value == "1" || value == "true")+ case "framegenperformance": b.settings.frameGenPerformance = (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 = fcase "dlloverrides":b.settings.dllOverrides = valuecase "dpi":diff --git a/Tests/HighballKitTests/EnvironmentTests.swift b/Tests/HighballKitTests/EnvironmentTests.swiftindex 9d00f3e..90c0347 100644--- a/Tests/HighballKitTests/EnvironmentTests.swift+++ b/Tests/HighballKitTests/EnvironmentTests.swift@@ -142,6 +142,66 @@ final class EnvironmentTests: XCTestCase {XCTAssertEqual(env["WINEDLLPATH_PREPEND"], "\(d9vkWine.path):\(dxvkWine.path)")}+ // check frame generation setup and fallback+ func testFrameGenEnvironment() throws {+ var (engine, bottle) = try fixtures()+ let root = FileManager.default.temporaryDirectory.appending(path: "hb-test-fg-\(UUID().uuidString)")+ bottle = Bottle(url: root, settings: bottle.settings)+ defer { try? FileManager.default.removeItem(at: root); try? FileManager.default.removeItem(at: engine.root) }+ for dir in ["d9vk/wine", "dxvk/wine", "dxmt/wine"] {+ try FileManager.default.createDirectory(at: engine.renderersDir.appending(path: dir), withIntermediateDirectories: true)+ }+ 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."))+ var env = try bottle.environment(engine: engine, renderer: .dxvk)+ XCTAssertNil(env["LSFGM_ENV"])++ // missing shaders+ 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")+ 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) {+ XCTAssertTrue(why.contains("Lossless Scaling"), why)+ } else { XCTFail("expected unavailable without the DLL") }++ // add the shader fixture+ let steam = bottle.driveC.appending(path: "Program Files (x86)/Steam")+ let ls = steam.appending(path: "steamapps/common/Lossless Scaling")+ 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))+ env = try bottle.environment(engine: engine, renderer: .dxvk)+ XCTAssertEqual(env["LSFGM_ENV"], "1")+ XCTAssertEqual(env["LSFGM_MULTIPLIER"], "2")+ XCTAssertEqual(env["LSFGM_DLL_PATH"], ls.appending(path: "lsfg-vk.dll").path)+ // check driver link repair+ XCTAssertEqual(env["LSFGM_MOLTENVK"], shim.appending(path: "libMoltenVK.real.dylib").path)+ XCTAssertEqual(try FileManager.default.destinationOfSymbolicLink(atPath: shim.appending(path: "libMoltenVK.real.dylib").path), "../../frameworks/libMoltenVK.dylib")+ // the shim must take priority over the driver+ 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") }+ env = try bottle.environment(engine: engine, renderer: .dxmt)+ XCTAssertNil(env["LSFGM_ENV"])+ XCTAssertNil(env["DYLD_LIBRARY_PATH"])++ // off overrides installed components+ bottle.settings.frameGen = 1+ XCTAssertEqual(bottle.frameGenStatus(renderer: .dxvk, engine: engine), .off)+ XCTAssertNil(try bottle.environment(engine: engine, renderer: .dxvk)["LSFGM_ENV"])+ }+// A renderer whose overlay is missing must throw, not silently fall back.func testMissingRendererThrows() throws {let (engine, bottle) = try fixtures()diff --git a/Tests/HighballKitTests/FrameGenerationTests.swift b/Tests/HighballKitTests/FrameGenerationTests.swiftnew file mode 100644index 0000000..c6f3d65--- /dev/null+++ b/Tests/HighballKitTests/FrameGenerationTests.swift@@ -0,0 +1,154 @@+import Foundation+import CryptoKit+@testable import HighballKit++private func frameGenerationChecks() throws {+ let fm = FileManager.default+ let root = fm.temporaryDirectory.appending(path: "hb-framegen-\(UUID().uuidString)")+ defer { try? fm.removeItem(at: root) }+ func check(_ value: @autoclosure () -> Bool, _ message: String) throws {+ if !value() { throw HighballError.failed(message) }+ }+ func file(_ url: URL, _ data: String = "fixture") throws {+ try fm.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)+ try Data(data.utf8).write(to: url)+ }+ let manifest = try EngineManifest.load(from: URL(fileURLWithPath: #filePath)+ .deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()+ .appending(path: "spike/engine-manifest.json"))+ let engine = InstalledEngine(manifest: manifest, root: root.appending(path: "engine"))+ var bottle = Bottle(url: root.appending(path: "bottle"), settings: BottleSettings(name: "audit", engineID: manifest.id))+ for renderer in ["dxvk", "d9vk", "dxmt", "vkd3d"] {+ try fm.createDirectory(at: engine.renderersDir.appending(path: "\(renderer)/wine"), withIntermediateDirectories: true)+ }+ bottle.settings.frameGen = 2+ 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 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 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")+ 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 fm.removeItem(at: real)+ try file(real, "keep this user file")+ _ = engine.lsfgShimDir+ let userFile = try String(contentsOf: real, encoding: .utf8)+ try check(userFile == "keep this user file", "Driver repair deleted a regular user file")++ 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")+ let windowsLibrary = "Z:" + external.path.replacingOccurrences(of: "/", with: "\\")+ try file(steam.appending(path: "steamapps/libraryfolders.vdf"),+ "\"libraryfolders\" { \"1\" { \"path\" \"\(windowsLibrary.replacingOccurrences(of: "\\", with: "\\\\"))\" } }")+ let dll = external.appending(path: "steamapps/common/Custom LS/lsfg-vk.dll")+ try file(external.appending(path: "steamapps/appmanifest_993090.acf"),+ "\"AppState\" { \"appid\" \"993090\" \"name\" \"Lossless Scaling\" \"installdir\" \"Custom LS\" \"StateFlags\" \"4\" }")+ try file(dll)+ try check(bottle.losslessScalingDLL == dll, "Secondary Steam library was not discovered")+ var env = try bottle.environment(engine: engine, renderer: .dxvk,+ 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(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")+ bottle.settings.environment["LSFGM_DLL_PATH"] = external.path+ env = try bottle.environment(engine: engine, renderer: .dxvk)+ try check(env["LSFGM_ENV"] == nil, "A directory was accepted as a shader DLL")+ try check(env["HB_LSFG_UNAVAILABLE"]?.contains("override") == true, "Invalid override was not explained")+ bottle.settings.environment.removeAll()+ 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")+ for multiplier in [2, 3, 4] {+ bottle.settings.frameGen = multiplier+ env = try bottle.environment(engine: engine, renderer: .dxvk)+ try check(env["LSFGM_MULTIPLIER"] == String(multiplier), "Supported multiplier not configured")+ }+ 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")+ bottle.settings.frameGenAdaptive = true+ bottle.settings.frameGenFlowScale = 50+ bottle.settings.frameGenPerformance = true+ env = try bottle.environment(engine: engine, renderer: .dxvk)+ try check(env["LSFGM_PACING_MODE"] == "adaptive" && env["LSFGM_FLOW_SCALE"] == "0.50" && env["LSFGM_PERFORMANCE_MODE"] == "1", "Adaptive, flow and performance settings not configured")+ try check(WineRunner.launchHeader(engine: engine, bottle: bottle, renderer: .dxvk, env: env, args: []).contains("frameGen=4x(requested, adaptive, flow 0.50, performance)"), "Header omits pacing, flow and performance")+ let flowSettings = try JSONDecoder.highball.decode(BottleSettings.self, from: Data(#"{"name":"old","engineID":"e","frameGenFlowScale":10}"#.utf8))+ try check(flowSettings.frameGenFlowScale == 100, "Invalid saved flow scale did not default to full")+ env = try bottle.environment(engine: engine, renderer: .dxvk, extra: ["LSFGM_PACING_MODE": "vsync"])+ try check(env["LSFGM_PACING_MODE"] == "vsync", "Pacing override was replaced")+ bottle.settings.frameGenAdaptive = false+ bottle.settings.frameGenFlowScale = 100+ bottle.settings.frameGenPerformance = false+ bottle.settings.fpsCap = 30+ env = try bottle.environment(engine: engine, renderer: .dxmt) // the test engine has no d3dmetal+ try check(env["DXMT_CONFIG"] == "d3d11.preferredMaxFrameRate=30;", "Frame cap not passed to dxmt")+ bottle.settings.fpsCap = 0+ let dylib = shim.appending(path: "libMoltenVK.dylib").path+ env = try bottle.environment(engine: engine, renderer: .dxmt, extra: ["DYLD_INSERT_LIBRARIES": "/custom/insert.dylib"])+ try check(env["LSFGM_ENV"] == "1" && env["LSFGM_METAL"] == "1", "Metal renderer did not use the metal hook")+ try check(env["DYLD_INSERT_LIBRARIES"] == dylib + ":/custom/insert.dylib", "Metal hook not inserted ahead of custom libraries")+ try check(env["DYLD_LIBRARY_PATH"]?.hasPrefix(shim.path) == true, "Vulkan hook (D3D9 on a Metal renderer) missing")+ env = try bottle.environment(engine: engine, renderer: .wined3d, extra: ["WINE_D3D_CONFIG": "csmt=0,renderer=gl"])+ try check(env["LSFGM_ENV"] == "1" && env["LSFGM_METAL"] == nil, "WineD3D did not use the Vulkan hook")+ try check(env["WINE_D3D_CONFIG"] == "renderer=vulkan,csmt=0", "WineD3D was not switched to its Vulkan renderer")+ env = try bottle.environment(engine: engine, renderer: .dxvk, extra: ["LSFGM_METAL": "1"])+ try check(env["LSFGM_METAL"] == nil && env["DYLD_INSERT_LIBRARIES"] == nil, "Vulkan renderer picked up the metal hook")+ bottle.settings.frameGen = 1+ env = try bottle.environment(engine: engine, renderer: .dxvk, extra: ["LSFGM_ENV": "1", "LSFGM_MULTIPLIER": "3"])+ try check(env["LSFGM_ENV"] == nil && env["DISABLE_LSFGM"] == "1", "Off setting was bypassed by an override")+ env = try bottle.environment(engine: engine, renderer: .dxmt, extra: ["LSFGM_METAL": "1"])+ try check(env["LSFGM_METAL"] == nil && env["DISABLE_LSFGM"] == "1", "Off setting left the metal hook armed")+ for value in [-1, 0, 999] {+ let settings = try JSONDecoder.highball.decode(BottleSettings.self,+ from: Data("{\"name\":\"old\",\"engineID\":\"e\",\"frameGen\":\(value)}".utf8))+ try check(settings.frameGen == 1, "Invalid saved multiplier did not default to off")+ }+ 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")+}++private func localComponentChecks() async throws {+ let root = FileManager.default.temporaryDirectory.appending(path: "hb-local-component-\(UUID().uuidString)")+ defer { try? FileManager.default.removeItem(at: root) }+ try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)+ let archive = root.appending(path: "component.tar.xz")+ let bytes = Data("local archive fixture".utf8)+ try bytes.write(to: archive)+ let sha = SHA256.hash(data: bytes).map { String(format: "%02x", $0) }.joined()+ var component = EngineManifest.Component(kind: "renderer", url: archive, sha256: sha.uppercased())+ let store = EngineStore(paths: HighballPaths(home: root.appending(path: "home")))+ let fetched = try await store.download(component, name: "local")+ guard fetched == archive else { throw HighballError.failed("Local component did not preserve its URL") }+ component.sha256 = String(repeating: "0", count: 64)+ do {+ _ = try await store.download(component, name: "local")+ throw HighballError.failed("Local component bypassed checksum validation")+ } catch HighballError.checksumMismatch { }+}++#if FRAMEGEN_STANDALONE+@main enum FrameGenerationChecks {+ static func main() async throws { try frameGenerationChecks(); try await localComponentChecks(); print("Frame generation integration checks passed") }+}+#else+import XCTest+final class FrameGenerationTests: XCTestCase {+ func testLaunchConfigurationAndRecovery() throws { try frameGenerationChecks() }+ func testLocalComponentChecksums() async throws { try await localComponentChecks() }+}+#endifdiff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex 1ea41e3..744a0a7 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -72,6 +72,7 @@ final class RegressionTests: XCTestCase {XCTAssertEqual(s.dpiScale, 96, "no dpi field on an old bottle must default to 96 (100%)")XCTAssertEqual(s.dllOverrides, "", "field added in 0.7.2 must default empty")XCTAssertEqual(s.fpsCap, 0)+ XCTAssertEqual(s.frameGen, 1, "frame generation added in 0.9.x must default to off")// That fixture predates formatVersion 2, so it exercises the migration below.XCTAssertEqual(s.dxvkAsync, false)XCTAssertEqual(s.pins.first?.arguments, [], "pin arguments default to empty")