mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-17 18:18:16 -05:00
renderer_vulkan: Throw when enumerating devices fails
Report device enumeration errors with exceptions to be consistent with other initialization related function calls. Reduces the amount of code to maintain.
This commit is contained in:
@ -111,7 +111,7 @@ void RemoveUnavailableLayers(const vk::InstanceDispatch& dld, std::vector<const
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
std::pair<vk::Instance, u32> CreateInstance(Common::DynamicLibrary& library,
|
||||
std::pair<vk::Instance, u32> CreateInstance(const Common::DynamicLibrary& library,
|
||||
vk::InstanceDispatch& dld,
|
||||
Core::Frontend::WindowSystemType window_type,
|
||||
bool enable_debug_utils, bool enable_layers) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
namespace Vulkan {
|
||||
|
||||
[[nodiscard]] std::pair<vk::Instance, u32> CreateInstance(
|
||||
Common::DynamicLibrary& library, vk::InstanceDispatch& dld,
|
||||
const Common::DynamicLibrary& library, vk::InstanceDispatch& dld,
|
||||
Core::Frontend::WindowSystemType window_type = Core::Frontend::WindowSystemType::Headless,
|
||||
bool enable_debug_utils = false, bool enable_layers = false);
|
||||
|
||||
|
@ -465,17 +465,13 @@ Instance Instance::Create(u32 version, Span<const char*> layers, Span<const char
|
||||
return Instance(instance, dispatch);
|
||||
}
|
||||
|
||||
std::optional<std::vector<VkPhysicalDevice>> Instance::EnumeratePhysicalDevices() const {
|
||||
std::vector<VkPhysicalDevice> Instance::EnumeratePhysicalDevices() const {
|
||||
u32 num;
|
||||
if (dld->vkEnumeratePhysicalDevices(handle, &num, nullptr) != VK_SUCCESS) {
|
||||
return std::nullopt;
|
||||
}
|
||||
Check(dld->vkEnumeratePhysicalDevices(handle, &num, nullptr));
|
||||
std::vector<VkPhysicalDevice> physical_devices(num);
|
||||
if (dld->vkEnumeratePhysicalDevices(handle, &num, physical_devices.data()) != VK_SUCCESS) {
|
||||
return std::nullopt;
|
||||
}
|
||||
Check(dld->vkEnumeratePhysicalDevices(handle, &num, physical_devices.data()));
|
||||
SortPhysicalDevices(physical_devices, *dld);
|
||||
return std::make_optional(std::move(physical_devices));
|
||||
return physical_devices;
|
||||
}
|
||||
|
||||
DebugUtilsMessenger Instance::CreateDebugUtilsMessenger(
|
||||
|
@ -580,7 +580,8 @@ public:
|
||||
|
||||
/// Enumerates physical devices.
|
||||
/// @return Physical devices and an empty handle on failure.
|
||||
std::optional<std::vector<VkPhysicalDevice>> EnumeratePhysicalDevices() const;
|
||||
/// @throw Exception on Vulkan error.
|
||||
std::vector<VkPhysicalDevice> EnumeratePhysicalDevices() const;
|
||||
|
||||
/// Creates a debug callback messenger.
|
||||
/// @throw Exception on creation failure.
|
||||
|
Reference in New Issue
Block a user