diff options
author | Greg Daniel <egdaniel@google.com> | 2017-04-27 12:57:59 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-27 17:40:40 +0000 |
commit | a41d48b739c144ee7b36290a9642064bc6cdcd05 (patch) | |
tree | e1908e91729410df91ad1dcc1ce85ee0f5e1e7f7 | |
parent | 13b7dc03dde5ed83f081861d94e88f3ec920e016 (diff) |
Add additional checks when creating vulkan context
Makes sure we get the phsyical devices and queues we expect
Bug: skia:
Change-Id: I13031caa8aa85d680a8e921bee3237d6b53cebf0
Reviewed-on: https://skia-review.googlesource.com/14523
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
-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); |