mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-22 23:15:38 +00:00
Fix crash in SettingsViewModel when Vulkan isn't available (#4985)
* 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
This commit is contained in:
parent
21e88f17f6
commit
ac66643346
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue