Clean up layer test
authorMark Young <marky@lunarg.com>
Wed, 16 Feb 2022 16:09:16 +0000 (09:09 -0700)
committerMark Young <marky@lunarg.com>
Wed, 16 Feb 2022 17:09:29 +0000 (10:09 -0700)
My previous commit to enable physical device modifications in a layer
required new compiled layers to do the work.  Since this can more
cleanly be done by setting layer flags (as suggested by @charles-lunarg)
I have gone back and done that.

tests/framework/framework_config.h.in
tests/framework/layer/CMakeLists.txt
tests/framework/layer/test_layer.cpp
tests/framework/layer/test_layer.h
tests/loader_layer_tests.cpp

index 88b2867..fa7d013 100644 (file)
Binary files a/tests/framework/framework_config.h.in and b/tests/framework/framework_config.h.in differ
index b65e2e3..0ab3955 100644 (file)
@@ -54,46 +54,6 @@ target_link_libraries(test_layer_export_version_2 PRIVATE test_layer_deps)
 target_compile_definitions(test_layer_export_version_2 PRIVATE
     ${TEST_LAYER_VERSION_0_EXPORTS} ${TEST_LAYER_VERSION_1_EXPORTS} ${TEST_LAYER_VERSION_2_EXPORTS} )
 
-# Physical device list altering layer (add phys dev, remove phys dev, re-order phys devs)
-set(PHYSDEV_LAYER_ADD_EXPORTS
-        ${TEST_LAYER_VERSION_0_EXPORTS} ${TEST_LAYER_VERSION_1_EXPORTS} ${TEST_LAYER_VERSION_2_EXPORTS}
-        TEST_LAYER_NAME="VkLayer_LunarG_add_phys_dev"
-        TEST_PHYSDEV_LAYER_ADD=1
-    )
-set(PHYSDEV_REMOVE_EXPORTS
-        ${TEST_LAYER_VERSION_0_EXPORTS} ${TEST_LAYER_VERSION_1_EXPORTS} ${TEST_LAYER_VERSION_2_EXPORTS}
-        TEST_LAYER_NAME="VkLayer_LunarG_remove_phys_dev"
-        TEST_PHYSDEV_LAYER_REMOVE=1
-    )
-set(PHYSDEV_LAYER_REORDER_EXPORTS
-        ${TEST_LAYER_VERSION_0_EXPORTS} ${TEST_LAYER_VERSION_1_EXPORTS} ${TEST_LAYER_VERSION_2_EXPORTS}
-        TEST_LAYER_NAME="VkLayer_LunarG_reorder_phys_dev"
-        TEST_PHYSDEV_LAYER_REORDER=1
-    )
-set(PHYSDEV_LAYER_ALL_EXPORTS
-        ${TEST_LAYER_VERSION_0_EXPORTS} ${TEST_LAYER_VERSION_1_EXPORTS} ${TEST_LAYER_VERSION_2_EXPORTS}
-        TEST_LAYER_NAME="VkLayer_LunarG_all_phys_dev"
-        TEST_PHYSDEV_LAYER_ADD=1
-        TEST_PHYSDEV_LAYER_REMOVE=1
-        TEST_PHYSDEV_LAYER_REORDER=1
-    )
-
-add_library(test_layer_physdev_add SHARED ${TEST_LAYER_SOURCES})
-target_link_libraries(test_layer_physdev_add PRIVATE test_layer_deps)
-target_compile_definitions(test_layer_physdev_add PRIVATE ${PHYSDEV_LAYER_ADD_EXPORTS})
-
-add_library(test_layer_physdev_remove SHARED ${TEST_LAYER_SOURCES})
-target_link_libraries(test_layer_physdev_remove PRIVATE test_layer_deps)
-target_compile_definitions(test_layer_physdev_remove PRIVATE ${PHYSDEV_REMOVE_EXPORTS})
-
-add_library(test_layer_physdev_reorder SHARED ${TEST_LAYER_SOURCES})
-target_link_libraries(test_layer_physdev_reorder PRIVATE test_layer_deps)
-target_compile_definitions(test_layer_physdev_reorder PRIVATE ${PHYSDEV_LAYER_REORDER_EXPORTS})
-
-add_library(test_layer_physdev_all SHARED ${TEST_LAYER_SOURCES})
-target_link_libraries(test_layer_physdev_all PRIVATE test_layer_deps)
-target_compile_definitions(test_layer_physdev_all PRIVATE ${PHYSDEV_LAYER_ALL_EXPORTS})
-
 # Wrap Objects layer which wraps dispatchable handles to test that the loader will properly
 # work in the case where handles in the terminator don't match handles in the trampoline portion.
 set(WRAP_LAYER_VERSION_1_EXPORTS
@@ -132,10 +92,6 @@ if(WIN32)
     target_sources(test_layer_export_version_0 PRIVATE export_definitions/test_layer_0.def)
     target_sources(test_layer_export_version_1 PRIVATE export_definitions/test_layer_1.def)
     target_sources(test_layer_export_version_2 PRIVATE export_definitions/test_layer_2.def)
-    target_sources(test_layer_physdev_add PRIVATE export_definitions/test_layer_2.def)
-    target_sources(test_layer_physdev_remove PRIVATE export_definitions/test_layer_2.def)
-    target_sources(test_layer_physdev_reorder PRIVATE export_definitions/test_layer_2.def)
-    target_sources(test_layer_physdev_all PRIVATE export_definitions/test_layer_2.def)
     target_sources(test_layer_wrap_objects PRIVATE export_definitions/test_layer_wrap_objects.def)
     target_sources(test_layer_wrap_objects_1 PRIVATE export_definitions/test_layer_wrap_objects.def)
     target_sources(test_layer_wrap_objects_2 PRIVATE export_definitions/test_layer_wrap_objects.def)
index 1f8c68f..63bc619 100644 (file)
@@ -220,78 +220,77 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDevice(VkPhysicalDevice physicalDevi
 
 VKAPI_ATTR VkResult VKAPI_CALL test_vkEnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount,
                                                                VkPhysicalDevice* pPhysicalDevices) {
-#if !TEST_PHYSDEV_LAYER_REMOVE && !TEST_PHYSDEV_LAYER_ADD && !TEST_PHYSDEV_LAYER_REORDER
-    return layer.instance_dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
-#else  // TEST_PHYSDEV_LAYER_REMOVE || TEST_PHYSDEV_LAYER_ADD || TEST_PHYSDEV_LAYER_REORDER
-    VkResult res = VK_SUCCESS;
-
-    if (layer.complete_physical_devices.size() == 0) {
-        // Get list of all physical devices from lower down
-        // NOTE: This only works if we don't test changing the number of devices
-        //       underneath us when using this test.
-        uint32_t icd_count = 0;
-        layer.instance_dispatch_table.EnumeratePhysicalDevices(instance, &icd_count, nullptr);
-        std::vector<VkPhysicalDevice> tmp_vector;
-        tmp_vector.resize(icd_count);
-        layer.instance_dispatch_table.EnumeratePhysicalDevices(instance, &icd_count, tmp_vector.data());
-        layer.complete_physical_devices.clear();
-
-#if TEST_PHYSDEV_LAYER_REMOVE
-        // Erase the 3rd and 4th items
-        layer.removed_physical_devices.push_back(tmp_vector[3]);
-        layer.removed_physical_devices.push_back(tmp_vector[4]);
-        tmp_vector.erase(tmp_vector.begin() + 3);
-        tmp_vector.erase(tmp_vector.begin() + 3);
-#endif  // TEST_PHYSDEV_LAYER_REMOVE
-
-#if TEST_PHYSDEV_LAYER_ADD
-        // Insert a new device in the beginning, middle, and end
-        uint32_t middle = static_cast<uint32_t>(tmp_vector.size() / 2);
-        VkPhysicalDevice new_phys_dev = reinterpret_cast<VkPhysicalDevice>((size_t)(0xABCD0000));
-        layer.added_physical_devices.push_back(new_phys_dev);
-        tmp_vector.insert(tmp_vector.begin(), new_phys_dev);
-        new_phys_dev = reinterpret_cast<VkPhysicalDevice>((size_t)(0xBADC0000));
-        layer.added_physical_devices.push_back(new_phys_dev);
-        tmp_vector.insert(tmp_vector.begin() + middle, new_phys_dev);
-        new_phys_dev = reinterpret_cast<VkPhysicalDevice>((size_t)(0xDCBA0000));
-        layer.added_physical_devices.push_back(new_phys_dev);
-        tmp_vector.push_back(new_phys_dev);
-#endif  // TEST_PHYSDEV_LAYER_ADD
-
-#if TEST_PHYSDEV_LAYER_REORDER
-        // Flip the order of items
-        for (int32_t dev = static_cast<int32_t>(tmp_vector.size() - 1); dev >= 0; --dev) {
-            layer.complete_physical_devices.push_back(tmp_vector[dev]);
+    if (layer.add_phys_devs || layer.remove_phys_devs || layer.reorder_phys_devs) {
+        VkResult res = VK_SUCCESS;
+
+        if (layer.complete_physical_devices.size() == 0) {
+            // Get list of all physical devices from lower down
+            // NOTE: This only works if we don't test changing the number of devices
+            //       underneath us when using this test.
+            uint32_t icd_count = 0;
+            layer.instance_dispatch_table.EnumeratePhysicalDevices(instance, &icd_count, nullptr);
+            std::vector<VkPhysicalDevice> tmp_vector;
+            tmp_vector.resize(icd_count);
+            layer.instance_dispatch_table.EnumeratePhysicalDevices(instance, &icd_count, tmp_vector.data());
+            layer.complete_physical_devices.clear();
+
+            if (layer.remove_phys_devs) {
+                // Erase the 3rd and 4th items
+                layer.removed_physical_devices.push_back(tmp_vector[3]);
+                layer.removed_physical_devices.push_back(tmp_vector[4]);
+                tmp_vector.erase(tmp_vector.begin() + 3);
+                tmp_vector.erase(tmp_vector.begin() + 3);
+            }
+
+            if (layer.add_phys_devs) {
+                // Insert a new device in the beginning, middle, and end
+                uint32_t middle = static_cast<uint32_t>(tmp_vector.size() / 2);
+                VkPhysicalDevice new_phys_dev = reinterpret_cast<VkPhysicalDevice>((size_t)(0xABCD0000));
+                layer.added_physical_devices.push_back(new_phys_dev);
+                tmp_vector.insert(tmp_vector.begin(), new_phys_dev);
+                new_phys_dev = reinterpret_cast<VkPhysicalDevice>((size_t)(0xBADC0000));
+                layer.added_physical_devices.push_back(new_phys_dev);
+                tmp_vector.insert(tmp_vector.begin() + middle, new_phys_dev);
+                new_phys_dev = reinterpret_cast<VkPhysicalDevice>((size_t)(0xDCBA0000));
+                layer.added_physical_devices.push_back(new_phys_dev);
+                tmp_vector.push_back(new_phys_dev);
+            }
+
+            if (layer.reorder_phys_devs) {
+                // Flip the order of items
+                for (int32_t dev = static_cast<int32_t>(tmp_vector.size() - 1); dev >= 0; --dev) {
+                    layer.complete_physical_devices.push_back(tmp_vector[dev]);
+                }
+            } else {
+                // Otherwise, keep the order the same
+                for (uint32_t dev = 0; dev < tmp_vector.size(); ++dev) {
+                    layer.complete_physical_devices.push_back(tmp_vector[dev]);
+                }
+            }
         }
-#else   // !TEST_PHYSDEV_LAYER_REORDER
-        // Otherwise, keep the order the same
-        for (uint32_t dev = 0; dev < tmp_vector.size(); ++dev) {
-            layer.complete_physical_devices.push_back(tmp_vector[dev]);
+
+        if (nullptr == pPhysicalDevices) {
+            *pPhysicalDeviceCount = static_cast<uint32_t>(layer.complete_physical_devices.size());
+        } else {
+            uint32_t adj_count = static_cast<uint32_t>(layer.complete_physical_devices.size());
+            if (*pPhysicalDeviceCount < adj_count) {
+                adj_count = *pPhysicalDeviceCount;
+                res = VK_INCOMPLETE;
+            }
+            for (uint32_t dev = 0; dev < adj_count; ++dev) {
+                pPhysicalDevices[dev] = layer.complete_physical_devices[dev];
+            }
+            *pPhysicalDeviceCount = adj_count;
         }
-#endif  // !TEST_PHYSDEV_LAYER_REORDER
-    }
 
-    if (nullptr == pPhysicalDevices) {
-        *pPhysicalDeviceCount = static_cast<uint32_t>(layer.complete_physical_devices.size());
+        return res;
     } else {
-        uint32_t adj_count = static_cast<uint32_t>(layer.complete_physical_devices.size());
-        if (*pPhysicalDeviceCount < adj_count) {
-            adj_count = *pPhysicalDeviceCount;
-            res = VK_INCOMPLETE;
-        }
-        for (uint32_t dev = 0; dev < adj_count; ++dev) {
-            pPhysicalDevices[dev] = layer.complete_physical_devices[dev];
-        }
-        *pPhysicalDeviceCount = adj_count;
+        return layer.instance_dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
     }
-
-    return res;
-#endif  // TEST_PHYSDEV_LAYER_REMOVE || TEST_PHYSDEV_LAYER_ADD || TEST_PHYSDEV_LAYER_REORDER
 }
 
 VKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
                                                               VkPhysicalDeviceProperties* pProperties) {
-#if TEST_PHYSDEV_LAYER_REMOVE || TEST_PHYSDEV_LAYER_ADD || TEST_PHYSDEV_LAYER_REORDER
     if (std::find(layer.removed_physical_devices.begin(), layer.removed_physical_devices.end(), physicalDevice) !=
         layer.removed_physical_devices.end()) {
         // Should not get here since the application should not know about those devices
@@ -309,9 +308,6 @@ VKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceProperties(VkPhysicalDevice p
         strncpy(pProperties->deviceName, "physdev_added_xx", VK_MAX_PHYSICAL_DEVICE_NAME_SIZE);
 #endif
     } else {
-#else  // !TEST_PHYSDEV_LAYER_REMOVE && !TEST_PHYSDEV_LAYER_ADD && !TEST_PHYSDEV_LAYER_REORDER
-    {
-#endif
         // Not an affected device so just return
         layer.instance_dispatch_table.GetPhysicalDeviceProperties(physicalDevice, pProperties);
     }
@@ -319,92 +315,92 @@ VKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceProperties(VkPhysicalDevice p
 
 VKAPI_ATTR VkResult VKAPI_CALL test_vkEnumeratePhysicalDeviceGroups(
     VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties) {
-#if !TEST_PHYSDEV_LAYER_REMOVE && !TEST_PHYSDEV_LAYER_ADD && !TEST_PHYSDEV_LAYER_REORDER
-    return layer.instance_dispatch_table.EnumeratePhysicalDeviceGroups(instance, pPhysicalDeviceGroupCount,
-                                                                       pPhysicalDeviceGroupProperties);
-#else  // TEST_PHYSDEV_LAYER_REMOVE || TEST_PHYSDEV_LAYER_ADD || TEST_PHYSDEV_LAYER_REORDER
-    VkResult res = VK_SUCCESS;
-
-    if (layer.complete_physical_device_groups.size() == 0) {
-        uint32_t fake_count = 1000;
-        // Call EnumerateDevices to add remove devices as needed
-        test_vkEnumeratePhysicalDevices(instance, &fake_count, nullptr);
-
-        // Get list of all physical devices from lower down
-        // NOTE: This only works if we don't test changing the number of devices
-        //       underneath us when using this test.
-        uint32_t icd_group_count = 0;
-        layer.instance_dispatch_table.EnumeratePhysicalDeviceGroups(instance, &icd_group_count, nullptr);
-        std::vector<VkPhysicalDeviceGroupProperties> tmp_vector(icd_group_count);
-        for (uint32_t group = 0; group < icd_group_count; ++group) {
-            tmp_vector[group].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES;
-        }
-        layer.instance_dispatch_table.EnumeratePhysicalDeviceGroups(instance, &icd_group_count, tmp_vector.data());
-        layer.complete_physical_device_groups.clear();
-
-#if TEST_PHYSDEV_LAYER_REMOVE
-        // Now, if a device has been removed, and it was the only group, we need to remove the group as well.
-        for (uint32_t rem_dev = 0; rem_dev < layer.removed_physical_devices.size(); ++rem_dev) {
+    if (layer.add_phys_devs || layer.remove_phys_devs || layer.reorder_phys_devs) {
+        VkResult res = VK_SUCCESS;
+
+        if (layer.complete_physical_device_groups.size() == 0) {
+            uint32_t fake_count = 1000;
+            // Call EnumerateDevices to add remove devices as needed
+            test_vkEnumeratePhysicalDevices(instance, &fake_count, nullptr);
+
+            // Get list of all physical devices from lower down
+            // NOTE: This only works if we don't test changing the number of devices
+            //       underneath us when using this test.
+            uint32_t icd_group_count = 0;
+            layer.instance_dispatch_table.EnumeratePhysicalDeviceGroups(instance, &icd_group_count, nullptr);
+            std::vector<VkPhysicalDeviceGroupProperties> tmp_vector(icd_group_count);
             for (uint32_t group = 0; group < icd_group_count; ++group) {
-                for (uint32_t grp_dev = 0; grp_dev < tmp_vector[group].physicalDeviceCount; ++grp_dev) {
-                    if (tmp_vector[group].physicalDevices[grp_dev] == layer.removed_physical_devices[rem_dev]) {
-                        for (uint32_t cp_item = grp_dev + 1; cp_item < tmp_vector[group].physicalDeviceCount; ++cp_item) {
-                            tmp_vector[group].physicalDevices[grp_dev] = tmp_vector[group].physicalDevices[cp_item];
+                tmp_vector[group].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES;
+            }
+            layer.instance_dispatch_table.EnumeratePhysicalDeviceGroups(instance, &icd_group_count, tmp_vector.data());
+            layer.complete_physical_device_groups.clear();
+
+            if (layer.remove_phys_devs) {
+                // Now, if a device has been removed, and it was the only group, we need to remove the group as well.
+                for (uint32_t rem_dev = 0; rem_dev < layer.removed_physical_devices.size(); ++rem_dev) {
+                    for (uint32_t group = 0; group < icd_group_count; ++group) {
+                        for (uint32_t grp_dev = 0; grp_dev < tmp_vector[group].physicalDeviceCount; ++grp_dev) {
+                            if (tmp_vector[group].physicalDevices[grp_dev] == layer.removed_physical_devices[rem_dev]) {
+                                for (uint32_t cp_item = grp_dev + 1; cp_item < tmp_vector[group].physicalDeviceCount; ++cp_item) {
+                                    tmp_vector[group].physicalDevices[grp_dev] = tmp_vector[group].physicalDevices[cp_item];
+                                }
+                                tmp_vector[group].physicalDeviceCount--;
+                            }
                         }
-                        tmp_vector[group].physicalDeviceCount--;
+                    }
+                }
+                for (uint32_t group = 0; group < tmp_vector.size(); ++group) {
+                    if (tmp_vector[group].physicalDeviceCount == 0) {
+                        layer.removed_physical_device_groups.push_back(tmp_vector[group]);
+                        tmp_vector.erase(tmp_vector.begin() + group);
+                        --group;
                     }
                 }
             }
-        }
-        for (uint32_t group = 0; group < tmp_vector.size(); ++group) {
-            if (tmp_vector[group].physicalDeviceCount == 0) {
-                layer.removed_physical_device_groups.push_back(tmp_vector[group]);
-                tmp_vector.erase(tmp_vector.begin() + group);
-                --group;
+
+            if (layer.add_phys_devs) {
+                // Add a new group for each physical device not associated with a current group
+                for (uint32_t dev = 0; dev < layer.added_physical_devices.size(); ++dev) {
+                    VkPhysicalDeviceGroupProperties props{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES};
+                    props.physicalDeviceCount = 1;
+                    props.physicalDevices[0] = layer.added_physical_devices[dev];
+                    tmp_vector.push_back(props);
+                    layer.added_physical_device_groups.push_back(props);
+                }
             }
-        }
-#endif  // TEST_PHYSDEV_LAYER_REMOVE
-
-#if TEST_PHYSDEV_LAYER_ADD
-        // Add a new group for each physical device not associated with a current group
-        for (uint32_t dev = 0; dev < layer.added_physical_devices.size(); ++dev) {
-            VkPhysicalDeviceGroupProperties props{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES};
-            props.physicalDeviceCount = 1;
-            props.physicalDevices[0] = layer.added_physical_devices[dev];
-            tmp_vector.push_back(props);
-            layer.added_physical_device_groups.push_back(props);
-        }
-#endif  // TEST_PHYSDEV_LAYER_ADD
 
-#if TEST_PHYSDEV_LAYER_REORDER
-        // Flip the order of items
-        for (int32_t dev = static_cast<int32_t>(tmp_vector.size() - 1); dev >= 0; --dev) {
-            layer.complete_physical_device_groups.push_back(tmp_vector[dev]);
+            if (layer.reorder_phys_devs) {
+                // Flip the order of items
+                for (int32_t dev = static_cast<int32_t>(tmp_vector.size() - 1); dev >= 0; --dev) {
+                    layer.complete_physical_device_groups.push_back(tmp_vector[dev]);
+                }
+            } else {
+                // Otherwise, keep the order the same
+                for (uint32_t dev = 0; dev < tmp_vector.size(); ++dev) {
+                    layer.complete_physical_device_groups.push_back(tmp_vector[dev]);
+                }
+            }
         }
-#else   // !TEST_PHYSDEV_LAYER_REORDER
-        // Otherwise, keep the order the same
-        for (uint32_t dev = 0; dev < tmp_vector.size(); ++dev) {
-            layer.complete_physical_device_groups.push_back(tmp_vector[dev]);
+
+        if (nullptr == pPhysicalDeviceGroupProperties) {
+            *pPhysicalDeviceGroupCount = static_cast<uint32_t>(layer.complete_physical_device_groups.size());
+        } else {
+            uint32_t adj_count = static_cast<uint32_t>(layer.complete_physical_device_groups.size());
+            if (*pPhysicalDeviceGroupCount < adj_count) {
+                adj_count = *pPhysicalDeviceGroupCount;
+                res = VK_INCOMPLETE;
+            }
+            for (uint32_t dev = 0; dev < adj_count; ++dev) {
+                pPhysicalDeviceGroupProperties[dev] = layer.complete_physical_device_groups[dev];
+            }
+            *pPhysicalDeviceGroupCount = adj_count;
         }
-#endif  // !TEST_PHYSDEV_LAYER_REORDER
-    }
 
-    if (nullptr == pPhysicalDeviceGroupProperties) {
-        *pPhysicalDeviceGroupCount = static_cast<uint32_t>(layer.complete_physical_device_groups.size());
+        return res;
     } else {
-        uint32_t adj_count = static_cast<uint32_t>(layer.complete_physical_device_groups.size());
-        if (*pPhysicalDeviceGroupCount < adj_count) {
-            adj_count = *pPhysicalDeviceGroupCount;
-            res = VK_INCOMPLETE;
-        }
-        for (uint32_t dev = 0; dev < adj_count; ++dev) {
-            pPhysicalDeviceGroupProperties[dev] = layer.complete_physical_device_groups[dev];
-        }
-        *pPhysicalDeviceGroupCount = adj_count;
+        return layer.instance_dispatch_table.EnumeratePhysicalDeviceGroups(instance, pPhysicalDeviceGroupCount,
+                                                                           pPhysicalDeviceGroupProperties);
     }
-
-    return res;
-#endif  // TEST_PHYSDEV_LAYER_REMOVE || TEST_PHYSDEV_LAYER_ADD || TEST_PHYSDEV_LAYER_REORDER
 }
 
 // device functions
index 2944a55..d64379f 100644 (file)
@@ -80,21 +80,6 @@ Interface Version 2
 
 // Added manifest version 1.1.0
 
-// vkEnumeratePhysicalDevices and vkEnumeratePhysicalDeviceGroups add a new item
-#ifndef TEST_PHYSDEV_LAYER_ADD
-#define TEST_PHYSDEV_LAYER_ADD 0
-#endif
-
-// vkEnumeratePhysicalDevices and vkEnumeratePhysicalDeviceGroups remove an item
-#ifndef TEST_PHYSDEV_LAYER_REMOVE
-#define TEST_PHYSDEV_LAYER_REMOVE 0
-#endif
-
-// vkEnumeratePhysicalDevices and vkEnumeratePhysicalDeviceGroups reorders items
-#ifndef TEST_PHYSDEV_LAYER_REORDER
-#define TEST_PHYSDEV_LAYER_REORDER 0
-#endif
-
 struct TestLayer;
 
 // Callbacks allow tests to implement custom functionality without modifying the layer binary
@@ -133,14 +118,18 @@ struct TestLayer {
     BUILDER_VALUE(TestLayer, std::function<VkResult(TestLayer& layer)>, create_instance_callback, {})
     // Called in vkCreateDevice after calling down the chain & returning
     BUILDER_VALUE(TestLayer, std::function<VkResult(TestLayer& layer)>, create_device_callback, {})
-#if TEST_PHYSDEV_LAYER_REMOVE || TEST_PHYSDEV_LAYER_ADD || TEST_PHYSDEV_LAYER_REORDER
+
+    // Physical device modifier test flags and members.  This data is primarily used to test adding, removing and
+    // re-ordering physical device data in a layer.
+    BUILDER_VALUE(TestLayer, bool, add_phys_devs, false)
+    BUILDER_VALUE(TestLayer, bool, remove_phys_devs, false)
+    BUILDER_VALUE(TestLayer, bool, reorder_phys_devs, false)
     BUILDER_VECTOR(TestLayer, VkPhysicalDevice, complete_physical_devices, complete_physical_device)
     BUILDER_VECTOR(TestLayer, VkPhysicalDevice, removed_physical_devices, removed_physical_device)
     BUILDER_VECTOR(TestLayer, VkPhysicalDevice, added_physical_devices, added_physical_device)
     BUILDER_VECTOR(TestLayer, VkPhysicalDeviceGroupProperties, complete_physical_device_groups, complete_physical_device_group)
     BUILDER_VECTOR(TestLayer, VkPhysicalDeviceGroupProperties, removed_physical_device_groups, removed_physical_device_group)
     BUILDER_VECTOR(TestLayer, VkPhysicalDeviceGroupProperties, added_physical_device_groups, added_physical_device_group)
-#endif // TEST_PHYSDEV_LAYER_REMOVE || TEST_PHYSDEV_LAYER_ADD || TEST_PHYSDEV_LAYER_REORDER
 
     PFN_vkGetInstanceProcAddr next_vkGetInstanceProcAddr = VK_NULL_HANDLE;
     PFN_GetPhysicalDeviceProcAddr next_GetPhysicalDeviceProcAddr = VK_NULL_HANDLE;
index 8db2280..f81c698 100644 (file)
@@ -2782,10 +2782,13 @@ TEST_F(LayerPhysDeviceMod, AddPhysicalDevices) {
     FrameworkEnvironment env;
     env.add_implicit_layer(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
                                                          .set_name("VkLayer_LunarG_add_phys_dev")
-                                                         .set_lib_path(TEST_LAYER_PHYSDEV_ADD)
+                                                         .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
                                                          .set_api_version(VK_API_VERSION_1_1)
                                                          .set_disable_environment("TEST_DISABLE_ADD_PHYS_DEV")),
-                           "test_layer_remove.json");
+                           "test_layer_add.json");
+
+    auto& layer = env.get_test_layer(0);
+    layer.set_add_phys_devs(true);
 
     for (uint32_t icd = 0; icd < 2; ++icd) {
         env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));
@@ -2862,11 +2865,14 @@ TEST_F(LayerPhysDeviceMod, RemovePhysicalDevices) {
     FrameworkEnvironment env;
     env.add_implicit_layer(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
                                                          .set_name("VkLayer_LunarG_remove_phys_dev")
-                                                         .set_lib_path(TEST_LAYER_PHYSDEV_REMOVE)
+                                                         .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
                                                          .set_api_version(VK_API_VERSION_1_1)
                                                          .set_disable_environment("TEST_DISABLE_REMOVE_PHYS_DEV")),
                            "test_layer_remove.json");
 
+    auto& layer = env.get_test_layer(0);
+    layer.set_remove_phys_devs(true);
+
     for (uint32_t icd = 0; icd < 2; ++icd) {
         env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));
         auto& cur_icd = env.get_test_icd(icd);
@@ -2915,11 +2921,14 @@ TEST_F(LayerPhysDeviceMod, ReorderPhysicalDevices) {
     FrameworkEnvironment env;
     env.add_implicit_layer(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
                                                          .set_name("VkLayer_LunarG_reorder_phys_dev")
-                                                         .set_lib_path(TEST_LAYER_PHYSDEV_REORDER)
+                                                         .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
                                                          .set_api_version(VK_API_VERSION_1_1)
                                                          .set_disable_environment("TEST_DISABLE_REORDER_PHYS_DEV")),
                            "test_layer_reorder.json");
 
+    auto& layer = env.get_test_layer(0);
+    layer.set_reorder_phys_devs(true);
+
     for (uint32_t icd = 0; icd < 2; ++icd) {
         env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));
         auto& cur_icd = env.get_test_icd(icd);
@@ -2968,11 +2977,14 @@ TEST_F(LayerPhysDeviceMod, AddRemoveAndReorderPhysicalDevices) {
     FrameworkEnvironment env;
     env.add_implicit_layer(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
                                                          .set_name("VkLayer_LunarG_all_phys_dev")
-                                                         .set_lib_path(TEST_LAYER_PHYSDEV_ALL)
+                                                         .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
                                                          .set_api_version(VK_API_VERSION_1_1)
                                                          .set_disable_environment("TEST_DISABLE_ALL_PHYS_DEV")),
                            "test_layer_all.json");
 
+    auto& layer = env.get_test_layer(0);
+    layer.set_add_phys_devs(true).set_remove_phys_devs(true).set_reorder_phys_devs(true);
+
     for (uint32_t icd = 0; icd < 2; ++icd) {
         env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));
         auto& cur_icd = env.get_test_icd(icd);
@@ -3047,11 +3059,14 @@ TEST_F(LayerPhysDeviceMod, AddPhysicalDeviceGroups) {
     FrameworkEnvironment env;
     env.add_implicit_layer(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
                                                          .set_name("VkLayer_LunarG_add_phys_dev")
-                                                         .set_lib_path(TEST_LAYER_PHYSDEV_ADD)
+                                                         .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
                                                          .set_api_version(VK_API_VERSION_1_1)
                                                          .set_disable_environment("TEST_DISABLE_ADD_PHYS_DEV")),
                            "test_layer_remove.json");
 
+    auto& layer = env.get_test_layer(0);
+    layer.set_add_phys_devs(true);
+
     for (uint32_t icd = 0; icd < 2; ++icd) {
         env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));
         auto& cur_icd = env.get_test_icd(icd);
@@ -3138,11 +3153,14 @@ TEST_F(LayerPhysDeviceMod, RemovePhysicalDeviceGroups) {
     FrameworkEnvironment env;
     env.add_implicit_layer(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
                                                          .set_name("VkLayer_LunarG_remove_phys_dev")
-                                                         .set_lib_path(TEST_LAYER_PHYSDEV_REMOVE)
+                                                         .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
                                                          .set_api_version(VK_API_VERSION_1_1)
                                                          .set_disable_environment("TEST_DISABLE_REMOVE_PHYS_DEV")),
                            "test_layer_remove.json");
 
+    auto& layer = env.get_test_layer(0);
+    layer.set_remove_phys_devs(true);
+
     for (uint32_t icd = 0; icd < 2; ++icd) {
         env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));
         auto& cur_icd = env.get_test_icd(icd);
@@ -3190,11 +3208,14 @@ TEST_F(LayerPhysDeviceMod, ReorderPhysicalDeviceGroups) {
     FrameworkEnvironment env;
     env.add_implicit_layer(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
                                                          .set_name("VkLayer_LunarG_reorder_phys_dev")
-                                                         .set_lib_path(TEST_LAYER_PHYSDEV_REORDER)
+                                                         .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
                                                          .set_api_version(VK_API_VERSION_1_1)
                                                          .set_disable_environment("TEST_DISABLE_REORDER_PHYS_DEV")),
                            "test_layer_reorder.json");
 
+    auto& layer = env.get_test_layer(0);
+    layer.set_reorder_phys_devs(true);
+
     for (uint32_t icd = 0; icd < 2; ++icd) {
         env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));
         auto& cur_icd = env.get_test_icd(icd);
@@ -3246,11 +3267,14 @@ TEST_F(LayerPhysDeviceMod, AddRemoveAndReorderPhysicalDeviceGroups) {
     FrameworkEnvironment env;
     env.add_implicit_layer(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
                                                          .set_name("VkLayer_LunarG_all_phys_dev")
-                                                         .set_lib_path(TEST_LAYER_PHYSDEV_ALL)
+                                                         .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
                                                          .set_api_version(VK_API_VERSION_1_1)
                                                          .set_disable_environment("TEST_DISABLE_ALL_PHYS_DEV")),
                            "test_layer_all.json");
 
+    auto& layer = env.get_test_layer(0);
+    layer.set_add_phys_devs(true).set_remove_phys_devs(true).set_reorder_phys_devs(true);
+
     for (uint32_t icd = 0; icd < 2; ++icd) {
         env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));
         auto& cur_icd = env.get_test_icd(icd);