Only check first GPDPA in the layer chain.

When checking for unknown physical device functions, check the first layer that supports
vk_layerGetPhysicalDeviceProcAddr in the chain starting with the layer closest to the
application. This prevents unecessary work being done, and if any layer wraps VkInstance
will properly call through the wrapping layer first without calling into any other layer.
This commit is contained in:
Charles Giessen 2022-06-06 12:05:52 -06:00 committed by Charles Giessen
parent d3db2f78d9
commit c3601d4d91
2 changed files with 17 additions and 8 deletions

View File

@ -178,18 +178,17 @@ bool loader_check_icds_for_phys_dev_ext_address(struct loader_instance *inst, co
bool loader_check_layer_list_for_phys_dev_ext_address(struct loader_instance *inst, const char *funcName) {
struct loader_layer_properties *layer_prop_list = inst->expanded_activated_layer_list.list;
for (uint32_t layer = 0; layer < inst->expanded_activated_layer_list.count; ++layer) {
// If this layer supports the vk_layerGetPhysicalDeviceProcAddr, then call
// it and see if it returns a valid pointer for this function name.
for (uint32_t layer = 0; layer < inst->expanded_activated_layer_list.count; layer++) {
// Find the first layer in the call chain which supports vk_layerGetPhysicalDeviceProcAddr
// and call that, returning whether it found a valid pointer for this function name.
// We return if the topmost layer supports GPDPA since the layer should call down the chain for us.
if (layer_prop_list[layer].interface_version > 1) {
const struct loader_layer_functions *const functions = &(layer_prop_list[layer].functions);
if (NULL != functions->get_physical_device_proc_addr &&
NULL != functions->get_physical_device_proc_addr((VkInstance)inst->instance, funcName)) {
return true;
if (NULL != functions->get_physical_device_proc_addr) {
return NULL != functions->get_physical_device_proc_addr((VkInstance)inst->instance, funcName);
}
}
}
return false;
}
@ -327,4 +326,4 @@ void *loader_phys_dev_ext_gpa_term_no_check(struct loader_instance *inst, const
}
return NULL;
}
}

View File

@ -445,6 +445,12 @@ VKAPI_ATTR void VKAPI_CALL test_vkDestroyDevice(VkDevice device, const VkAllocat
}
}
}
// forward declarations needed for trampolines
#if TEST_LAYER_EXPORT_GET_PHYSICAL_DEVICE_PROC_ADDR
extern "C" {
FRAMEWORK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance, const char* pName);
}
#endif
// trampolines
@ -467,6 +473,10 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL get_physical_device_func(VkInstance ins
return to_vkVoidFunction(func.function);
}
}
#if TEST_LAYER_EXPORT_GET_PHYSICAL_DEVICE_PROC_ADDR
if (string_eq(pName, "vk_layerGetPhysicalDeviceProcAddr")) return to_vkVoidFunction(vk_layerGetPhysicalDeviceProcAddr);
#endif
return nullptr;
}