diff options
Diffstat (limited to 'layers/image.cpp')
| -rw-r--r-- | layers/image.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/layers/image.cpp b/layers/image.cpp index fd4e1338..bba0ffd3 100644 --- a/layers/image.cpp +++ b/layers/image.cpp @@ -72,6 +72,8 @@ struct layer_data { physicalDeviceProperties(){}; }; +static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION; + static unordered_map<void *, layer_data *> layer_data_map; static std::mutex global_lock; @@ -136,7 +138,6 @@ CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallba my_data->instance = *pInstance; my_data->instance_dispatch_table = new VkLayerInstanceDispatchTable; layer_init_instance_dispatch_table(*pInstance, my_data->instance_dispatch_table, fpGetInstanceProcAddr); - my_data->report_data = debug_report_create_instance(my_data->instance_dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, pCreateInfo->ppEnabledExtensionNames); @@ -1319,6 +1320,17 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance return pTable->GetInstanceProcAddr(instance, funcName); } +VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { + assert(instance); + + layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); + + VkLayerInstanceDispatchTable *pTable = my_data->instance_dispatch_table; + if (pTable->GetPhysicalDeviceProcAddr == NULL) + return NULL; + return pTable->GetPhysicalDeviceProcAddr(instance, funcName); +} + static PFN_vkVoidFunction intercept_core_instance_command(const char *name) { static const struct { @@ -1334,6 +1346,7 @@ intercept_core_instance_command(const char *name) { { "vkEnumerateInstanceExtensionProperties", reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceExtensionProperties) }, { "vkEnumerateDeviceExtensionProperties", reinterpret_cast<PFN_vkVoidFunction>(EnumerateDeviceExtensionProperties) }, { "vkGetPhysicalDeviceProperties", reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceProperties) }, + { "vk_layerGetPhysicalDeviceProcAddr", reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceProcAddr) }, }; for (size_t i = 0; i < ARRAY_SIZE(core_instance_commands); i++) { @@ -1432,3 +1445,27 @@ VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkD VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { return image::GetInstanceProcAddr(instance, funcName); } + +VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { + return image::GetPhysicalDeviceProcAddr(instance, funcName); +} + +VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) { + assert(pVersionStruct != NULL); + assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT); + + // Fill in the function pointers if our version is at least capable of having the structure contain them. + if (pVersionStruct->loaderLayerInterfaceVersion >= 2) { + pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr; + pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr; + pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr; + } + + if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) { + image::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion; + } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) { + pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION; + } + + return VK_SUCCESS; +} |
