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

Enable VK_KHR_maintenance_5 support #1268

Merged
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
372 changes: 186 additions & 186 deletions loader/generated/vk_loader_extensions.c

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5850,6 +5850,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical
dev->extensions.ext_debug_marker_enabled = true;
} else if (!strcmp(localCreateInfo.ppEnabledExtensionNames[i], "VK_EXT_full_screen_exclusive")) {
dev->extensions.ext_full_screen_exclusive_enabled = true;
} else if (!strcmp(localCreateInfo.ppEnabledExtensionNames[i], VK_KHR_MAINTENANCE_5_EXTENSION_NAME)) {
dev->should_ignore_device_commands_from_newer_version = true;
}
}
dev->extensions.ext_debug_utils_enabled = icd_term->this_instance->enabled_known_extensions.ext_debug_utils;
Expand Down
8 changes: 4 additions & 4 deletions loader/loader_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ struct loader_device {
} extensions;

struct loader_device *next;

// Makes vkGetDeviceProcAddr check if core functions are supported by the current app_api_version.
// Only set to true if VK_KHR_maintenance5 is enabled.
bool should_ignore_device_commands_from_newer_version;
};

// Per ICD information
Expand Down Expand Up @@ -359,10 +363,6 @@ struct loader_instance {
bool wsi_display_props2_enabled;
bool create_terminator_invalid_extension;
bool supports_get_dev_prop_2;

// Makes vkGetDeviceProcAddr check if core functions are supported by the current app_api_version
// Currently unused
bool should_ignore_device_commands_from_newer_version;
};

// VkPhysicalDevice requires special treatment by loader. Firstly, terminator
Expand Down
2 changes: 1 addition & 1 deletion loader/trampoline.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDev
const struct loader_instance *inst = icd_term->this_instance;
uint32_t api_version =
VK_MAKE_API_VERSION(0, inst->app_api_version.major, inst->app_api_version.minor, inst->app_api_version.patch);
return (inst->should_ignore_device_commands_from_newer_version && api_version < VK_API_VERSION_1_1)
return (dev->should_ignore_device_commands_from_newer_version && api_version < VK_API_VERSION_1_1)
? NULL
: (PFN_vkVoidFunction)vkGetDeviceQueue2;
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/loader_extension_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ def OutputLoaderLookupFunc(self):
if 'VK_VERSION_' in cur_cmd.ext_name:
tables += '\n // ---- Core %s commands\n' % cur_cmd.ext_name[11:]
if cur_type == 'device':
version_check = f' if (inst->should_ignore_device_commands_from_newer_version && api_version < VK_API_VERSION_{cur_cmd.ext_name[11:]}) return NULL;\n'
version_check = f' if (dev->should_ignore_device_commands_from_newer_version && api_version < VK_API_VERSION_{cur_cmd.ext_name[11:]}) return NULL;\n'
else:

tables += '\n // ---- %s extension commands\n' % cur_cmd.ext_name
Expand Down
67 changes: 49 additions & 18 deletions tests/loader_get_proc_addr_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,22 +303,22 @@ TEST(GetProcAddr, PreserveLayerGettingVkCreateDeviceWithNullInstance) {

// The following tests - AppQueries11FunctionsWhileOnlyEnabling10, AppQueries12FunctionsWhileOnlyEnabling11, and
// AppQueries13FunctionsWhileOnlyEnabling12 - check that vkGetDeviceProcAddr only returning functions from core versions up to
// the apiVersion declared in VkApplicationInfo. They currently are partially implemented. as this behavior is not active.
// Future commits will add the mechanism to enable this behavior. The tests currently make sure that the existing behavior is not
// affected by the changes made in this commit.
// the apiVersion declared in VkApplicationInfo. Function querying should succeed if VK_KHR_maintenance_5 is not enabled, and they
// should return zero when that extension is enabled.

TEST(GetDeviceProcAddr, AppQueries11FunctionsWhileOnlyEnabling10) {
FrameworkEnvironment env{};
auto& driver = env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2, VK_API_VERSION_1_1))
.set_icd_api_version(VK_API_VERSION_1_1)
.add_physical_device(PhysicalDevice{}.set_api_version(VK_API_VERSION_1_1).finish());
auto& driver =
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2, VK_API_VERSION_1_1))
.set_icd_api_version(VK_API_VERSION_1_1)
.add_physical_device(
PhysicalDevice{}.set_api_version(VK_API_VERSION_1_1).add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME).finish());

std::vector<const char*> functions = {"vkGetDeviceQueue2", "vkCmdDispatchBase", "vkCreateDescriptorUpdateTemplate"};
for (const auto& f : functions) {
driver.physical_devices.back().add_device_function(VulkanFunction{f, [] {}});
}
{
// Positive testing - behavior not active
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 0, 0);
inst.CheckCreate();
Expand All @@ -330,22 +330,32 @@ TEST(GetDeviceProcAddr, AppQueries11FunctionsWhileOnlyEnabling10) {
}
}
{
// Negative testing - need to implement once behavior is incorporated
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 0, 0);
inst.CheckCreate();

DeviceWrapper dev{inst};
dev.create_info.add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
dev.CheckCreate(inst.GetPhysDev());
for (const auto& f : functions) {
ASSERT_EQ(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
}

TEST(GetDeviceProcAddr, AppQueries12FunctionsWhileOnlyEnabling11) {
FrameworkEnvironment env{};
auto& driver = env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2, VK_API_VERSION_1_2))
.set_icd_api_version(VK_API_VERSION_1_2)
.add_physical_device(PhysicalDevice{}.set_api_version(VK_API_VERSION_1_2).finish());
auto& driver =
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2, VK_API_VERSION_1_2))
.set_icd_api_version(VK_API_VERSION_1_2)
.add_physical_device(
PhysicalDevice{}.set_api_version(VK_API_VERSION_1_2).add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME).finish());
std::vector<const char*> functions = {"vkCmdDrawIndirectCount", "vkCmdNextSubpass2", "vkGetBufferDeviceAddress",
"vkGetDeviceMemoryOpaqueCaptureAddress"};
for (const auto& f : functions) {
driver.physical_devices.back().add_device_function(VulkanFunction{f, [] {}});
}
{
// Positive testing - behavior not active
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 1, 0);
inst.CheckCreate();
Expand All @@ -358,23 +368,34 @@ TEST(GetDeviceProcAddr, AppQueries12FunctionsWhileOnlyEnabling11) {
}
}
{
// Negative testing - need to implement once behavior is incorporated
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 1, 0);
inst.CheckCreate();

DeviceWrapper dev{inst};
dev.create_info.add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
dev.CheckCreate(inst.GetPhysDev());

for (const auto& f : functions) {
ASSERT_EQ(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
}

TEST(GetDeviceProcAddr, AppQueries13FunctionsWhileOnlyEnabling12) {
FrameworkEnvironment env{};
auto& driver = env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2, VK_API_VERSION_1_3))
.set_icd_api_version(VK_API_VERSION_1_3)
.add_physical_device(PhysicalDevice{}.set_api_version(VK_API_VERSION_1_3).finish());
auto& driver =
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2, VK_API_VERSION_1_3))
.set_icd_api_version(VK_API_VERSION_1_3)
.add_physical_device(
PhysicalDevice{}.set_api_version(VK_API_VERSION_1_3).add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME).finish());
std::vector<const char*> functions = {"vkCreatePrivateDataSlot", "vkGetDeviceBufferMemoryRequirements", "vkCmdWaitEvents2",
"vkGetDeviceImageSparseMemoryRequirements"};

for (const auto& f : functions) {
driver.physical_devices.back().add_device_function(VulkanFunction{f, [] {}});
}
{
// Positive testing - behavior not active
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 2, 0);
inst.CheckCreate();
Expand All @@ -387,6 +408,16 @@ TEST(GetDeviceProcAddr, AppQueries13FunctionsWhileOnlyEnabling12) {
}
}
{
// Negative testing - need to implement once behavior is incorporated
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(1, 2, 0);
inst.CheckCreate();

DeviceWrapper dev{inst};
dev.create_info.add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
dev.CheckCreate(inst.GetPhysDev());

for (const auto& f : functions) {
ASSERT_EQ(nullptr, dev->vkGetDeviceProcAddr(dev.dev, f));
}
}
}