Parcourir la source

vulkan: gracefully handle inability to create device

rdb il y a 7 ans
Parent
commit
b7865a3716

+ 5 - 0
panda/src/vulkandisplay/vulkanGraphicsStateGuardian.cxx

@@ -309,6 +309,11 @@ VulkanGraphicsStateGuardian(GraphicsEngine *engine, VulkanGraphicsPipe *pipe,
  */
 VulkanGraphicsStateGuardian::
 ~VulkanGraphicsStateGuardian() {
+  if (_device == VK_NULL_HANDLE) {
+    nassertv(_memory_pages.empty());
+    return;
+  }
+
   // And all the semaphores that were generated on this device.
   for (VkSemaphore semaphore : _semaphores) {
     vkDestroySemaphore(_device, semaphore, nullptr);

+ 7 - 0
panda/src/vulkandisplay/vulkanGraphicsWindow.cxx

@@ -447,6 +447,13 @@ open_window() {
     DCAST_INTO_R(vkgsg, _gsg.p(), false);
   }
 
+  if (!vkgsg->is_valid()) {
+    _gsg.clear();
+    vulkandisplay_cat.error()
+      << "VulkanGraphicsStateGuardian is not valid.\n";
+    return false;
+  }
+
   _fb_properties.set_force_hardware(vkgsg->is_hardware());
   _fb_properties.set_force_software(!vkgsg->is_hardware());