Warn when the apiVersion's variant isn't 0
authorCharles Giessen <charles@lunarg.com>
Wed, 26 Jan 2022 20:37:04 +0000 (13:37 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Fri, 28 Jan 2022 23:24:27 +0000 (16:24 -0700)
The 1.2.175 header release saw the addition of API Variants. For the purposes
of the loader, this should always be set to 0. If this value isn't zero, the
loader should warn about it.

loader/trampoline.c
tests/loader_version_tests.cpp

index 42580e3ea429de2afee695dd5ef532c721be07b0..4828c0c6b5657dc06283ed76d8b2440663994570 100644 (file)
@@ -516,6 +516,17 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
         }
     }
 
+    // Make sure the application provided API version has 0 for its variant
+    if (NULL != pCreateInfo->pApplicationInfo) {
+        uint32_t variant_version = VK_API_VERSION_VARIANT(pCreateInfo->pApplicationInfo->apiVersion);
+        if (0 != variant_version) {
+            loader_log(ptr_instance, VULKAN_LOADER_WARN_BIT, 0,
+                       "vkCreateInstance: The API Variant specified in pCreateInfo->pApplicationInfo.apiVersion is %d instead of "
+                       "the expected value of 0.",
+                       variant_version);
+        }
+    }
+
     // Due to implicit layers need to get layer list even if
     // enabledLayerCount == 0 and VK_INSTANCE_LAYERS is unset. For now always
     // get layer list via loader_scan_for_layers().
index 4cfc09494c45314d618fbf34544386e5d542ab1c..0b7b7978187acff59f41e769e4d991a8e784678f 100644 (file)
@@ -595,4 +595,19 @@ TEST(MinorVersionUpdate, Version1_3) {
     QueueSubmit2(nullptr, 0, nullptr, VK_NULL_HANDLE);
     auto SetPrivateData = reinterpret_cast<PFN_vkSetPrivateData>(inst.functions->vkGetDeviceProcAddr(device, "vkSetPrivateData"));
     SetPrivateData(device, VK_OBJECT_TYPE_UNKNOWN, 0, {}, 0);
+}
+
+TEST(ApplicationInfoVersion, NonVulkanVariant) {
+    FrameworkEnvironment env{};
+    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6));
+    env.get_test_icd().physical_devices.push_back({});
+
+    DebugUtilsLogger log;
+    InstWrapper inst{env.vulkan_functions};
+    inst.create_info.set_api_version(VK_MAKE_API_VERSION(1, 0, 0, 0));
+    FillDebugUtilsCreateDetails(inst.create_info, log);
+    inst.CheckCreate();
+    ASSERT_TRUE(log.find(
+        std::string("vkCreateInstance: The API Variant specified in pCreateInfo->pApplicationInfo.apiVersion is 1 instead of "
+                    "the expected value of 0.")));
 }
\ No newline at end of file