Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: src/gpu/vk/GrVkBackendContext.cpp

Issue 1899213002: Revise WSI setup. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/vk/GrVkInterface.h ('k') | src/gpu/vk/GrVkGpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « include/gpu/vk/GrVkInterface.h ('k') | src/gpu/vk/GrVkGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698