From 3587bb2a5cd3727730a3891ad0e7b26a195b96e0 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 24 Oct 2024 17:27:04 +0200 Subject: [PATCH] DXR Support Toggle --- Whisky/Localizable.xcstrings | 22 +++++++++++++++++++ Whisky/Views/Bottle/ConfigView.swift | 9 ++++++++ .../WhiskyKit/Whisky/BottleSettings.swift | 21 +++++++++++++----- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Whisky/Localizable.xcstrings b/Whisky/Localizable.xcstrings index f51f9d15..6065826a 100644 --- a/Whisky/Localizable.xcstrings +++ b/Whisky/Localizable.xcstrings @@ -3558,6 +3558,28 @@ } } }, + "config.dxr" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "DirectX Raytracing" + } + } + } + }, + "config.dxr.info" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Enables raytracing support in DirectX 12 titles " + } + } + } + }, "config.dxvk" : { "localizations" : { "ar" : { diff --git a/Whisky/Views/Bottle/ConfigView.swift b/Whisky/Views/Bottle/ConfigView.swift index e08ee3a9..ca5bd801 100644 --- a/Whisky/Views/Bottle/ConfigView.swift +++ b/Whisky/Views/Bottle/ConfigView.swift @@ -141,6 +141,15 @@ struct ConfigView: View { Text("config.metalTrace") Text("config.metalTrace.info") } + if let device = MTLCreateSystemDefaultDevice() { + // Represents the Apple family 9 GPU features that correspond to the Apple A17, M3, and M4 GPUs. + if device.supportsFamily(.apple9) { + Toggle(isOn: $bottle.settings.dxrEnabled) { + Text("config.dxr") + Text("config.dxr.info") + } + } + } } } .formStyle(.grouped) diff --git a/WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift b/WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift index 7f8c0e29..e56aae79 100644 --- a/WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift +++ b/WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift @@ -104,6 +104,7 @@ public struct BottleWineConfig: Codable, Equatable { public struct BottleMetalConfig: Codable, Equatable { var metalHud: Bool = false var metalTrace: Bool = false + var dxrEnabled: Bool = false public init() {} @@ -111,6 +112,7 @@ public struct BottleMetalConfig: Codable, Equatable { let container = try decoder.container(keyedBy: CodingKeys.self) self.metalHud = try container.decodeIfPresent(Bool.self, forKey: .metalHud) ?? false self.metalTrace = try container.decodeIfPresent(Bool.self, forKey: .metalTrace) ?? false + self.dxrEnabled = try container.decodeIfPresent(Bool.self, forKey: .dxrEnabled) ?? false } } @@ -178,6 +180,11 @@ public struct BottleSettings: Codable, Equatable { set { wineConfig.windowsVersion = newValue } } + public var avxEnabled: Bool { + get { return wineConfig.avxEnabled } + set { wineConfig.avxEnabled = newValue } + } + /// The pinned programs on this bottle public var pins: [PinnedProgram] { get { return info.pins } @@ -205,6 +212,11 @@ public struct BottleSettings: Codable, Equatable { set { metalConfig.metalTrace = newValue } } + public var dxrEnabled: Bool { + get { return metalConfig.dxrEnabled } + set { metalConfig.dxrEnabled = newValue } + } + public var dxvk: Bool { get { return dxvkConfig.dxvk } set { dxvkConfig.dxvk = newValue } @@ -220,11 +232,6 @@ 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 { @@ -306,5 +313,9 @@ public struct BottleSettings: Codable, Equatable { if avxEnabled { wineEnv.updateValue("1", forKey: "ROSETTA_ADVERTISE_AVX") } + + if dxrEnabled { + wineEnv.updateValue("1", forKey: "D3DM_SUPPORT_DXR") + } } }