Check if extension is available and enable/disable field based on that and fix some typos

This commit is contained in:
sunshineinabox 2024-02-07 11:02:30 -08:00
parent 97743b6c81
commit d79f14128b
2 changed files with 52 additions and 14 deletions

View file

@ -2,6 +2,7 @@ using Avalonia.Collections;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Threading; using Avalonia.Threading;
using LibHac.Tools.FsSystem; using LibHac.Tools.FsSystem;
using OpenTK.Graphics.OpenGL;
using Ryujinx.Audio.Backends.OpenAL; using Ryujinx.Audio.Backends.OpenAL;
using Ryujinx.Audio.Backends.SDL2; using Ryujinx.Audio.Backends.SDL2;
using Ryujinx.Audio.Backends.SoundIo; using Ryujinx.Audio.Backends.SoundIo;
@ -25,6 +26,8 @@ using System.Linq;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using AntiAliasing = Ryujinx.Common.Configuration.AntiAliasing;
using ScalingFilter = Ryujinx.Common.Configuration.ScalingFilter;
using TimeZone = Ryujinx.Ava.UI.Models.TimeZone; using TimeZone = Ryujinx.Ava.UI.Models.TimeZone;
namespace Ryujinx.Ava.UI.ViewModels namespace Ryujinx.Ava.UI.ViewModels
@ -51,6 +54,7 @@ namespace Ryujinx.Ava.UI.ViewModels
private int _shadinglanguageBackendIndex; private int _shadinglanguageBackendIndex;
private int _scalingFilter; private int _scalingFilter;
private int _scalingFilterLevel; private int _scalingFilterLevel;
private bool? _isSpirVAvailableCache;
public event Action CloseWindow; public event Action CloseWindow;
public event Action SaveSettingsEvent; public event Action SaveSettingsEvent;
@ -165,7 +169,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool IsVulkanSelected => GraphicsBackendIndex == 0; public bool IsVulkanSelected => GraphicsBackendIndex == 0;
public bool IsOGSpirVAvialble => true; private bool? _isSpirVAvailable;
public bool UseHypervisor { get; set; } public bool UseHypervisor { get; set; }
public string TimeZone { get; set; } public string TimeZone { get; set; }
@ -200,11 +204,12 @@ namespace Ryujinx.Ava.UI.ViewModels
_graphicsBackendIndex = value; _graphicsBackendIndex = value;
OnPropertyChanged(); OnPropertyChanged();
OnPropertyChanged(nameof(IsVulkanSelected)); OnPropertyChanged(nameof(IsVulkanSelected));
Task.Run(NoGlslVulkan); Task.Run(ShadingLanguageAvailable);
OnPropertyChanged(nameof(IsSpirVAvailable));
} }
} }
public int ShadingLangugeIndex public int ShadingLanguageIndex
{ {
get => _shadinglanguageBackendIndex; get => _shadinglanguageBackendIndex;
set set
@ -214,6 +219,16 @@ namespace Ryujinx.Ava.UI.ViewModels
} }
} }
public bool? IsSpirVAvailable
{
get => _isSpirVAvailable;
set
{
_isSpirVAvailable = value;
OnPropertyChanged();
}
}
public int ScalingFilter public int ScalingFilter
{ {
get => _scalingFilter; get => _scalingFilter;
@ -306,6 +321,7 @@ namespace Ryujinx.Ava.UI.ViewModels
_validTzRegions = new List<string>(); _validTzRegions = new List<string>();
_networkInterfaces = new Dictionary<string, string>(); _networkInterfaces = new Dictionary<string, string>();
Task.Run(ShadingLanguageAvailable);
Task.Run(CheckSoundBackends); Task.Run(CheckSoundBackends);
Task.Run(PopulateNetworkInterfaces); Task.Run(PopulateNetworkInterfaces);
@ -330,21 +346,43 @@ namespace Ryujinx.Ava.UI.ViewModels
}); });
} }
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; _shadinglanguageBackendIndex = 0;
ShadingLangugeIndex = 0; ShadingLanguageIndex = 0;
} }
await Dispatcher.UIThread.InvokeAsync(() => await Dispatcher.UIThread.InvokeAsync(() =>
{ {
OnPropertyChanged(nameof(ShadingLangugeIndex)); OnPropertyChanged(nameof(ShadingLanguageIndex));
OnPropertyChanged(nameof(IsSpirVAvailable));
}); });
} }
private async Task LoadAvailableGpus() private async Task LoadAvailableGpus()
{ {
AvailableGpus.Clear(); AvailableGpus.Clear();
@ -355,7 +393,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
IsVulkanAvailable = false; IsVulkanAvailable = false;
GraphicsBackendIndex = 1; GraphicsBackendIndex = 1;
ShadingLangugeIndex = 1; ShadingLanguageIndex = 1;
} }
else else
{ {
@ -473,7 +511,7 @@ namespace Ryujinx.Ava.UI.ViewModels
// Graphics // Graphics
GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value; 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(). // Physical devices are queried asynchronously hence the prefered index config value is loaded in LoadAvailableGpus().
EnableShaderCache = config.Graphics.EnableShaderCache; EnableShaderCache = config.Graphics.EnableShaderCache;
EnableTextureRecompression = config.Graphics.EnableTextureRecompression; EnableTextureRecompression = config.Graphics.EnableTextureRecompression;
@ -561,7 +599,7 @@ namespace Ryujinx.Ava.UI.ViewModels
// Graphics // Graphics
config.Graphics.GraphicsBackend.Value = (GraphicsBackend)GraphicsBackendIndex; 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.PreferredGpu.Value = _gpuIds.ElementAtOrDefault(PreferredGpuIndex);
config.Graphics.EnableShaderCache.Value = EnableShaderCache; config.Graphics.EnableShaderCache.Value = EnableShaderCache;
config.Graphics.EnableTextureRecompression.Value = EnableTextureRecompression; config.Graphics.EnableTextureRecompression.Value = EnableTextureRecompression;

View file

@ -64,9 +64,9 @@
<ComboBox Width="350" <ComboBox Width="350"
HorizontalContentAlignment="Left" HorizontalContentAlignment="Left"
ToolTip.Tip="{locale:Locale ShadingLanguageTooltip}" ToolTip.Tip="{locale:Locale ShadingLanguageTooltip}"
SelectedIndex="{Binding ShadingLangugeIndex}" SelectedIndex="{Binding ShadingLanguageIndex}"
AutoScrollToSelectedItem="True"> AutoScrollToSelectedItem="True">
<ComboBoxItem IsEnabled="{Binding IsOGSpirVAvialble}"> <ComboBoxItem IsEnabled="{Binding IsSpirVAvailable}">
<TextBlock Text="SPIR-V" /> <TextBlock Text="SPIR-V" />
</ComboBoxItem> </ComboBoxItem>
<ComboBoxItem IsEnabled="{Binding !IsVulkanSelected}"> <ComboBoxItem IsEnabled="{Binding !IsVulkanSelected}">