Skip to content

Commit

Permalink
feat: avx feature switch (#1034)
Browse files Browse the repository at this point in the history
* feat: avx feature switch

* fix: gate avx behind macOS 15

* fix: add warning about emulation performance impact

* fix: align texts (i have ocd)

* fix: change English verbiage for AVX

* fix: shorten English warning for AVX

* Tweaks

---------

Co-authored-by: Isaac Marovitz <[email protected]>
  • Loading branch information
ohaiibuzzle and IsaacMarovitz authored Oct 24, 2024
1 parent 84c7be4 commit c500441
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Whisky/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -3130,6 +3130,26 @@
}
}
},
"config.avx" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Advertise AVX Support"
}
}
}
},
"config.avx.warning" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "May negatively impact performance"
}
}
}
},
"config.buildVersion" : {
"localizations" : {
"ar" : {
Expand Down
17 changes: 17 additions & 0 deletions Whisky/Views/Bottle/ConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ struct ConfigView: View {
)
}
}
if #available(macOS 15, *) {
Toggle(isOn: $bottle.settings.avxEnabled) {
VStack(alignment: .leading) {
Text("config.avx")
if bottle.settings.avxEnabled {
HStack(alignment: .firstTextBaseline) {
Image(systemName: "exclamationmark.triangle.fill")
.symbolRenderingMode(.multicolor)
.font(.subheadline)
Text("config.avx.warning")
.fontWeight(.light)
.font(.subheadline)
}
}
}
}
}
}
Section("config.title.dxvk", isExpanded: $dxvkSectionExpanded) {
Toggle(isOn: $bottle.settings.dxvk) {
Expand Down
11 changes: 11 additions & 0 deletions WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public struct BottleWineConfig: Codable, Equatable {
var wineVersion: SemanticVersion = Self.defaultWineVersion
var windowsVersion: WinVersion = .win10
var enhancedSync: EnhancedSync = .msync
var avxEnabled: Bool = false

public init() {}

Expand All @@ -95,6 +96,7 @@ public struct BottleWineConfig: Codable, Equatable {
self.wineVersion = try container.decodeIfPresent(SemanticVersion.self, forKey: .wineVersion) ?? Self.defaultWineVersion
self.windowsVersion = try container.decodeIfPresent(WinVersion.self, forKey: .windowsVersion) ?? .win10
self.enhancedSync = try container.decodeIfPresent(EnhancedSync.self, forKey: .enhancedSync) ?? .msync
self.avxEnabled = try container.decodeIfPresent(Bool.self, forKey: .avxEnabled) ?? false
}
// swiftlint:enable line_length
}
Expand Down Expand Up @@ -218,6 +220,11 @@ public struct BottleSettings: Codable, Equatable {
set { dxvkConfig.dxvkHud = newValue }
}

public var avxEnabled: Bool {
get { return wineConfig.avxEnabled }
set { wineConfig.avxEnabled = newValue }
}

@discardableResult
public static func decode(from metadataURL: URL) throws -> BottleSettings {
guard FileManager.default.fileExists(atPath: metadataURL.path(percentEncoded: false)) else {
Expand Down Expand Up @@ -295,5 +302,9 @@ public struct BottleSettings: Codable, Equatable {
if metalTrace {
wineEnv.updateValue("1", forKey: "METAL_CAPTURE_ENABLED")
}

if avxEnabled {
wineEnv.updateValue("1", forKey: "ROSETTA_ADVERTISE_AVX")
}
}
}

0 comments on commit c500441

Please sign in to comment.