aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjhorv <38920027+jhorv@users.noreply.github.com>2023-05-21 15:39:06 -0400
committerGitHub <noreply@github.com>2023-05-21 21:39:06 +0200
commitac66643346df76561ff85be741e2998290d43646 (patch)
tree532b5f81b45a85911a1b78de8c3f6f114fb456bd /src
parent21e88f17f6ebeeae61c3aa95d610ee7adf48d62c (diff)
Fix crash in SettingsViewModel when Vulkan isn't available (#4985)1.1.814
* fix crash when Vulkan isn't available * add VulkanRenderer.GetPhysicalDevices() overload that provides its own Vk API object and logs on failure * adjustments per AcK77
Diffstat (limited to 'src')
-rw-r--r--src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs2
-rw-r--r--src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs19
-rw-r--r--src/Ryujinx/Ui/Windows/SettingsWindow.cs2
3 files changed, 21 insertions, 2 deletions
diff --git a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs
index 89392f6b..d260b6fc 100644
--- a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs
+++ b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs
@@ -311,7 +311,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{
_gpuIds = new List<string>();
List<string> names = new();
- var devices = VulkanRenderer.GetPhysicalDevices(Vk.GetApi());
+ var devices = VulkanRenderer.GetPhysicalDevices();
if (devices.Length == 0)
{
diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs
index ffa1a103..74267325 100644
--- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs
+++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs
@@ -599,6 +599,25 @@ namespace Ryujinx.Graphics.Vulkan
return new HardwareInfo(GpuVendor, GpuRenderer);
}
+ /// <summary>
+ /// Gets the available Vulkan devices using the default Vulkan API
+ /// object returned by <see cref="Vk.GetApi()"/>
+ /// </summary>
+ /// <returns></returns>
+ public static DeviceInfo[] GetPhysicalDevices()
+ {
+ try
+ {
+ return VulkanInitialization.GetSuitablePhysicalDevices(Vk.GetApi());
+ }
+ catch (Exception ex)
+ {
+ Logger.Error?.PrintMsg(LogClass.Gpu, $"Error querying Vulkan devices: {ex.Message}");
+
+ return Array.Empty<DeviceInfo>();
+ }
+ }
+
public static DeviceInfo[] GetPhysicalDevices(Vk api)
{
try
diff --git a/src/Ryujinx/Ui/Windows/SettingsWindow.cs b/src/Ryujinx/Ui/Windows/SettingsWindow.cs
index 65175ff1..fbfbf527 100644
--- a/src/Ryujinx/Ui/Windows/SettingsWindow.cs
+++ b/src/Ryujinx/Ui/Windows/SettingsWindow.cs
@@ -478,7 +478,7 @@ namespace Ryujinx.Ui.Windows
if (Enum.Parse<GraphicsBackend>(_graphicsBackend.ActiveId) == GraphicsBackend.Vulkan)
{
- var devices = VulkanRenderer.GetPhysicalDevices(Vk.GetApi());
+ var devices = VulkanRenderer.GetPhysicalDevices();
string preferredGpuIdFromConfig = ConfigurationState.Instance.Graphics.PreferredGpu.Value;
string preferredGpuId = preferredGpuIdFromConfig;
bool noGpuId = string.IsNullOrEmpty(preferredGpuIdFromConfig);