diff options
-rw-r--r-- | src/gpu/vk/GrVkBackendContext.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/gpu/vk/GrVkBackendContext.cpp b/src/gpu/vk/GrVkBackendContext.cpp index 479d680f18..e473178223 100644 --- a/src/gpu/vk/GrVkBackendContext.cpp +++ b/src/gpu/vk/GrVkBackendContext.cpp @@ -147,7 +147,11 @@ const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndex grVkDestroyInstance(inst, nullptr); return nullptr; } - SkASSERT(gpuCount > 0); + if (!gpuCount) { + SkDebugf("vkEnumeratePhysicalDevices returned no supported devices.\n"); + grVkDestroyInstance(inst, nullptr); + return nullptr; + } // Just returning the first physical device instead of getting the whole array. // TODO: find best match for our needs gpuCount = 1; @@ -161,7 +165,11 @@ const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndex // query to get the initial queue props size uint32_t queueCount; grVkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, nullptr); - SkASSERT(queueCount >= 1); + if (!queueCount) { + SkDebugf("vkGetPhysicalDeviceQueueFamilyProperties returned no queues.\n"); + grVkDestroyInstance(inst, nullptr); + return nullptr; + } SkAutoMalloc queuePropsAlloc(queueCount * sizeof(VkQueueFamilyProperties)); // now get the actual queue props @@ -177,10 +185,14 @@ const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndex break; } } - SkASSERT(graphicsQueueIndex < queueCount); + if (graphicsQueueIndex == queueCount) { + SkDebugf("Could not find any supported graphics queues.\n"); + grVkDestroyInstance(inst, nullptr); + return nullptr; + } // iterate to find the present queue, if needed - uint32_t presentQueueIndex = graphicsQueueIndex; + uint32_t presentQueueIndex = queueCount; if (presentQueueIndexPtr && canPresent) { for (uint32_t i = 0; i < queueCount; i++) { if (canPresent(inst, physDev, i)) { @@ -188,8 +200,16 @@ const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndex break; } } - SkASSERT(presentQueueIndex < queueCount); + if (presentQueueIndex == queueCount) { + SkDebugf("Could not find any supported present queues.\n"); + grVkDestroyInstance(inst, nullptr); + return nullptr; + } *presentQueueIndexPtr = presentQueueIndex; + } else { + // Just setting this so we end up make a single queue for graphics since there was no + // request for a present queue. + presentQueueIndex = graphicsQueueIndex; } extensions.initDevice(kGrVkMinimumVersion, inst, physDev); |