tests: Add queue family selection utility
authorJohn Zulauf <jzulauf@lunarg.com>
Fri, 26 Jan 2018 18:35:17 +0000 (11:35 -0700)
committerjzulauf-lunarg <32470354+jzulauf-lunarg@users.noreply.github.com>
Wed, 31 Jan 2018 16:12:35 +0000 (09:12 -0700)
Add additional queue family selection utility for choosing queue
families based on both required and restricted capabilities.  Refactored
existing utility to use new utility.

Change-Id: I3c92cfdbbe6463bf1730f2173e91424e082063ce

tests/vkrenderframework.cpp
tests/vkrenderframework.h

index 817d649..fc84224 100644 (file)
@@ -508,10 +508,12 @@ VkDeviceObj::VkDeviceObj(uint32_t id, VkPhysicalDevice obj, std::vector<const ch
     queue_props = phy().queue_properties();
 }
 
-uint32_t VkDeviceObj::QueueFamilyWithoutCapabilities(VkQueueFlags capabilities) {
-    // Find a queue family without desired capabilities
+uint32_t VkDeviceObj::QueueFamilyMatching(VkQueueFlags with, VkQueueFlags without, bool all_bits) {
+    // Find a queue family with and without desired capabilities
     for (uint32_t i = 0; i < queue_props.size(); i++) {
-        if ((queue_props[i].queueFlags & capabilities) == 0 && (queue_props[i].queueCount > 0)) {
+        auto flags = queue_props[i].queueFlags;
+        bool matches = all_bits ? (flags & with) == with : (flags & with) != 0;
+        if (matches && ((flags & without) == 0) && (queue_props[i].queueCount > 0)) {
             return i;
         }
     }
index 54d7243..1260b85 100644 (file)
@@ -52,7 +52,11 @@ class VkDeviceObj : public vk_testing::Device {
     VkDeviceObj(uint32_t id, VkPhysicalDevice obj, std::vector<const char *> &extension_names,
                 VkPhysicalDeviceFeatures *features = nullptr);
 
-    uint32_t QueueFamilyWithoutCapabilities(VkQueueFlags capabilities);
+    uint32_t QueueFamilyMatching(VkQueueFlags with, VkQueueFlags without, bool all_bits = true);
+    uint32_t QueueFamilyWithoutCapabilities(VkQueueFlags capabilities) {
+        // an all_bits match with 0 matches all
+        return QueueFamilyMatching(VkQueueFlags(0), capabilities, true /* all_bits with */);
+    }
 
     VkDevice device() { return handle(); }
     void get_device_queue();