From 811c2651f2a48d100cf94aab5d5999253ad1fe0a Mon Sep 17 00:00:00 2001 From: MutantAura Date: Thu, 25 Apr 2024 18:00:49 +0100 Subject: [PATCH] Keep OGL threading specific path and adjust warning to info log. --- .../GraphicsDriver/DriverUtilities.cs | 16 +++++++++------- src/Ryujinx.Gtk3/Program.cs | 2 +- src/Ryujinx.Gtk3/UI/Windows/SettingsWindow.cs | 2 +- src/Ryujinx/Program.cs | 2 +- src/Ryujinx/UI/ViewModels/SettingsViewModel.cs | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Ryujinx.Common/GraphicsDriver/DriverUtilities.cs b/src/Ryujinx.Common/GraphicsDriver/DriverUtilities.cs index 7e2598c25..3caa823dc 100644 --- a/src/Ryujinx.Common/GraphicsDriver/DriverUtilities.cs +++ b/src/Ryujinx.Common/GraphicsDriver/DriverUtilities.cs @@ -6,21 +6,23 @@ namespace Ryujinx.Common.GraphicsDriver { public static class DriverUtilities { + public static void ToggleOglThreading(bool enabled) + { + Environment.SetEnvironmentVariable("mesa_glthread", enabled.ToString().ToLower()); + Environment.SetEnvironmentVariable("__GL_THREADED_OPTIMIZATIONS", enabled ? "1" : "0"); + + ToggleNvDriverSetting(NvapiSettingId.OglThreadControlId, enabled); + } + public static void ToggleNvDriverSetting(NvapiSettingId id, bool enabled) { try { - if (id == NvapiSettingId.OglThreadControlId) - { - Environment.SetEnvironmentVariable("mesa_glthread", enabled.ToString().ToLower()); - Environment.SetEnvironmentVariable("__GL_THREADED_OPTIMIZATIONS", enabled ? "1" : "0"); - } - NVDriverHelper.SetControlOption(id, enabled); } catch { - Logger.Warning?.Print(LogClass.Application, "Failed to set NVIDIA driver settings. NVAPI may be unavailable."); + Logger.Info?.Print(LogClass.Application, "NVAPI was unreachable, no changes were made."); } } } diff --git a/src/Ryujinx.Gtk3/Program.cs b/src/Ryujinx.Gtk3/Program.cs index 4dd170a3d..bd3fa4366 100644 --- a/src/Ryujinx.Gtk3/Program.cs +++ b/src/Ryujinx.Gtk3/Program.cs @@ -236,7 +236,7 @@ namespace Ryujinx // Enable OGL multithreading on the driver, when available. BackendThreading threadingMode = ConfigurationState.Instance.Graphics.BackendThreading; - DriverUtilities.ToggleNvDriverSetting(NvapiSettingId.OglThreadControlId, threadingMode == BackendThreading.Off); + DriverUtilities.ToggleOglThreading(threadingMode == BackendThreading.Off); // Enable DXGI present mode on the driver, when available. DriverUtilities.ToggleNvDriverSetting(NvapiSettingId.OglCplPreferDxPresentId, true); diff --git a/src/Ryujinx.Gtk3/UI/Windows/SettingsWindow.cs b/src/Ryujinx.Gtk3/UI/Windows/SettingsWindow.cs index 876c6b904..aeb33d6fd 100644 --- a/src/Ryujinx.Gtk3/UI/Windows/SettingsWindow.cs +++ b/src/Ryujinx.Gtk3/UI/Windows/SettingsWindow.cs @@ -611,7 +611,7 @@ namespace Ryujinx.UI.Windows BackendThreading backendThreading = Enum.Parse(_galThreading.ActiveId); if (ConfigurationState.Instance.Graphics.BackendThreading != backendThreading) { - DriverUtilities.ToggleNvDriverSetting(NvapiSettingId.OglThreadControlId, backendThreading == BackendThreading.Off); + DriverUtilities.ToggleOglThreading(backendThreading == BackendThreading.Off); } ConfigurationState.Instance.Logger.EnableError.Value = _errorLogToggle.Active; diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index 3ba2e87d4..5e1193426 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -113,7 +113,7 @@ namespace Ryujinx.Ava PrintSystemInfo(); // Enable OGL multithreading on the driver, when available. - DriverUtilities.ToggleNvDriverSetting(NvapiSettingId.OglThreadControlId, ConfigurationState.Instance.Graphics.BackendThreading == BackendThreading.Off); + DriverUtilities.ToggleOglThreading(ConfigurationState.Instance.Graphics.BackendThreading == BackendThreading.Off); // Enable Dxgi present on the driver, when available. DriverUtilities.ToggleNvDriverSetting(NvapiSettingId.OglCplPreferDxPresentId, true); diff --git a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs index 857483772..667de1940 100644 --- a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs @@ -530,7 +530,7 @@ namespace Ryujinx.Ava.UI.ViewModels if (ConfigurationState.Instance.Graphics.BackendThreading != (BackendThreading)GraphicsBackendMultithreadingIndex) { - DriverUtilities.ToggleNvDriverSetting(NvapiSettingId.OglThreadControlId, GraphicsBackendMultithreadingIndex == (int)BackendThreading.Off); + DriverUtilities.ToggleOglThreading(GraphicsBackendMultithreadingIndex == (int)BackendThreading.Off); } config.Graphics.BackendThreading.Value = (BackendThreading)GraphicsBackendMultithreadingIndex;