Index: src/gpu/vk/GrVkBackendContext.cpp |
diff --git a/src/gpu/vk/GrVkBackendContext.cpp b/src/gpu/vk/GrVkBackendContext.cpp |
index d189840adbed7bddf58a66c40a0400b4c7ce2e4b..22cdaa6a14218ebb55d9640d39375e4d49fcf65b 100644 |
--- a/src/gpu/vk/GrVkBackendContext.cpp |
+++ b/src/gpu/vk/GrVkBackendContext.cpp |
@@ -36,7 +36,8 @@ const char* kDebugLayerNames[] = { |
const uint32_t kGrVkMinimumVersion = VK_MAKE_VERSION(1, 0, 3); |
// Create the base Vulkan objects needed by the GrVkGpu object |
-const GrVkBackendContext* GrVkBackendContext::Create() { |
+const GrVkBackendContext* GrVkBackendContext::Create(uint32_t* presentQueueIndexPtr, |
+ bool(*canPresent)(VkInstance, VkPhysicalDevice, uint32_t queueIndex)) { |
VkPhysicalDevice physDev; |
VkDevice device; |
VkInstance inst; |
@@ -142,15 +143,28 @@ const GrVkBackendContext* GrVkBackendContext::Create() { |
vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, queueProps); |
// iterate to find the graphics queue |
- uint32_t graphicsQueueIndex = -1; |
+ uint32_t graphicsQueueIndex = queueCount; |
for (uint32_t i = 0; i < queueCount; i++) { |
- if (queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { |
+ if (graphicsQueueIndex == queueCount && queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { |
egdaniel
2016/04/20 18:26:54
why is this needed in the if? Seems like the only
jvanverth1
2016/04/20 18:32:24
Good catch. This and the if below are from when bo
|
graphicsQueueIndex = i; |
break; |
} |
} |
SkASSERT(graphicsQueueIndex < queueCount); |
+ // iterate to find the present queue, if needed |
+ uint32_t presentQueueIndex = graphicsQueueIndex; |
+ if (presentQueueIndexPtr && canPresent) { |
+ for (uint32_t i = 0; i < queueCount; i++) { |
+ if (presentQueueIndex == queueCount && canPresent(inst, physDev, i)) { |
egdaniel
2016/04/20 18:26:54
Assuming the assert above is true, presentQueueInd
|
+ presentQueueIndex = i; |
+ break; |
+ } |
+ } |
+ SkASSERT(presentQueueIndex < queueCount); |
+ *presentQueueIndexPtr = presentQueueIndex; |
+ } |
+ |
extensions.initDevice(kGrVkMinimumVersion, inst, physDev); |
SkTArray<const char*> deviceLayerNames; |
@@ -192,20 +206,32 @@ const GrVkBackendContext* GrVkBackendContext::Create() { |
float queuePriorities[1] = { 0.0 }; |
// Here we assume no need for swapchain queue |
// If one is needed, the client will need its own setup code |
- const VkDeviceQueueCreateInfo queueInfo = { |
- VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType |
- nullptr, // pNext |
- 0, // VkDeviceQueueCreateFlags |
- graphicsQueueIndex, // queueFamilyIndex |
- 1, // queueCount |
- queuePriorities, // pQueuePriorities |
+ const VkDeviceQueueCreateInfo queueInfo[2] = { |
+ { |
+ VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType |
+ nullptr, // pNext |
+ 0, // VkDeviceQueueCreateFlags |
+ graphicsQueueIndex, // queueFamilyIndex |
+ 1, // queueCount |
+ queuePriorities, // pQueuePriorities |
+ }, |
+ { |
+ VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType |
+ nullptr, // pNext |
+ 0, // VkDeviceQueueCreateFlags |
+ presentQueueIndex, // queueFamilyIndex |
+ 1, // queueCount |
+ queuePriorities, // pQueuePriorities |
+ } |
}; |
+ uint32_t queueInfoCount = (presentQueueIndex != graphicsQueueIndex) ? 2 : 1; |
+ |
const VkDeviceCreateInfo deviceInfo = { |
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType |
nullptr, // pNext |
0, // VkDeviceCreateFlags |
- 1, // queueCreateInfoCount |
- &queueInfo, // pQueueCreateInfos |
+ queueInfoCount, // queueCreateInfoCount |
+ queueInfo, // pQueueCreateInfos |
(uint32_t) deviceLayerNames.count(), // layerCount |
deviceLayerNames.begin(), // ppEnabledLayerNames |
(uint32_t) deviceExtensionNames.count(), // extensionCount |
@@ -228,7 +254,7 @@ const GrVkBackendContext* GrVkBackendContext::Create() { |
ctx->fPhysicalDevice = physDev; |
ctx->fDevice = device; |
ctx->fQueue = queue; |
- ctx->fQueueFamilyIndex = graphicsQueueIndex; |
+ ctx->fGraphicsQueueIndex = graphicsQueueIndex; |
ctx->fMinAPIVersion = kGrVkMinimumVersion; |
ctx->fExtensions = extensionFlags; |
ctx->fFeatures = featureFlags; |