Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when ICD Manifest version differs from VkPhysicalDevice #1251

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5419,7 +5419,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI
"terminator_CreateInstance: ICD \"%s\" vkEnumerateInstanceVersion returned error. The ICD will be "
"treated as a 1.0 ICD",
icd_term->scanned_icd->lib_name);
} else if (VK_API_VERSION_MINOR(icd_version) == 0) {
loader_log(ptr_instance, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
"terminator_CreateInstance: Manifest ICD for \"%s\" contained a 1.1 or greater API version, but "
"vkEnumerateInstanceVersion returned 1.0, treating as a 1.0 ICD",
icd_term->scanned_icd->lib_name);
}
} else {
loader_log(ptr_instance, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
"terminator_CreateInstance: Manifest ICD for \"%s\" contained a 1.1 or greater API version, but does "
"not support vkEnumerateInstanceVersion, treating as a 1.0 ICD",
icd_term->scanned_icd->lib_name);
}
}

Expand Down
13 changes: 10 additions & 3 deletions tests/framework/icd/test_icd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkEnumerateInstanceLayerProperties(uint32_t*

VKAPI_ATTR VkResult VKAPI_CALL test_vkEnumerateInstanceVersion(uint32_t* pApiVersion) {
if (pApiVersion != nullptr) {
*pApiVersion = VK_API_VERSION_1_0;
*pApiVersion = icd.icd_api_version;
}
return VK_SUCCESS;
}
Expand Down Expand Up @@ -267,6 +267,9 @@ test_vkEnumeratePhysicalDeviceGroups([[maybe_unused]] VkInstance instance, uint3
pPhysicalDeviceGroupProperties[device_group].physicalDeviceCount = 1;
pPhysicalDeviceGroupProperties[device_group].physicalDevices[0] =
icd.physical_devices[device_group].vk_physical_device.handle;
for (size_t i = 1; i < VK_MAX_DEVICE_GROUP_SIZE; i++) {
pPhysicalDeviceGroupProperties[device_group].physicalDevices[i] = {};
}
}
} else {
group_count = static_cast<uint32_t>(icd.physical_device_groups.size());
Expand All @@ -284,6 +287,9 @@ test_vkEnumeratePhysicalDeviceGroups([[maybe_unused]] VkInstance instance, uint3
pPhysicalDeviceGroupProperties[device_group].physicalDevices[i] =
icd.physical_device_groups[device_group].physical_device_handles[i]->vk_physical_device.handle;
}
for (size_t i = handles_written; i < VK_MAX_DEVICE_GROUP_SIZE; i++) {
pPhysicalDeviceGroupProperties[device_group].physicalDevices[i] = {};
}
pPhysicalDeviceGroupProperties[device_group].physicalDeviceCount = handles_written;
}
}
Expand Down Expand Up @@ -1162,7 +1168,7 @@ FRAMEWORK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDe
PFN_vkVoidFunction get_instance_func_ver_1_1([[maybe_unused]] VkInstance instance, const char* pName) {
if (icd.icd_api_version >= VK_API_VERSION_1_1) {
if (string_eq(pName, "test_vkEnumerateInstanceVersion")) {
return to_vkVoidFunction(test_vkEnumerateInstanceVersion);
return icd.can_query_vkEnumerateInstanceVersion ? to_vkVoidFunction(test_vkEnumerateInstanceVersion) : nullptr;
}
if (string_eq(pName, "vkEnumeratePhysicalDeviceGroups")) {
return to_vkVoidFunction(test_vkEnumeratePhysicalDeviceGroups);
Expand Down Expand Up @@ -1549,7 +1555,8 @@ PFN_vkVoidFunction base_get_instance_proc_addr(VkInstance instance, const char*
: NULL;
if (string_eq(pName, "vkEnumerateInstanceLayerProperties"))
return to_vkVoidFunction(test_vkEnumerateInstanceLayerProperties);
if (string_eq(pName, "vkEnumerateInstanceVersion")) return to_vkVoidFunction(test_vkEnumerateInstanceVersion);
if (string_eq(pName, "vkEnumerateInstanceVersion"))
return icd.can_query_vkEnumerateInstanceVersion ? to_vkVoidFunction(test_vkEnumerateInstanceVersion) : nullptr;
if (string_eq(pName, "vkCreateInstance")) return to_vkVoidFunction(test_vkCreateInstance);
}
if (string_eq(pName, "vkGetDeviceProcAddr")) return to_vkVoidFunction(test_vkGetDeviceProcAddr);
Expand Down
2 changes: 2 additions & 0 deletions tests/framework/icd/test_icd.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ struct TestICD {
std::vector<uint64_t> messenger_handles;
std::vector<uint64_t> swapchain_handles;

BUILDER_VALUE(TestICD, bool, can_query_vkEnumerateInstanceVersion, true);

// Unknown instance functions Add a `VulkanFunction` to this list which will be searched in
// vkGetInstanceProcAddr for custom_instance_functions and vk_icdGetPhysicalDeviceProcAddr for
// custom_physical_device_functions. To add unknown device functions, add it to the PhysicalDevice directly (in the
Expand Down
8 changes: 3 additions & 5 deletions tests/framework/layer/test_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#endif

#if !defined(TEST_LAYER_NAME)
#define TEST_LAYER_NAME "VkLayer_LunarG_test_layer"
#define TEST_LAYER_NAME "VK_LAYER_LunarG_test_layer"
#endif

TestLayer layer;
Expand Down Expand Up @@ -457,10 +457,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkEnumeratePhysicalDeviceGroups(
// 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;
}
std::vector<VkPhysicalDeviceGroupProperties> tmp_vector(icd_group_count,
{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();

Expand Down
2 changes: 1 addition & 1 deletion tests/loader_alloc_callback_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ TEST(Allocation, CreateInstanceDeviceIntentionalAllocFail) {
custom_json_file_contents << custom_json_file.rdbuf();

fs::path new_path = env.get_folder(ManifestLocation::explicit_layer)
.write_manifest("VkLayer_complex_file.json", custom_json_file_contents.str());
.write_manifest("VK_LAYER_complex_file.json", custom_json_file_contents.str());
env.platform_shim->add_manifest(ManifestCategory::explicit_layer, new_path);

size_t fail_index = 0;
Expand Down
Loading