From ef9f05bdbc1577be838629aa23c74afa02a5cff2 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Mon, 14 Aug 2023 12:16:14 -0700 Subject: [PATCH] Checkbox to Enable not conditional yet --- src/Ryujinx.Ava/Assets/Locales/en_US.json | 4 +++- .../UI/ViewModels/SettingsViewModel.cs | 7 ++++++ .../Views/Settings/SettingsGraphicsView.axaml | 6 ++++- .../UI/Windows/MainWindow.axaml.cs | 1 + src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs | 5 +++++ .../Shader/ShaderCache.cs | 2 +- .../Configuration/ConfigurationFileFormat.cs | 5 +++++ .../Configuration/ConfigurationState.cs | 19 ++++++++++++++++ src/Ryujinx/Ui/MainWindow.cs | 1 + src/Ryujinx/Ui/Windows/SettingsWindow.cs | 7 ++++++ src/Ryujinx/Ui/Windows/SettingsWindow.glade | 22 +++++++++++++++++-- 11 files changed, 74 insertions(+), 5 deletions(-) diff --git a/src/Ryujinx.Ava/Assets/Locales/en_US.json b/src/Ryujinx.Ava/Assets/Locales/en_US.json index efd3187ad..d547f9162 100644 --- a/src/Ryujinx.Ava/Assets/Locales/en_US.json +++ b/src/Ryujinx.Ava/Assets/Locales/en_US.json @@ -139,6 +139,7 @@ "SettingsTabGraphics": "Graphics", "SettingsTabGraphicsAPI": "Graphics API", "SettingsTabGraphicsEnableShaderCache": "Enable Shader Cache", + "SettingsTabGraphicsEnableOGLSpirV": "Enable Spir-V Shaders on OpenGL", "SettingsTabGraphicsAnisotropicFiltering": "Anisotropic Filtering:", "SettingsTabGraphicsAnisotropicFilteringAuto": "Auto", "SettingsTabGraphicsAnisotropicFiltering2x": "2x", @@ -467,6 +468,7 @@ "GraphicsBackendThreadingTooltip": "Executes graphics backend commands on a second thread.\n\nSpeeds up shader compilation, reduces stuttering, and improves performance on GPU drivers without multithreading support of their own. Slightly better performance on drivers with multithreading.\n\nSet to AUTO if unsure.", "GalThreadingTooltip": "Executes graphics backend commands on a second thread.\n\nSpeeds up shader compilation, reduces stuttering, and improves performance on GPU drivers without multithreading support of their own. Slightly better performance on drivers with multithreading.\n\nSet to AUTO if unsure.", "ShaderCacheToggleTooltip": "Saves a disk shader cache which reduces stuttering in subsequent runs.\n\nLeave ON if unsure.", + "OGLSpirVTooltip": "Saves shaders as Spir-V.\n\nLeave OFF if unsure.", "ResolutionScaleTooltip": "Resolution Scale applied to applicable render targets", "ResolutionScaleEntryTooltip": "Floating point resolution scale, such as 1.5. Non-integral scales are more likely to cause issues or crash.", "AnisotropyTooltip": "Level of Anisotropic Filtering (set to Auto to use the value requested by the game)", @@ -653,4 +655,4 @@ "PackagingShaders": "Packaging Shaders", "AboutChangelogButton": "View Changelog on GitHub", "AboutChangelogButtonTooltipMessage": "Click to open the changelog for this version in your default browser." -} \ No newline at end of file +} diff --git a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs index 441c669d4..ad6901008 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs @@ -143,6 +143,7 @@ namespace Ryujinx.Ava.UI.ViewModels public bool IgnoreMissingServices { get; set; } public bool ExpandDramSize { get; set; } public bool EnableShaderCache { get; set; } + public bool EnableOGLSpirV { get; set; } public bool EnableTextureRecompression { get; set; } public bool EnableMacroHLE { get; set; } public bool EnableColorSpacePassthrough { get; set; } @@ -211,8 +212,12 @@ namespace Ryujinx.Ava.UI.ViewModels _graphicsBackendIndex = value; OnPropertyChanged(); OnPropertyChanged(nameof(IsVulkanSelected)); + OnPropertyChanged(nameof(IsOGLSelected)); } } + + public bool IsOGLSelected => !IsVulkanSelected; + public int ScalingFilter { get => _scalingFilter; @@ -445,6 +450,7 @@ namespace Ryujinx.Ava.UI.ViewModels GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value; // Physical devices are queried asynchronously hence the prefered index config value is loaded in LoadAvailableGpus(). EnableShaderCache = config.Graphics.EnableShaderCache; + EnableOGLSpirV = config.Graphics.EnableOGLSpirV; EnableTextureRecompression = config.Graphics.EnableTextureRecompression; EnableMacroHLE = config.Graphics.EnableMacroHLE; EnableColorSpacePassthrough = config.Graphics.EnableColorSpacePassthrough; @@ -532,6 +538,7 @@ namespace Ryujinx.Ava.UI.ViewModels config.Graphics.GraphicsBackend.Value = (GraphicsBackend)GraphicsBackendIndex; config.Graphics.PreferredGpu.Value = _gpuIds.ElementAtOrDefault(PreferredGpuIndex); config.Graphics.EnableShaderCache.Value = EnableShaderCache; + config.Graphics.EnableOGLSpirV.Value = EnableOGLSpirV; config.Graphics.EnableTextureRecompression.Value = EnableTextureRecompression; config.Graphics.EnableMacroHLE.Value = EnableMacroHLE; config.Graphics.EnableColorSpacePassthrough.Value = EnableColorSpacePassthrough; diff --git a/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml b/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml index 9dc67dadb..36e976f54 100644 --- a/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml +++ b/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml @@ -64,6 +64,10 @@ ToolTip.Tip="{locale:Locale ShaderCacheToggleTooltip}"> + + + @@ -296,4 +300,4 @@ - \ No newline at end of file + diff --git a/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs b/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs index d32360e07..b7aa0dcaf 100644 --- a/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs +++ b/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml.cs @@ -435,6 +435,7 @@ namespace Ryujinx.Ava.UI.Windows GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy; GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath; GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache; + GraphicsConfig.EnableOGLSpirV = ConfigurationState.Instance.Graphics.EnableOGLSpirV; GraphicsConfig.EnableTextureRecompression = ConfigurationState.Instance.Graphics.EnableTextureRecompression; GraphicsConfig.EnableMacroHLE = ConfigurationState.Instance.Graphics.EnableMacroHLE; #pragma warning restore IDE0055 diff --git a/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs b/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs index fbb7399ca..f6d24b558 100644 --- a/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs +++ b/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs @@ -57,6 +57,11 @@ namespace Ryujinx.Graphics.Gpu /// Enables or disables the shader cache. /// public static bool EnableShaderCache; + + /// + /// Enables or disables color space passthrough, if available. + /// + public static bool EnableOGLSpirV = false; /// /// Enables or disables shader SPIR-V compilation. diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index 97d7a7206..d2a06ac0e 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -727,7 +727,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// Translation options private static TranslationOptions CreateTranslationOptions(TargetApi api, TranslationFlags flags) { - TargetLanguage lang = GraphicsConfig.EnableSpirvCompilationOnVulkan && api == TargetApi.Vulkan + TargetLanguage lang = (GraphicsConfig.EnableSpirvCompilationOnVulkan && api == TargetApi.Vulkan) || (GraphicsConfig.EnableOGLSpirV && api == TargetApi.OpenGL) ? TargetLanguage.Spirv : TargetLanguage.Glsl; diff --git a/src/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs b/src/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs index 09e7f570a..aa4af958f 100644 --- a/src/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs +++ b/src/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs @@ -175,6 +175,11 @@ namespace Ryujinx.Ui.Common.Configuration /// Enables or disables Shader cache /// public bool EnableShaderCache { get; set; } + + /// + /// Enables or disables Spir-V Shaders on OpenGL + /// + public bool EnableOGLSpirV { get; set; } /// /// Enables or disables texture recompression diff --git a/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs index ee898354b..cd4edde4d 100644 --- a/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs +++ b/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs @@ -474,6 +474,11 @@ namespace Ryujinx.Ui.Common.Configuration /// Enables or disables Shader cache /// public ReactiveObject EnableShaderCache { get; private set; } + + /// + /// Enables or disables Spir-V Shaders on OpenGL + /// + public ReactiveObject EnableOGLSpirV { get; private set; } /// /// Enables or disables texture recompression @@ -532,6 +537,8 @@ namespace Ryujinx.Ui.Common.Configuration EnableVsync.Event += static (sender, e) => LogValueChange(e, nameof(EnableVsync)); EnableShaderCache = new ReactiveObject(); EnableShaderCache.Event += static (sender, e) => LogValueChange(e, nameof(EnableShaderCache)); + EnableOGLSpirV = new ReactiveObject(); + EnableOGLSpirV.Event += static (sender, e) => LogValueChange(e, nameof(EnableOGLSpirV)); EnableTextureRecompression = new ReactiveObject(); EnableTextureRecompression.Event += static (sender, e) => LogValueChange(e, nameof(EnableTextureRecompression)); GraphicsBackend = new ReactiveObject(); @@ -672,6 +679,7 @@ namespace Ryujinx.Ui.Common.Configuration HideCursor = HideCursor, EnableVsync = Graphics.EnableVsync, EnableShaderCache = Graphics.EnableShaderCache, + EnableOGLSpirV = Graphics.EnableOGLSpirV, EnableTextureRecompression = Graphics.EnableTextureRecompression, EnableMacroHLE = Graphics.EnableMacroHLE, EnableColorSpacePassthrough = Graphics.EnableColorSpacePassthrough, @@ -778,6 +786,7 @@ namespace Ryujinx.Ui.Common.Configuration HideCursor.Value = HideCursorMode.Never; Graphics.EnableVsync.Value = true; Graphics.EnableShaderCache.Value = true; + Graphics.EnableOGLSpirV.Value = false; Graphics.EnableTextureRecompression.Value = false; Graphics.EnableMacroHLE.Value = true; Graphics.EnableColorSpacePassthrough.Value = false; @@ -1408,6 +1417,15 @@ namespace Ryujinx.Ui.Common.Configuration configurationFileUpdated = true; } + + if (configurationFileFormat.Version < 49) + { + Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 48."); + + configurationFileFormat.EnableOGLSpirV = false; + + configurationFileUpdated = true; + } Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog; Graphics.ResScale.Value = configurationFileFormat.ResScale; @@ -1442,6 +1460,7 @@ namespace Ryujinx.Ui.Common.Configuration HideCursor.Value = configurationFileFormat.HideCursor; Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync; Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache; + Graphics.EnableOGLSpirV.Value = configurationFileFormat.EnableOGLSpirV; Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression; Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE; Graphics.EnableColorSpacePassthrough.Value = configurationFileFormat.EnableColorSpacePassthrough; diff --git a/src/Ryujinx/Ui/MainWindow.cs b/src/Ryujinx/Ui/MainWindow.cs index 8f562a83b..5182dfcf8 100644 --- a/src/Ryujinx/Ui/MainWindow.cs +++ b/src/Ryujinx/Ui/MainWindow.cs @@ -1096,6 +1096,7 @@ namespace Ryujinx.Ui Graphics.Gpu.GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy; Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath; Graphics.Gpu.GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache; + Graphics.Gpu.GraphicsConfig.EnableOGLSpirV = ConfigurationState.Instance.Graphics.EnableOGLSpirV; Graphics.Gpu.GraphicsConfig.EnableTextureRecompression = ConfigurationState.Instance.Graphics.EnableTextureRecompression; Graphics.Gpu.GraphicsConfig.EnableMacroHLE = ConfigurationState.Instance.Graphics.EnableMacroHLE; } diff --git a/src/Ryujinx/Ui/Windows/SettingsWindow.cs b/src/Ryujinx/Ui/Windows/SettingsWindow.cs index b9f1a90a3..5d2503a77 100644 --- a/src/Ryujinx/Ui/Windows/SettingsWindow.cs +++ b/src/Ryujinx/Ui/Windows/SettingsWindow.cs @@ -56,6 +56,7 @@ namespace Ryujinx.Ui.Windows [GUI] RadioButton _hideCursorAlways; [GUI] CheckButton _vSyncToggle; [GUI] CheckButton _shaderCacheToggle; + [GUI] CheckButton _enableOGLSpirV; [GUI] CheckButton _textureRecompressionToggle; [GUI] CheckButton _macroHLEToggle; [GUI] CheckButton _ptcToggle; @@ -249,6 +250,11 @@ namespace Ryujinx.Ui.Windows { _shaderCacheToggle.Click(); } + + if (ConfigurationState.Instance.Graphics.EnableOGLSpirV) + { + _enableOGLSpirV.Click(); + } if (ConfigurationState.Instance.Graphics.EnableTextureRecompression) { @@ -626,6 +632,7 @@ namespace Ryujinx.Ui.Windows ConfigurationState.Instance.HideCursor.Value = hideCursor; ConfigurationState.Instance.Graphics.EnableVsync.Value = _vSyncToggle.Active; ConfigurationState.Instance.Graphics.EnableShaderCache.Value = _shaderCacheToggle.Active; + ConfigurationState.Instance.Graphics.EnableOGLSpirV.Value = _enableOGLSpirV.Active; ConfigurationState.Instance.Graphics.EnableTextureRecompression.Value = _textureRecompressionToggle.Active; ConfigurationState.Instance.Graphics.EnableMacroHLE.Value = _macroHLEToggle.Active; ConfigurationState.Instance.System.EnablePtc.Value = _ptcToggle.Active; diff --git a/src/Ryujinx/Ui/Windows/SettingsWindow.glade b/src/Ryujinx/Ui/Windows/SettingsWindow.glade index 0caa477bd..6ae0adc5a 100644 --- a/src/Ryujinx/Ui/Windows/SettingsWindow.glade +++ b/src/Ryujinx/Ui/Windows/SettingsWindow.glade @@ -2122,6 +2122,24 @@ 0 + + + Enable Spir-V Shader in OpenGL + True + True + False + Uses shaders in Spir-V format. Leave OFF if unsure. + start + 5 + 5 + True + + + False + True + 1 + + Enable Texture Recompression @@ -2137,7 +2155,7 @@ False True - 1 + 2 @@ -2155,7 +2173,7 @@ False True - 2 + 3