Explorar el Código

vulkan: Improve error for vkGetPhysicalDeviceSurfaceFormatsKHR failure

rdb hace 4 años
padre
commit
349a520440
Se han modificado 1 ficheros con 10 adiciones y 6 borrados
  1. 10 6
      panda/src/vulkandisplay/vulkanGraphicsWindow.cxx

+ 10 - 6
panda/src/vulkandisplay/vulkanGraphicsWindow.cxx

@@ -512,14 +512,18 @@ open_window() {
 
 
   // Query the preferred image formats for this surface.
   // Query the preferred image formats for this surface.
   uint32_t num_formats;
   uint32_t num_formats;
+  VkSurfaceFormatKHR *formats;
   err = vkGetPhysicalDeviceSurfaceFormatsKHR(vkpipe->_gpu, _surface,
   err = vkGetPhysicalDeviceSurfaceFormatsKHR(vkpipe->_gpu, _surface,
                                              &num_formats, nullptr);
                                              &num_formats, nullptr);
-  nassertr(!err, false);
-  VkSurfaceFormatKHR *formats =
-      (VkSurfaceFormatKHR *)alloca(sizeof(VkSurfaceFormatKHR) * num_formats);
-  err = vkGetPhysicalDeviceSurfaceFormatsKHR(vkpipe->_gpu, _surface,
-                                             &num_formats, formats);
-  nassertr(!err, false);
+  if (!err) {
+    formats = (VkSurfaceFormatKHR *)alloca(sizeof(VkSurfaceFormatKHR) * num_formats);
+    err = vkGetPhysicalDeviceSurfaceFormatsKHR(vkpipe->_gpu, _surface,
+                                               &num_formats, formats);
+  }
+  if (err) {
+    vulkan_error(err, "Failed to get physical device surface formats");
+    return false;
+  }
 
 
   // If the format list includes just one entry of VK_FORMAT_UNDEFINED, the
   // If the format list includes just one entry of VK_FORMAT_UNDEFINED, the
   // surface has no preferred format.  Otherwise, at least one supported
   // surface has no preferred format.  Otherwise, at least one supported