From 51626cd346289ef4f43776ca76d41ff8747dda58 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Mon, 14 Aug 2023 14:28:19 -0700 Subject: [PATCH] Rework check fix --- .../UI/ViewModels/SettingsViewModel.cs | 10 ++----- .../Views/Settings/SettingsGraphicsView.axaml | 2 +- .../Shader/ShaderCache.cs | 26 ++++++++++++++++++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs index ff606f331..45b118501 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs @@ -215,17 +215,11 @@ namespace Ryujinx.Ava.UI.ViewModels _graphicsBackendIndex = value; OnPropertyChanged(); OnPropertyChanged(nameof(IsVulkanSelected)); - OnPropertyChanged(nameof(IsSpirVAvailable)); + OnPropertyChanged(nameof(IsOpenGLSelected)); } } - public bool SpirVCapability() - { - bool isSpirVSupported = HwCapabilitiesFacade.SupportsSpirV; - return isSpirVSupported; - } - - public bool IsSpirVAvailable => !IsVulkanSelected && SpirVCapability(); + public bool IsOpenGLSelected => !IsVulkanSelected; public int ScalingFilter { diff --git a/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml b/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml index 42d29948d..1e3bb4ba4 100644 --- a/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml +++ b/src/Ryujinx.Ava/UI/Views/Settings/SettingsGraphicsView.axaml @@ -64,7 +64,7 @@ ToolTip.Tip="{locale:Locale ShaderCacheToggleTooltip}"> - diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index d2a06ac0e..bd72ca1cc 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -78,6 +78,7 @@ namespace Ryujinx.Graphics.Gpu.Shader private readonly ShaderCacheHashTable _graphicsShaderCache; private readonly DiskCacheHostStorage _diskCacheHostStorage; private readonly BackgroundDiskCacheWriter _cacheWriter; + private static bool _isSpirVCapable; /// /// Event for signalling shader cache loading progress. @@ -101,6 +102,8 @@ namespace Ryujinx.Graphics.Gpu.Shader string diskCacheTitleId = GetDiskCachePath(); + _isSpirVCapable = OpenGlSpirVCapable(); + _computeShaderCache = new ComputeShaderCacheHashTable(); _graphicsShaderCache = new ShaderCacheHashTable(); _diskCacheHostStorage = new DiskCacheHostStorage(diskCacheTitleId); @@ -718,6 +721,27 @@ namespace Ryujinx.Graphics.Gpu.Shader }; } + + /// + /// Checks if SpirV is available on OpenGL + /// + /// + /// True or false + /// + private bool OpenGlSpirVCapable() + { + bool spirV = _context.Capabilities.SupportsSpirV; + if (!spirV) + { + Logger.Warning?.PrintMsg(LogClass.Gpu, $"Spir-V Not Available on OpenGL for your GPU"); + } + else + { + Logger.Warning?.PrintMsg(LogClass.Gpu, $"Spir-V !Available! on OpenGL for your GPU"); + } + return spirV; + } + /// /// Creates shader translation options with the requested graphics API and flags. /// The shader language is choosen based on the current configuration and graphics API. @@ -727,7 +751,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// Translation options private static TranslationOptions CreateTranslationOptions(TargetApi api, TranslationFlags flags) { - TargetLanguage lang = (GraphicsConfig.EnableSpirvCompilationOnVulkan && api == TargetApi.Vulkan) || (GraphicsConfig.EnableOGLSpirV && api == TargetApi.OpenGL) + TargetLanguage lang = (GraphicsConfig.EnableSpirvCompilationOnVulkan && api == TargetApi.Vulkan) || (GraphicsConfig.EnableOGLSpirV && _isSpirVCapable) ? TargetLanguage.Spirv : TargetLanguage.Glsl;