diff options
| author | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-07-15 17:40:20 -0600 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-07-17 10:05:24 -0600 |
| commit | fe95fca16869a27cb6ed7fc8efa8e97c153e838d (patch) | |
| tree | dad4aea1f8d074347152179e12a0e9552484cea8 | |
| parent | 5ec11e1e0f7e548e9af7078f17bfb08d0e67b12e (diff) | |
| download | usermoji-fe95fca16869a27cb6ed7fc8efa8e97c153e838d.tar.xz | |
cube: Keep track of queue_count in demo structure
Need to know the number of queues in multiple places so just
save it as part of the demo info data structure.
| -rw-r--r-- | demos/cube.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/demos/cube.c b/demos/cube.c index 83244ff8..7ca3f305 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -393,6 +393,7 @@ struct demo { VkDbgMsgCallback msg_callback; uint32_t current_buffer; + uint32_t queue_count; }; static VkResult memory_type_from_properties(struct demo *demo, uint32_t typeBits, VkFlags properties, uint32_t *typeIndex) @@ -2234,8 +2235,6 @@ static void demo_init_vk(struct demo *demo) }; uint32_t gpu_count; - uint32_t i; - uint32_t queue_count; err = vkCreateInstance(&inst_info, &demo->inst); if (err == VK_ERROR_INCOMPATIBLE_DRIVER) { @@ -2378,10 +2377,11 @@ static void demo_init_vk(struct demo *demo) err = vkGetPhysicalDeviceProperties(demo->gpu, &demo->gpu_props); assert(!err); - err = vkGetPhysicalDeviceQueueCount(demo->gpu, &queue_count); + err = vkGetPhysicalDeviceQueueCount(demo->gpu, &demo->queue_count); assert(!err); + assert(demo->queue_count >= 1); - demo->queue_props = (VkPhysicalDeviceQueueProperties *) malloc(queue_count * sizeof(VkPhysicalDeviceQueueProperties)); + demo->queue_props = (VkPhysicalDeviceQueueProperties *) malloc(demo->queue_count * sizeof(VkPhysicalDeviceQueueProperties)); err = vkGetPhysicalDeviceQueueProperties(demo->gpu, queue_count, demo->queue_props); assert(!err); assert(queue_count >= 1); @@ -2402,8 +2402,8 @@ static void demo_init_vk(struct demo *demo) #endif // _WIN32 // Iterate over each queue to learn whether it supports presenting to WSI: - VkBool32* supportsPresent = (VkBool32 *)malloc(queue_count * sizeof(VkBool32)); - for (i = 0; i < queue_count; i++) { + VkBool32* supportsPresent = (VkBool32 *)malloc(demo->queue_count * sizeof(VkBool32)); + for (i = 0; i < demo->queue_count; i++) { demo->fpGetPhysicalDeviceSurfaceSupportWSI(demo->gpu, i, (VkSurfaceDescriptionWSI *) &demo->surface_description, &supportsPresent[i]); @@ -2413,7 +2413,7 @@ static void demo_init_vk(struct demo *demo) // families, try to find one that supports both uint32_t graphicsQueueNodeIndex = UINT32_MAX; uint32_t presentQueueNodeIndex = UINT32_MAX; - for (i = 0; i < queue_count; i++) { + for (i = 0; i < demo->queue_count; i++) { if ((demo->queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0) { if (graphicsQueueNodeIndex == UINT32_MAX) { graphicsQueueNodeIndex = i; @@ -2429,7 +2429,7 @@ static void demo_init_vk(struct demo *demo) if (presentQueueNodeIndex == UINT32_MAX) { // If didn't find a queue that supports both graphics and present, then // find a separate present queue. - for (uint32_t i = 0; i < queue_count; ++i) { + for (uint32_t i = 0; i < demo->queue_count; ++i) { if (supportsPresent[i] == VK_TRUE) { presentQueueNodeIndex = i; break; |
