diff options
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/renderer_vulkan.cpp | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index 831c204c2..f64318f25 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp | |||
| @@ -170,7 +170,6 @@ void RendererVulkan::ShutDown() { | |||
| 170 | if (const auto& dev = device->GetLogical()) { | 170 | if (const auto& dev = device->GetLogical()) { |
| 171 | dev.WaitIdle(); | 171 | dev.WaitIdle(); |
| 172 | } | 172 | } |
| 173 | |||
| 174 | rasterizer.reset(); | 173 | rasterizer.reset(); |
| 175 | blit_screen.reset(); | 174 | blit_screen.reset(); |
| 176 | scheduler.reset(); | 175 | scheduler.reset(); |
| @@ -180,19 +179,13 @@ void RendererVulkan::ShutDown() { | |||
| 180 | } | 179 | } |
| 181 | 180 | ||
| 182 | bool RendererVulkan::PickDevices() { | 181 | bool RendererVulkan::PickDevices() { |
| 183 | const auto devices = instance.EnumeratePhysicalDevices(); | 182 | const std::vector<VkPhysicalDevice> devices = instance.EnumeratePhysicalDevices(); |
| 184 | if (!devices) { | ||
| 185 | LOG_ERROR(Render_Vulkan, "Failed to enumerate physical devices"); | ||
| 186 | return false; | ||
| 187 | } | ||
| 188 | |||
| 189 | const s32 device_index = Settings::values.vulkan_device.GetValue(); | 183 | const s32 device_index = Settings::values.vulkan_device.GetValue(); |
| 190 | if (device_index < 0 || device_index >= static_cast<s32>(devices->size())) { | 184 | if (device_index < 0 || device_index >= static_cast<s32>(devices.size())) { |
| 191 | LOG_ERROR(Render_Vulkan, "Invalid device index {}!", device_index); | 185 | LOG_ERROR(Render_Vulkan, "Invalid device index {}!", device_index); |
| 192 | return false; | 186 | return false; |
| 193 | } | 187 | } |
| 194 | const vk::PhysicalDevice physical_device((*devices)[static_cast<std::size_t>(device_index)], | 188 | const vk::PhysicalDevice physical_device(devices[static_cast<std::size_t>(device_index)], dld); |
| 195 | dld); | ||
| 196 | if (!VKDevice::IsSuitable(physical_device, *surface)) { | 189 | if (!VKDevice::IsSuitable(physical_device, *surface)) { |
| 197 | return false; | 190 | return false; |
| 198 | } | 191 | } |
| @@ -224,23 +217,21 @@ void RendererVulkan::Report() const { | |||
| 224 | telemetry_session.AddField(field, "GPU_Vulkan_Extensions", extensions); | 217 | telemetry_session.AddField(field, "GPU_Vulkan_Extensions", extensions); |
| 225 | } | 218 | } |
| 226 | 219 | ||
| 227 | std::vector<std::string> RendererVulkan::EnumerateDevices() { | 220 | std::vector<std::string> RendererVulkan::EnumerateDevices() try { |
| 228 | vk::InstanceDispatch dld; | 221 | vk::InstanceDispatch dld; |
| 229 | Common::DynamicLibrary library = OpenLibrary(); | 222 | const Common::DynamicLibrary library = OpenLibrary(); |
| 230 | vk::Instance instance = CreateInstance(library, dld).first; | 223 | const vk::Instance instance = CreateInstance(library, dld).first; |
| 231 | if (!instance) { | 224 | const std::vector<VkPhysicalDevice> physical_devices = instance.EnumeratePhysicalDevices(); |
| 232 | return {}; | ||
| 233 | } | ||
| 234 | const std::optional physical_devices = instance.EnumeratePhysicalDevices(); | ||
| 235 | if (!physical_devices) { | ||
| 236 | return {}; | ||
| 237 | } | ||
| 238 | std::vector<std::string> names; | 225 | std::vector<std::string> names; |
| 239 | names.reserve(physical_devices->size()); | 226 | names.reserve(physical_devices.size()); |
| 240 | for (const auto& device : *physical_devices) { | 227 | for (const VkPhysicalDevice device : physical_devices) { |
| 241 | names.push_back(vk::PhysicalDevice(device, dld).GetProperties().deviceName); | 228 | names.push_back(vk::PhysicalDevice(device, dld).GetProperties().deviceName); |
| 242 | } | 229 | } |
| 243 | return names; | 230 | return names; |
| 231 | |||
| 232 | } catch (const vk::Exception& exception) { | ||
| 233 | LOG_ERROR(Render_Vulkan, "Failed to enumerate devices with error: {}", exception.what()); | ||
| 234 | return {}; | ||
| 244 | } | 235 | } |
| 245 | 236 | ||
| 246 | } // namespace Vulkan | 237 | } // namespace Vulkan |