From d79f14128b99367abb24dfde635aa44e96c67066 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Wed, 7 Feb 2024 11:02:30 -0800 Subject: [PATCH] Check if extension is available and enable/disable field based on that and fix some typos --- .../UI/ViewModels/SettingsViewModel.cs | 62 +++++++++++++++---- .../Views/Settings/SettingsGraphicsView.axaml | 4 +- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs index c566068c4..30aad33db 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs @@ -2,6 +2,7 @@ using Avalonia.Collections; using Avalonia.Controls; using Avalonia.Threading; using LibHac.Tools.FsSystem; +using OpenTK.Graphics.OpenGL; using Ryujinx.Audio.Backends.OpenAL; using Ryujinx.Audio.Backends.SDL2; using Ryujinx.Audio.Backends.SoundIo; @@ -25,6 +26,8 @@ using System.Linq; using System.Net.NetworkInformation; using System.Runtime.InteropServices; using System.Threading.Tasks; +using AntiAliasing = Ryujinx.Common.Configuration.AntiAliasing; +using ScalingFilter = Ryujinx.Common.Configuration.ScalingFilter; using TimeZone = Ryujinx.Ava.UI.Models.TimeZone; namespace Ryujinx.Ava.UI.ViewModels @@ -51,6 +54,7 @@ namespace Ryujinx.Ava.UI.ViewModels private int _shadinglanguageBackendIndex; private int _scalingFilter; private int _scalingFilterLevel; + private bool? _isSpirVAvailableCache; public event Action CloseWindow; public event Action SaveSettingsEvent; @@ -165,7 +169,7 @@ namespace Ryujinx.Ava.UI.ViewModels public bool IsVulkanSelected => GraphicsBackendIndex == 0; - public bool IsOGSpirVAvialble => true; + private bool? _isSpirVAvailable; public bool UseHypervisor { get; set; } public string TimeZone { get; set; } @@ -200,11 +204,12 @@ namespace Ryujinx.Ava.UI.ViewModels _graphicsBackendIndex = value; OnPropertyChanged(); OnPropertyChanged(nameof(IsVulkanSelected)); - Task.Run(NoGlslVulkan); + Task.Run(ShadingLanguageAvailable); + OnPropertyChanged(nameof(IsSpirVAvailable)); } } - public int ShadingLangugeIndex + public int ShadingLanguageIndex { get => _shadinglanguageBackendIndex; set @@ -213,6 +218,16 @@ namespace Ryujinx.Ava.UI.ViewModels OnPropertyChanged(); } } + + public bool? IsSpirVAvailable + { + get => _isSpirVAvailable; + set + { + _isSpirVAvailable = value; + OnPropertyChanged(); + } + } public int ScalingFilter { @@ -306,6 +321,7 @@ namespace Ryujinx.Ava.UI.ViewModels _validTzRegions = new List(); _networkInterfaces = new Dictionary(); + Task.Run(ShadingLanguageAvailable); Task.Run(CheckSoundBackends); Task.Run(PopulateNetworkInterfaces); @@ -329,22 +345,44 @@ namespace Ryujinx.Ava.UI.ViewModels OnPropertyChanged(nameof(IsSDL2Enabled)); }); } - - private async Task NoGlslVulkan() + + private async Task ShadingLanguageAvailable() { - if (IsVulkanSelected & ShadingLangugeIndex == 1 || IsVulkanSelected & _shadinglanguageBackendIndex == 1) + if (GraphicsBackendIndex != 0) + { + if (!_isSpirVAvailableCache.HasValue) + { + _isSpirVAvailableCache = GL.GetString(StringName.Extensions).Contains("GL_ARB_gl_spirv"); + IsSpirVAvailable = _isSpirVAvailableCache.Value; + } + else + { + IsSpirVAvailable = _isSpirVAvailableCache.Value; + } + } + else + { + IsSpirVAvailable = true; + } + + if (!IsSpirVAvailable.Value) + { + _shadinglanguageBackendIndex = 1; + ShadingLanguageIndex = 1; + } + else if (ShadingLanguageIndex == 1 || _shadinglanguageBackendIndex == 1) { _shadinglanguageBackendIndex = 0; - ShadingLangugeIndex = 0; + ShadingLanguageIndex = 0; } await Dispatcher.UIThread.InvokeAsync(() => { - OnPropertyChanged(nameof(ShadingLangugeIndex)); + OnPropertyChanged(nameof(ShadingLanguageIndex)); + OnPropertyChanged(nameof(IsSpirVAvailable)); }); } - private async Task LoadAvailableGpus() { AvailableGpus.Clear(); @@ -355,7 +393,7 @@ namespace Ryujinx.Ava.UI.ViewModels { IsVulkanAvailable = false; GraphicsBackendIndex = 1; - ShadingLangugeIndex = 1; + ShadingLanguageIndex = 1; } else { @@ -473,7 +511,7 @@ namespace Ryujinx.Ava.UI.ViewModels // Graphics GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value; - ShadingLangugeIndex = (int)config.Graphics.ShadingLanguage.Value; + ShadingLanguageIndex = (int)config.Graphics.ShadingLanguage.Value; // Physical devices are queried asynchronously hence the prefered index config value is loaded in LoadAvailableGpus(). EnableShaderCache = config.Graphics.EnableShaderCache; EnableTextureRecompression = config.Graphics.EnableTextureRecompression; @@ -561,7 +599,7 @@ namespace Ryujinx.Ava.UI.ViewModels // Graphics config.Graphics.GraphicsBackend.Value = (GraphicsBackend)GraphicsBackendIndex; - config.Graphics.ShadingLanguage.Value = (ShadingLanguage)ShadingLangugeIndex; + config.Graphics.ShadingLanguage.Value = (ShadingLanguage)ShadingLanguageIndex; config.Graphics.PreferredGpu.Value = _gpuIds.ElementAtOrDefault(PreferredGpuIndex); config.Graphics.EnableShaderCache.Value = EnableShaderCache; config.Graphics.EnableTextureRecompression.Value = EnableTextureRecompression; diff --git a/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml b/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml index 40d8a081d..6c706c511 100644 --- a/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml +++ b/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml @@ -64,9 +64,9 @@ - +