Rework check fix

This commit is contained in:
sunshineinabox 2023-08-14 14:28:19 -07:00
parent 1e50368a30
commit 51626cd346
3 changed files with 28 additions and 10 deletions

View file

@ -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
{

View file

@ -64,7 +64,7 @@
ToolTip.Tip="{locale:Locale ShaderCacheToggleTooltip}">
<TextBlock Text="{locale:Locale SettingsTabGraphicsEnableShaderCache}" />
</CheckBox>
<CheckBox IsChecked="{Binding EnableOGLSpirV}" IsVisible="{Binding IsSpirVAvailable}"
<CheckBox IsChecked="{Binding EnableOGLSpirV}" IsVisible="{Binding IsOpenGLSelected}"
ToolTip.Tip="{locale:Locale OGLSpirVTooltip}">
<TextBlock Text="{locale:Locale SettingsTabGraphicsEnableOGLSpirV}" />
</CheckBox>

View file

@ -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;
/// <summary>
/// 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
};
}
/// <summary>
/// Checks if SpirV is available on OpenGL
/// </summary>
/// <remarks>
/// True or false
/// </remarks>
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;
}
/// <summary>
/// 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
/// <returns>Translation options</returns>
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;