diff options
Diffstat (limited to 'loader')
| -rw-r--r-- | loader/CMakeLists.txt | 26 | ||||
| -rw-r--r-- | loader/debug_report.c | 59 | ||||
| -rw-r--r-- | loader/debug_report.h | 169 | ||||
| -rw-r--r-- | loader/extensions.c | 694 | ||||
| -rw-r--r-- | loader/extensions.h | 96 | ||||
| -rw-r--r-- | loader/gpa_helper.h | 1 | ||||
| -rw-r--r-- | loader/loader.c | 1014 | ||||
| -rw-r--r-- | loader/loader.h | 188 | ||||
| -rw-r--r-- | loader/trampoline.c | 133 | ||||
| -rw-r--r-- | loader/wsi.c | 362 | ||||
| -rw-r--r-- | loader/wsi.h | 14 |
11 files changed, 791 insertions, 1965 deletions
diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 05bbfbf5..d4abafff 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -1,7 +1,10 @@ include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_PROJECT_BINARY_DIR} + ${CMAKE_BINARY_DIR} ) + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN) set(DisplayServer Win32) @@ -47,11 +50,8 @@ set(NORMAL_LOADER_SRCS trampoline.c wsi.c wsi.h - extensions.c - extensions.h debug_report.c debug_report.h - table_ops.h gpa_helper.h cJSON.c cJSON.h @@ -59,14 +59,14 @@ set(NORMAL_LOADER_SRCS murmurhash.h ) -set (OPT_LOADER_SRCS +set(OPT_LOADER_SRCS dev_ext_trampoline.c phys_dev_ext.c ) -set (LOADER_SRCS ${NORMAL_LOADER_SRCS} ${OPT_LOADER_SRCS}) add_definitions(-DAPI_NAME="${API_NAME}") + if (WIN32) # Use static MSVCRT libraries foreach(configuration in CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO @@ -85,8 +85,12 @@ if (WIN32) separate_arguments(LOCAL_C_FLAGS_REL WINDOWS_COMMAND ${CMAKE_C_FLAGS_RELEASE}) add_library(loader-norm OBJECT ${NORMAL_LOADER_SRCS} dirent_on_windows.c) + add_dependencies(loader-norm generate_helper_files) + target_compile_options(loader-norm PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_DBG}>") add_library(loader-opt OBJECT ${OPT_LOADER_SRCS}) + add_dependencies(loader-opt generate_helper_files) + target_compile_options(loader-opt PUBLIC "$<$<CONFIG:DEBUG>:${LOCAL_C_FLAGS_REL}>") add_library(${API_LOWERCASE}-${MAJOR} SHARED $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm> ${CMAKE_CURRENT_BINARY_DIR}/${API_LOWERCASE}-${MAJOR}.def ${CMAKE_CURRENT_SOURCE_DIR}/loader.rc) add_library(VKstatic.${MAJOR} STATIC $<TARGET_OBJECTS:loader-opt> $<TARGET_OBJECTS:loader-norm>) @@ -94,6 +98,8 @@ if (WIN32) set_target_properties(${API_LOWERCASE}-${MAJOR} PROPERTIES LINK_FLAGS_DEBUG /ignore:4098) set_target_properties(VKstatic.${MAJOR} PROPERTIES OUTPUT_NAME VKstatic.${MAJOR}) target_link_libraries(${API_LOWERCASE}-${MAJOR} shlwapi) + add_dependencies(${API_LOWERCASE}-${MAJOR} generate_helper_files) + target_link_libraries(VKstatic.${MAJOR} shlwapi) if (CMAKE_GENERATOR MATCHES "^Visual Studio.*") file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${API_LOWERCASE}-${MAJOR}.dll COPY_SRC_PATH) @@ -112,8 +118,10 @@ if (WIN32) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith") - add_library(${API_LOWERCASE} SHARED ${LOADER_SRCS}) - set_target_properties(${API_LOWERCASE} PROPERTIES SOVERSION "1" VERSION "1.0.41") + add_library(${API_LOWERCASE} SHARED ${NORMAL_LOADER_SRCS} ${OPT_LOADER_SRCS}) + add_dependencies(${API_LOWERCASE} generate_helper_files) + set_target_properties(${API_LOWERCASE} PROPERTIES SOVERSION "1" VERSION "1.0.42") target_link_libraries(${API_LOWERCASE} -ldl -lpthread -lm) + install(TARGETS ${API_LOWERCASE} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() diff --git a/loader/debug_report.c b/loader/debug_report.c index bd46282a..04e55ccf 100644 --- a/loader/debug_report.c +++ b/loader/debug_report.c @@ -272,15 +272,12 @@ static VKAPI_ATTR void VKAPI_CALL debug_report_DebugReportMessageEXT(VkInstance inst->disp->layer_inst_disp.DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); } -/* - * This is the instance chain terminator function - * for CreateDebugReportCallback - */ - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugReportCallback(VkInstance instance, - const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDebugReportCallbackEXT *pCallback) { +// This is the instance chain terminator function +// for CreateDebugReportCallback +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugReportCallbackEXT(VkInstance instance, + const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkDebugReportCallbackEXT *pCallback) { VkDebugReportCallbackEXT *icd_info = NULL; const struct loader_icd_term *icd_term; struct loader_instance *inst = (struct loader_instance *)instance; @@ -309,11 +306,11 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugReportCallback(VkInstance i storage_idx = 0; for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { - if (!icd_term->CreateDebugReportCallbackEXT) { + if (!icd_term->dispatch.CreateDebugReportCallbackEXT) { continue; } - res = icd_term->CreateDebugReportCallbackEXT(icd_term->instance, pCreateInfo, pAllocator, &icd_info[storage_idx]); + res = icd_term->dispatch.CreateDebugReportCallbackEXT(icd_term->instance, pCreateInfo, pAllocator, &icd_info[storage_idx]); if (res != VK_SUCCESS) { goto out; @@ -356,12 +353,12 @@ out: if (VK_SUCCESS != res) { storage_idx = 0; for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { - if (NULL == icd_term->DestroyDebugReportCallbackEXT) { + if (NULL == icd_term->dispatch.DestroyDebugReportCallbackEXT) { continue; } if (icd_info && icd_info[storage_idx]) { - icd_term->DestroyDebugReportCallbackEXT(icd_term->instance, icd_info[storage_idx], pAllocator); + icd_term->dispatch.DestroyDebugReportCallbackEXT(icd_term->instance, icd_info[storage_idx], pAllocator); } storage_idx++; } @@ -390,12 +387,9 @@ out: return res; } -/* - * This is the instance chain terminator function - * for DestroyDebugReportCallback - */ -VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallback(VkInstance instance, VkDebugReportCallbackEXT callback, - const VkAllocationCallbacks *pAllocator) { +// This is the instance chain terminator function for DestroyDebugReportCallback +VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, + const VkAllocationCallbacks *pAllocator) { uint32_t storage_idx; VkDebugReportCallbackEXT *icd_info; const struct loader_icd_term *icd_term; @@ -404,12 +398,12 @@ VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallback(VkInstance inst icd_info = *(VkDebugReportCallbackEXT **)&callback; storage_idx = 0; for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { - if (NULL == icd_term->DestroyDebugReportCallbackEXT) { + if (NULL == icd_term->dispatch.DestroyDebugReportCallbackEXT) { continue; } if (icd_info[storage_idx]) { - icd_term->DestroyDebugReportCallbackEXT(icd_term->instance, icd_info[storage_idx], pAllocator); + icd_term->dispatch.DestroyDebugReportCallbackEXT(icd_term->instance, icd_info[storage_idx], pAllocator); } storage_idx++; } @@ -425,29 +419,24 @@ VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallback(VkInstance inst } } -/* - * This is the instance chain terminator function - * for DebugReportMessage - */ -VKAPI_ATTR void VKAPI_CALL terminator_DebugReportMessage(VkInstance instance, VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, - int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { +// This is the instance chain terminator function for DebugReportMessage +VKAPI_ATTR void VKAPI_CALL terminator_DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, + int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { const struct loader_icd_term *icd_term; struct loader_instance *inst = (struct loader_instance *)instance; loader_platform_thread_lock_mutex(&loader_lock); for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { - if (icd_term->DebugReportMessageEXT != NULL) { - icd_term->DebugReportMessageEXT(icd_term->instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); + if (icd_term->dispatch.DebugReportMessageEXT != NULL) { + icd_term->dispatch.DebugReportMessageEXT(icd_term->instance, flags, objType, object, location, msgCode, pLayerPrefix, + pMsg); } } - /* - * Now that all ICDs have seen the message, call the necessary callbacks. - * Ignoring "bail" return value as there is nothing to bail from at this - * point. - */ + // Now that all ICDs have seen the message, call the necessary callbacks. Ignoring "bail" return value + // as there is nothing to bail from at this point. util_DebugReportMessage(inst, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); diff --git a/loader/debug_report.h b/loader/debug_report.h index 425811f2..89074d7f 100644 --- a/loader/debug_report.h +++ b/loader/debug_report.h @@ -23,82 +23,81 @@ #include "vk_loader_platform.h" #include "loader.h" -/* - * CreateMsgCallback is global and needs to be - * applied to all layers and ICDs. - * What happens if a layer is enabled on both the instance chain - * as well as the device chain and a call to CreateMsgCallback is made? - * Do we need to make sure that each layer / driver only gets called once? - * Should a layer implementing support for CreateMsgCallback only be allowed (?) - * to live on one chain? Or maybe make it the application's responsibility. - * If the app enables DRAW_STATE on at both CreateInstance time and CreateDevice - * time, CreateMsgCallback will call the DRAW_STATE layer twice. Once via - * the instance chain and once via the device chain. - * The loader should only return the DEBUG_REPORT extension as supported - * for the GetGlobalExtensionSupport call. That should help eliminate one - * duplication. - * Since the instance chain requires us iterating over the available ICDs - * and each ICD will have it's own unique MsgCallback object we need to - * track those objects to give back the right one. - * This also implies that the loader has to intercept vkDestroyObject and - * if the extension is enabled and the object type is a MsgCallback then - * we must translate the object into the proper ICD specific ones. - * DestroyObject works on a device chain. Should not be what's destroying - * the MsgCallback object. That needs to be an instance thing. So, since - * we used an instance to create it, we need a custom Destroy that also - * takes an instance. That way we can iterate over the ICDs properly. - * Example use: - * CreateInstance: DEBUG_REPORT - * Loader will create instance chain with enabled extensions. - * TODO: Should validation layers be enabled here? If not, they will not be in - * the instance chain. - * fn = GetProcAddr(INSTANCE, "vkCreateMsgCallback") -> point to loader's - * vkCreateMsgCallback - * App creates a callback object: fn(..., &MsgCallbackObject1) - * Have only established the instance chain so far. Loader will call the - * instance chain. - * Each layer in the instance chain will call down to the next layer, - * terminating with - * the CreateMsgCallback loader terminator function that creates the actual - * MsgCallbackObject1 object. - * The loader CreateMsgCallback terminator will iterate over the ICDs. - * Calling each ICD that supports vkCreateMsgCallback and collect answers in - * icd_msg_callback_map here. - * As result is sent back up the chain each layer has opportunity to record the - * callback operation and - * appropriate MsgCallback object. - * ... - * Any reports matching the flags set in MsgCallbackObject1 will generate the - * defined callback behavior - * in the layer / ICD that initiated that report. - * ... - * CreateDevice: MemTracker:... - * App does not include DEBUG_REPORT as that is a global extension. - * TODO: GetExtensionSupport must not report DEBUG_REPORT when using instance. - * App MUST include any desired validation layers or they will not participate - * in the device call chain. - * App creates a callback object: fn(..., &MsgCallbackObject2) - * Loader's vkCreateMsgCallback is called. - * Loader sends call down instance chain - this is a global extension - any - * validation layer that was - * enabled at CreateInstance will be able to register the callback. Loader will - * iterate over the ICDs and - * will record the ICD's version of the MsgCallback2 object here. - * ... - * Any report will go to the layer's report function and it will check the flags - * for MsgCallbackObject1 - * and MsgCallbackObject2 and take the appropriate action as indicated by the - * app. - * ... - * App calls vkDestroyMsgCallback( MsgCallbackObject1 ) - * Loader's DestroyMsgCallback is where call starts. DestroyMsgCallback will be - * sent down instance chain - * ending in the loader's DestroyMsgCallback terminator which will iterate over - * the ICD's destroying each - * ICD version of that MsgCallback object and then destroy the loader's version - * of the object. - * Any reports generated after this will only have MsgCallbackObject2 available. - */ + +// CreateMsgCallback is global and needs to be +// applied to all layers and ICDs. +// What happens if a layer is enabled on both the instance chain +// as well as the device chain and a call to CreateMsgCallback is made? +// Do we need to make sure that each layer / driver only gets called once? +// Should a layer implementing support for CreateMsgCallback only be allowed (?) +// to live on one chain? Or maybe make it the application's responsibility. +// If the app enables DRAW_STATE on at both CreateInstance time and CreateDevice +// time, CreateMsgCallback will call the DRAW_STATE layer twice. Once via +// the instance chain and once via the device chain. +// The loader should only return the DEBUG_REPORT extension as supported +// for the GetGlobalExtensionSupport call. That should help eliminate one +// duplication. +// Since the instance chain requires us iterating over the available ICDs +// and each ICD will have it's own unique MsgCallback object we need to +// track those objects to give back the right one. +// This also implies that the loader has to intercept vkDestroyObject and +// if the extension is enabled and the object type is a MsgCallback then +// we must translate the object into the proper ICD specific ones. +// DestroyObject works on a device chain. Should not be what's destroying +// the MsgCallback object. That needs to be an instance thing. So, since +// we used an instance to create it, we need a custom Destroy that also +// takes an instance. That way we can iterate over the ICDs properly. +// Example use: +// CreateInstance: DEBUG_REPORT +// Loader will create instance chain with enabled extensions. +// TODO: Should validation layers be enabled here? If not, they will not be in +// the instance chain. +// fn = GetProcAddr(INSTANCE, "vkCreateMsgCallback") -> point to loader's +// vkCreateMsgCallback +// App creates a callback object: fn(..., &MsgCallbackObject1) +// Have only established the instance chain so far. Loader will call the +// instance chain. +// Each layer in the instance chain will call down to the next layer, +// terminating with +// the CreateMsgCallback loader terminator function that creates the actual +// MsgCallbackObject1 object. +// The loader CreateMsgCallback terminator will iterate over the ICDs. +// Calling each ICD that supports vkCreateMsgCallback and collect answers in +// icd_msg_callback_map here. +// As result is sent back up the chain each layer has opportunity to record the +// callback operation and +// appropriate MsgCallback object. +// ... +// Any reports matching the flags set in MsgCallbackObject1 will generate the +// defined callback behavior +// in the layer / ICD that initiated that report. +// ... +// CreateDevice: MemTracker:... +// App does not include DEBUG_REPORT as that is a global extension. +// TODO: GetExtensionSupport must not report DEBUG_REPORT when using instance. +// App MUST include any desired validation layers or they will not participate +// in the device call chain. +// App creates a callback object: fn(..., &MsgCallbackObject2) +// Loader's vkCreateMsgCallback is called. +// Loader sends call down instance chain - this is a global extension - any +// validation layer that was +// enabled at CreateInstance will be able to register the callback. Loader will +// iterate over the ICDs and +// will record the ICD's version of the MsgCallback2 object here. +// ... +// Any report will go to the layer's report function and it will check the flags +// for MsgCallbackObject1 +// and MsgCallbackObject2 and take the appropriate action as indicated by the +// app. +// ... +// App calls vkDestroyMsgCallback( MsgCallbackObject1 ) +// Loader's DestroyMsgCallback is where call starts. DestroyMsgCallback will be +// sent down instance chain +// ending in the loader's DestroyMsgCallback terminator which will iterate over +// the ICD's destroying each +// ICD version of that MsgCallback object and then destroy the loader's version +// of the object. +// Any reports generated after this will only have MsgCallbackObject2 available. void debug_report_add_instance_extensions(const struct loader_instance *inst, struct loader_extension_list *ext_list); @@ -106,17 +105,17 @@ void debug_report_create_instance(struct loader_instance *ptr_instance, const Vk bool debug_report_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr); -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugReportCallback(VkInstance instance, - const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDebugReportCallbackEXT *pCallback); +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugReportCallbackEXT(VkInstance instance, + const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkDebugReportCallbackEXT *pCallback); -VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallback(VkInstance instance, VkDebugReportCallbackEXT callback, - const VkAllocationCallbacks *pAllocator); +VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, + const VkAllocationCallbacks *pAllocator); -VKAPI_ATTR void VKAPI_CALL terminator_DebugReportMessage(VkInstance instance, VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, - int32_t msgCode, const char *pLayerPrefix, const char *pMsg); +VKAPI_ATTR void VKAPI_CALL terminator_DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, + int32_t msgCode, const char *pLayerPrefix, const char *pMsg); VkResult util_CreateDebugReportCallback(struct loader_instance *inst, VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT callback); diff --git a/loader/extensions.c b/loader/extensions.c deleted file mode 100644 index fb05809f..00000000 --- a/loader/extensions.c +++ /dev/null @@ -1,694 +0,0 @@ -/* - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Mark Lobodzinski <mark@lunarg.com> - */ - -#define _GNU_SOURCE -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "vk_loader_platform.h" -#include "loader.h" -#include "extensions.h" -#include "table_ops.h" -#include <vulkan/vk_icd.h> -#include "wsi.h" - -// Definitions for the VK_KHR_get_physical_device_properties2 extension - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures2KHR *pFeatures) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceFeatures2KHR(unwrapped_phys_dev, pFeatures); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures2KHR *pFeatures) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetPhysicalDeviceFeatures2KHR) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetPhysicalDeviceFeatures2KHR"); - } - icd_term->GetPhysicalDeviceFeatures2KHR(phys_dev_term->phys_dev, pFeatures); -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties2KHR *pProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceProperties2KHR(unwrapped_phys_dev, pProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties2KHR *pProperties) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetPhysicalDeviceProperties2KHR) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetPhysicalDeviceProperties2KHR"); - } - icd_term->GetPhysicalDeviceProperties2KHR(phys_dev_term->phys_dev, pProperties); -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties2KHR *pFormatProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceFormatProperties2KHR(unwrapped_phys_dev, format, pFormatProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties2KHR *pFormatProperties) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetPhysicalDeviceFormatProperties2KHR) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetPhysicalDeviceFormatProperties2KHR"); - } - icd_term->GetPhysicalDeviceFormatProperties2KHR(phys_dev_term->phys_dev, format, pFormatProperties); -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR *pImageFormatInfo, - VkImageFormatProperties2KHR *pImageFormatProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetPhysicalDeviceImageFormatProperties2KHR(unwrapped_phys_dev, pImageFormatInfo, pImageFormatProperties); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR *pImageFormatInfo, - VkImageFormatProperties2KHR *pImageFormatProperties) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetPhysicalDeviceImageFormatProperties2KHR) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetPhysicalDeviceImageFormatProperties2KHR"); - } - return icd_term->GetPhysicalDeviceImageFormatProperties2KHR(phys_dev_term->phys_dev, pImageFormatInfo, pImageFormatProperties); -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, - uint32_t *pQueueFamilyPropertyCount, - VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceQueueFamilyProperties2KHR(unwrapped_phys_dev, pQueueFamilyPropertyCount, pQueueFamilyProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties2KHR( - VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetPhysicalDeviceQueueFamilyProperties2KHR) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetPhysicalDeviceQueueFamilyProperties2KHR"); - } - icd_term->GetPhysicalDeviceQueueFamilyProperties2KHR(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, - pQueueFamilyProperties); -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceMemoryProperties2KHR *pMemoryProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceMemoryProperties2KHR(unwrapped_phys_dev, pMemoryProperties); -} -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties2KHR( - VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2KHR *pMemoryProperties) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetPhysicalDeviceMemoryProperties2KHR) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetPhysicalDeviceMemoryProperties2KHR"); - } - icd_term->GetPhysicalDeviceMemoryProperties2KHR(phys_dev_term->phys_dev, pMemoryProperties); -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR *pFormatInfo, uint32_t *pPropertyCount, - VkSparseImageFormatProperties2KHR *pProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceSparseImageFormatProperties2KHR(unwrapped_phys_dev, pFormatInfo, pPropertyCount, pProperties); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR *pFormatInfo, uint32_t *pPropertyCount, - VkSparseImageFormatProperties2KHR *pProperties) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetPhysicalDeviceSparseImageFormatProperties2KHR) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetPhysicalDeviceSparseImageFormatProperties2KHR"); - } - icd_term->GetPhysicalDeviceSparseImageFormatProperties2KHR(phys_dev_term->phys_dev, pFormatInfo, pPropertyCount, pProperties); -} - -// Definitions for the VK_KHR_maintenance1 extension - -VKAPI_ATTR void VKAPI_CALL vkTrimCommandPoolKHR(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlagsKHR flags) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->TrimCommandPoolKHR(device, commandPool, flags); -} - -// Definitions for the VK_EXT_acquire_xlib_display extension - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT -VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, VkDisplayKHR display) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->AcquireXlibDisplayEXT(unwrapped_phys_dev, dpy, display); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, - VkDisplayKHR display) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->AcquireXlibDisplayEXT) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkAcquireXlibDisplayEXT"); - } - return icd_term->AcquireXlibDisplayEXT(phys_dev_term->phys_dev, dpy, display); -} - -VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput, - VkDisplayKHR *pDisplay) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetRandROutputDisplayEXT(unwrapped_phys_dev, dpy, rrOutput, pDisplay); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput, - VkDisplayKHR *pDisplay) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetRandROutputDisplayEXT) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetRandROutputDisplayEXT"); - } - return icd_term->GetRandROutputDisplayEXT(phys_dev_term->phys_dev, dpy, rrOutput, pDisplay); -} -#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */ - -// Definitions for the VK_EXT_debug_marker extension commands which -// need to have a terminator function - -VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT(VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - // If this is a physical device, we have to replace it with the proper one - // for the next call. - if (pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { - struct loader_physical_device_tramp *phys_dev_tramp = (struct loader_physical_device_tramp *)(uintptr_t)pTagInfo->object; - pTagInfo->object = (uint64_t)(uintptr_t)phys_dev_tramp->phys_dev; - } - return disp->DebugMarkerSetObjectTagEXT(device, pTagInfo); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectTagEXT(VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo) { - uint32_t icd_index = 0; - struct loader_device *dev; - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); - if (NULL != icd_term && NULL != icd_term->DebugMarkerSetObjectTagEXT) { - // If this is a physical device, we have to replace it with the proper - // one for the next call. - if (pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)(uintptr_t)pTagInfo->object; - pTagInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev; - - // If this is a KHR_surface, and the ICD has created its own, we - // have to replace it with the proper one for the next call. - } else if (pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { - if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) { - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pTagInfo->object; - if (NULL != icd_surface->real_icd_surfaces) { - pTagInfo->object = (uint64_t)icd_surface->real_icd_surfaces[icd_index]; - } - } - } - return icd_term->DebugMarkerSetObjectTagEXT(device, pTagInfo); - } else { - return VK_SUCCESS; - } -} - -VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT(VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - // If this is a physical device, we have to replace it with the proper one - // for the next call. - if (pNameInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { - struct loader_physical_device_tramp *phys_dev_tramp = (struct loader_physical_device_tramp *)(uintptr_t)pNameInfo->object; - pNameInfo->object = (uint64_t)(uintptr_t)phys_dev_tramp->phys_dev; - } - return disp->DebugMarkerSetObjectNameEXT(device, pNameInfo); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectNameEXT(VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo) { - uint32_t icd_index = 0; - struct loader_device *dev; - struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); - if (NULL != icd_term && NULL != icd_term->DebugMarkerSetObjectNameEXT) { - // If this is a physical device, we have to replace it with the proper - // one for the next call. - if (pNameInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)(uintptr_t)pNameInfo->object; - pNameInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev; - - // If this is a KHR_surface, and the ICD has created its own, we - // have to replace it with the proper one for the next call. - } else if (pNameInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { - if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) { - VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pNameInfo->object; - if (NULL != icd_surface->real_icd_surfaces) { - pNameInfo->object = (uint64_t)(uintptr_t)icd_surface->real_icd_surfaces[icd_index]; - } - } - } - return icd_term->DebugMarkerSetObjectNameEXT(device, pNameInfo); - } else { - return VK_SUCCESS; - } -} - -// Definitions for the VK_EXT_direct_mode_display extension - -VKAPI_ATTR VkResult VKAPI_CALL vkReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->ReleaseDisplayEXT(unwrapped_phys_dev, display); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->ReleaseDisplayEXT) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkReleaseDisplayEXT"); - } - return icd_term->ReleaseDisplayEXT(phys_dev_term->phys_dev, display); -} - -// Definitions for the VK_EXT_display_surface_counter extension - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, - VkSurfaceCapabilities2EXT *pSurfaceCapabilities) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetPhysicalDeviceSurfaceCapabilities2EXT(unwrapped_phys_dev, surface, pSurfaceCapabilities); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2EXT( - VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT *pSurfaceCapabilities) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL != icd_term) { - if (NULL == icd_term->GetPhysicalDeviceSurfaceCapabilities2EXT) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetPhysicalDeviceSurfaceCapabilities2EXT"); - } - VkIcdSurface *icd_surface = (VkIcdSurface *)(surface); - uint8_t icd_index = phys_dev_term->icd_index; - if (NULL != icd_surface->real_icd_surfaces) { - if (NULL != (void *)icd_surface->real_icd_surfaces[icd_index]) { - return icd_term->GetPhysicalDeviceSurfaceCapabilities2EXT( - phys_dev_term->phys_dev, icd_surface->real_icd_surfaces[icd_index], pSurfaceCapabilities); - } - } - } - return icd_term->GetPhysicalDeviceSurfaceCapabilities2EXT(phys_dev_term->phys_dev, surface, pSurfaceCapabilities); -} - -// Definitions for the VK_AMD_draw_indirect_count extension - -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, - uint32_t stride) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); -} - -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - VkBuffer countBuffer, VkDeviceSize countBufferOffset, - uint32_t maxDrawCount, uint32_t stride) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); -} - -// Definitions for the VK_NV_external_memory_capabilities extension - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceExternalImageFormatPropertiesNV( - VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, - VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, - VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - - return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV(unwrapped_phys_dev, format, type, tiling, usage, flags, - externalHandleType, pExternalImageFormatProperties); -} - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV( - VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, - VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, - VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - - if (!icd_term->GetPhysicalDeviceExternalImageFormatPropertiesNV) { - if (externalHandleType) { - return VK_ERROR_FORMAT_NOT_SUPPORTED; - } - - if (!icd_term->GetPhysicalDeviceImageFormatProperties) { - return VK_ERROR_INITIALIZATION_FAILED; - } - - pExternalImageFormatProperties->externalMemoryFeatures = 0; - pExternalImageFormatProperties->exportFromImportedHandleTypes = 0; - pExternalImageFormatProperties->compatibleHandleTypes = 0; - - return icd_term->GetPhysicalDeviceImageFormatProperties(phys_dev_term->phys_dev, format, type, tiling, usage, flags, - &pExternalImageFormatProperties->imageFormatProperties); - } - - return icd_term->GetPhysicalDeviceExternalImageFormatPropertiesNV(phys_dev_term->phys_dev, format, type, tiling, usage, flags, - externalHandleType, pExternalImageFormatProperties); -} - -#ifdef VK_USE_PLATFORM_WIN32_KHR - -// Definitions for the VK_NV_external_memory_win32 extension - -VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(VkDevice device, VkDeviceMemory memory, - VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE *pHandle) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->GetMemoryWin32HandleNV(device, memory, handleType, pHandle); -} - -#endif // VK_USE_PLATFORM_WIN32_KHR - -// Definitions for the VK_NVX_device_generated_commands - -VKAPI_ATTR void VKAPI_CALL vkCmdProcessCommandsNVX(VkCommandBuffer commandBuffer, - const VkCmdProcessCommandsInfoNVX *pProcessCommandsInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdProcessCommandsNVX(commandBuffer, pProcessCommandsInfo); -} - -VKAPI_ATTR void VKAPI_CALL vkCmdReserveSpaceForCommandsNVX(VkCommandBuffer commandBuffer, - const VkCmdReserveSpaceForCommandsInfoNVX *pReserveSpaceInfo) { - const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); - disp->CmdReserveSpaceForCommandsNVX(commandBuffer, pReserveSpaceInfo); -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateIndirectCommandsLayoutNVX(VkDevice device, - const VkIndirectCommandsLayoutCreateInfoNVX *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkIndirectCommandsLayoutNVX *pIndirectCommandsLayout) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->CreateIndirectCommandsLayoutNVX(device, pCreateInfo, pAllocator, pIndirectCommandsLayout); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyIndirectCommandsLayoutNVX(VkDevice device, VkIndirectCommandsLayoutNVX indirectCommandsLayout, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->DestroyIndirectCommandsLayoutNVX(device, indirectCommandsLayout, pAllocator); -} - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateObjectTableNVX(VkDevice device, const VkObjectTableCreateInfoNVX *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkObjectTableNVX *pObjectTable) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->CreateObjectTableNVX(device, pCreateInfo, pAllocator, pObjectTable); -} - -VKAPI_ATTR void VKAPI_CALL vkDestroyObjectTableNVX(VkDevice device, VkObjectTableNVX objectTable, - const VkAllocationCallbacks *pAllocator) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - disp->DestroyObjectTableNVX(device, objectTable, pAllocator); -} - -VKAPI_ATTR VkResult VKAPI_CALL vkRegisterObjectsNVX(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, - const VkObjectTableEntryNVX *const *ppObjectTableEntries, - const uint32_t *pObjectIndices) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->RegisterObjectsNVX(device, objectTable, objectCount, ppObjectTableEntries, pObjectIndices); -} - -VKAPI_ATTR VkResult VKAPI_CALL vkUnregisterObjectsNVX(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, - const VkObjectEntryTypeNVX *pObjectEntryTypes, - const uint32_t *pObjectIndices) { - const VkLayerDispatchTable *disp = loader_get_dispatch(device); - return disp->UnregisterObjectsNVX(device, objectTable, objectCount, pObjectEntryTypes, pObjectIndices); -} - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX(VkPhysicalDevice physicalDevice, - VkDeviceGeneratedCommandsFeaturesNVX *pFeatures, - VkDeviceGeneratedCommandsLimitsNVX *pLimits) { - const VkLayerInstanceDispatchTable *disp; - VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceGeneratedCommandsPropertiesNVX(unwrapped_phys_dev, pFeatures, pLimits); -} - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceGeneratedCommandsPropertiesNVX( - VkPhysicalDevice physicalDevice, VkDeviceGeneratedCommandsFeaturesNVX *pFeatures, VkDeviceGeneratedCommandsLimitsNVX *pLimits) { - struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetPhysicalDeviceGeneratedCommandsPropertiesNVX) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD associated with VkPhysicalDevice does not support " - "vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX"); - } else { - icd_term->GetPhysicalDeviceGeneratedCommandsPropertiesNVX(phys_dev_term->phys_dev, pFeatures, pLimits); - } -} - -// GPA helpers for extensions - -bool extension_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr) { - *addr = NULL; - - // Functions for the VK_KHR_get_physical_device_properties2 extension - - if (!strcmp("vkGetPhysicalDeviceFeatures2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)vkGetPhysicalDeviceFeatures2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)vkGetPhysicalDeviceProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceFormatProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)vkGetPhysicalDeviceFormatProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceImageFormatProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)vkGetPhysicalDeviceImageFormatProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceQueueFamilyProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)vkGetPhysicalDeviceQueueFamilyProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceMemoryProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)vkGetPhysicalDeviceMemoryProperties2KHR - : NULL; - return true; - } - if (!strcmp("vkGetPhysicalDeviceSparseImageFormatProperties2KHR", name)) { - *addr = (ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 == 1) - ? (void *)vkGetPhysicalDeviceSparseImageFormatProperties2KHR - : NULL; - return true; - } - - // Functions for the VK_KHR_maintenance1 extension - - if (!strcmp("vkTrimCommandPoolKHR", name)) { - *addr = (void *)vkTrimCommandPoolKHR; - return true; - } - -// Functions for the VK_EXT_acquire_xlib_display extension - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - if (!strcmp("vkAcquireXlibDisplayEXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_acquire_xlib_display == 1) ? (void *)vkAcquireXlibDisplayEXT : NULL; - return true; - } - - if (!strcmp("vkGetRandROutputDisplayEXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_acquire_xlib_display == 1) ? (void *)vkGetRandROutputDisplayEXT : NULL; - return true; - } - -#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT - - // Definitions for the VK_EXT_debug_marker extension commands which - // need to have a terminator function. Since these are device - // commands, we always need to return a valid value for them. - - if (!strcmp("vkDebugMarkerSetObjectTagEXT", name)) { - *addr = (void *)vkDebugMarkerSetObjectTagEXT; - return true; - } - if (!strcmp("vkDebugMarkerSetObjectNameEXT", name)) { - *addr = (void *)vkDebugMarkerSetObjectNameEXT; - return true; - } - - // Functions for the VK_EXT_direct_mode_display extension - - if (!strcmp("vkReleaseDisplayEXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_direct_mode_display == 1) ? (void *)vkReleaseDisplayEXT : NULL; - return true; - } - - // Functions for the VK_EXT_display_surface_counter extension - - if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilities2EXT", name)) { - *addr = (ptr_instance->enabled_known_extensions.ext_display_surface_counter == 1) - ? (void *)vkGetPhysicalDeviceSurfaceCapabilities2EXT - : NULL; - return true; - } - - // Functions for the VK_AMD_draw_indirect_count extension - - if (!strcmp("vkCmdDrawIndirectCountAMD", name)) { - *addr = (void *)vkCmdDrawIndirectCountAMD; - return true; - } - if (!strcmp("vkCmdDrawIndexedIndirectCountAMD", name)) { - *addr = (void *)vkCmdDrawIndexedIndirectCountAMD; - return true; - } - // Functions for the VK_NV_external_memory_capabilities extension - - if (!strcmp("vkGetPhysicalDeviceExternalImageFormatPropertiesNV", name)) { - *addr = (ptr_instance->enabled_known_extensions.nv_external_memory_capabilities == 1) - ? (void *)vkGetPhysicalDeviceExternalImageFormatPropertiesNV - : NULL; - return true; - } - -#ifdef VK_USE_PLATFORM_WIN32_KHR - - // Functions for the VK_NV_external_memory_win32 extension - if (!strcmp("vkGetMemoryWin32HandleNV", name)) { - *addr = (void *)vkGetMemoryWin32HandleNV; - return true; - } - -#endif // VK_USE_PLATFORM_WIN32_KHR - - // Functions for the VK_NVX_device_generated_commands extension - - if (!strcmp("vkCmdProcessCommandsNVX", name)) { - *addr = (void *)vkCmdProcessCommandsNVX; - return true; - } - if (!strcmp("vkCmdReserveSpaceForCommandsNVX", name)) { - *addr = (void *)vkCmdReserveSpaceForCommandsNVX; - return true; - } - if (!strcmp("vkCreateIndirectCommandsLayoutNVX", name)) { - *addr = (void *)vkCreateIndirectCommandsLayoutNVX; - return true; - } - if (!strcmp("vkDestroyIndirectCommandsLayoutNVX", name)) { - *addr = (void *)vkDestroyIndirectCommandsLayoutNVX; - return true; - } - if (!strcmp("vkCreateObjectTableNVX", name)) { - *addr = (void *)vkCreateObjectTableNVX; - return true; - } - if (!strcmp("vkDestroyObjectTableNVX", name)) { - *addr = (void *)vkDestroyObjectTableNVX; - return true; - } - if (!strcmp("vkRegisterObjectsNVX", name)) { - *addr = (void *)vkRegisterObjectsNVX; - return true; - } - if (!strcmp("vkUnregisterObjectsNVX", name)) { - *addr = (void *)vkUnregisterObjectsNVX; - return true; - } - if (!strcmp("vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX", name)) { - *addr = (void *)vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX; - return true; - } - - return false; -} - -void extensions_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo) { - for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { - if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.khr_get_physical_device_properties2 = 1; -#ifdef VK_USE_PLATFORM_XLIB_KHR - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.ext_acquire_xlib_display = 1; -#endif - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.ext_direct_mode_display = 1; - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.ext_display_surface_counter = 1; - } else if (0 == strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME)) { - ptr_instance->enabled_known_extensions.nv_external_memory_capabilities = 1; - } - } -} diff --git a/loader/extensions.h b/loader/extensions.h deleted file mode 100644 index 5736f3ba..00000000 --- a/loader/extensions.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Author: Mark Lobodzinski <mark@lunarg.com> - * - */ - -#include "vk_loader_platform.h" -#include "loader.h" - -bool extension_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr); - -void extensions_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo); - -// Instance extension terminators for the VK_KHR_get_physical_device_properties2 -// extension - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures2KHR *pFeatures); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties2KHR(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties2KHR *pProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties2KHR *pFormatProperties); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR *pImageFormatInfo, - VkImageFormatProperties2KHR *pImageFormatProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties2KHR( - VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties2KHR( - VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2KHR *pMemoryProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR *pFormatInfo, uint32_t *pPropertyCount, - VkSparseImageFormatProperties2KHR *pProperties); - -// Instance extension terminators for the VK_EXT_acquire_xlib_display -// extension - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT -VKAPI_ATTR VkResult VKAPI_CALL terminator_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, - VkDisplayKHR display); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput, - VkDisplayKHR *pDisplay); -#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */ - -// Instance extension terminators for the VK_EXT_direct_mode_display -// extension - -VKAPI_ATTR VkResult VKAPI_CALL terminator_ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display); - -// Instance extension terminators for the VK_EXT_display_surface_counter -// extension - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - VkSurfaceCapabilities2EXT *pSurfaceCapabilities); - -// Device extension terminators for the VK_NV_external_memory_capabilities -// extension - -VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectTagEXT(VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectNameEXT(VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo); - -// Instance extension terminators for the VK_NV_external_memory_capabilities -// extension - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV( - VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, - VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, - VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties); - -// Instance extension terminators for the VK_NVX_device_generated_commands -// extension -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceGeneratedCommandsPropertiesNVX( - VkPhysicalDevice physicalDevice, VkDeviceGeneratedCommandsFeaturesNVX *pFeatures, VkDeviceGeneratedCommandsLimitsNVX *pLimits); diff --git a/loader/gpa_helper.h b/loader/gpa_helper.h index 93d60df9..0763938b 100644 --- a/loader/gpa_helper.h +++ b/loader/gpa_helper.h @@ -22,7 +22,6 @@ #include <string.h> #include "debug_report.h" #include "wsi.h" -#include "extensions.h" static inline void *trampolineGetProcAddr(struct loader_instance *inst, const char *funcName) { // Don't include or check global functions diff --git a/loader/loader.c b/loader/loader.c index 244b8dc8..4d6d168a 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -41,10 +41,8 @@ #include "vk_loader_platform.h" #include "loader.h" #include "gpa_helper.h" -#include "table_ops.h" #include "debug_report.h" #include "wsi.h" -#include "extensions.h" #include "vulkan/vk_icd.h" #include "cJSON.h" #include "murmurhash.h" @@ -55,6 +53,9 @@ #endif #endif +// Generated file containing all the extension data +#include "vk_loader_extensions.c" + struct loader_struct loader = {0}; // TLS for instance for alloc/free callbacks THREAD_LOCAL_DECL struct loader_instance *tls_instance; @@ -86,127 +87,6 @@ loader_platform_thread_mutex loader_json_lock; const char *std_validation_str = "VK_LAYER_LUNARG_standard_validation"; -// This table contains the loader's instance dispatch table, which contains -// default functions if no instance layers are activated. This contains -// pointers to "terminator functions". -const VkLayerInstanceDispatchTable instance_disp = { - .GetInstanceProcAddr = vkGetInstanceProcAddr, - .DestroyInstance = terminator_DestroyInstance, - .EnumeratePhysicalDevices = terminator_EnumeratePhysicalDevices, - .GetPhysicalDeviceFeatures = terminator_GetPhysicalDeviceFeatures, - .GetPhysicalDeviceFormatProperties = terminator_GetPhysicalDeviceFormatProperties, - .GetPhysicalDeviceImageFormatProperties = terminator_GetPhysicalDeviceImageFormatProperties, - .GetPhysicalDeviceProperties = terminator_GetPhysicalDeviceProperties, - .GetPhysicalDeviceQueueFamilyProperties = terminator_GetPhysicalDeviceQueueFamilyProperties, - .GetPhysicalDeviceMemoryProperties = terminator_GetPhysicalDeviceMemoryProperties, - .EnumerateDeviceExtensionProperties = terminator_EnumerateDeviceExtensionProperties, - .EnumerateDeviceLayerProperties = terminator_EnumerateDeviceLayerProperties, - .GetPhysicalDeviceSparseImageFormatProperties = terminator_GetPhysicalDeviceSparseImageFormatProperties, - .DestroySurfaceKHR = terminator_DestroySurfaceKHR, - .GetPhysicalDeviceSurfaceSupportKHR = terminator_GetPhysicalDeviceSurfaceSupportKHR, - .GetPhysicalDeviceSurfaceCapabilitiesKHR = terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR, - .GetPhysicalDeviceSurfaceFormatsKHR = terminator_GetPhysicalDeviceSurfaceFormatsKHR, - .GetPhysicalDeviceSurfacePresentModesKHR = terminator_GetPhysicalDeviceSurfacePresentModesKHR, -#ifdef VK_USE_PLATFORM_MIR_KHR - .CreateMirSurfaceKHR = terminator_CreateMirSurfaceKHR, - .GetPhysicalDeviceMirPresentationSupportKHR = terminator_GetPhysicalDeviceMirPresentationSupportKHR, -#endif -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - .CreateWaylandSurfaceKHR = terminator_CreateWaylandSurfaceKHR, - .GetPhysicalDeviceWaylandPresentationSupportKHR = terminator_GetPhysicalDeviceWaylandPresentationSupportKHR, -#endif -#ifdef VK_USE_PLATFORM_WIN32_KHR - .CreateWin32SurfaceKHR = terminator_CreateWin32SurfaceKHR, - .GetPhysicalDeviceWin32PresentationSupportKHR = terminator_GetPhysicalDeviceWin32PresentationSupportKHR, -#endif -#ifdef VK_USE_PLATFORM_XCB_KHR - .CreateXcbSurfaceKHR = terminator_CreateXcbSurfaceKHR, - .GetPhysicalDeviceXcbPresentationSupportKHR = terminator_GetPhysicalDeviceXcbPresentationSupportKHR, -#endif -#ifdef VK_USE_PLATFORM_XLIB_KHR - .CreateXlibSurfaceKHR = terminator_CreateXlibSurfaceKHR, - .GetPhysicalDeviceXlibPresentationSupportKHR = terminator_GetPhysicalDeviceXlibPresentationSupportKHR, -#endif -#ifdef VK_USE_PLATFORM_ANDROID_KHR - .CreateAndroidSurfaceKHR = terminator_CreateAndroidSurfaceKHR, -#endif - .GetPhysicalDeviceDisplayPropertiesKHR = terminator_GetPhysicalDeviceDisplayPropertiesKHR, - .GetPhysicalDeviceDisplayPlanePropertiesKHR = terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR, - .GetDisplayPlaneSupportedDisplaysKHR = terminator_GetDisplayPlaneSupportedDisplaysKHR, - .GetDisplayModePropertiesKHR = terminator_GetDisplayModePropertiesKHR, - .CreateDisplayModeKHR = terminator_CreateDisplayModeKHR, - .GetDisplayPlaneCapabilitiesKHR = terminator_GetDisplayPlaneCapabilitiesKHR, - .CreateDisplayPlaneSurfaceKHR = terminator_CreateDisplayPlaneSurfaceKHR, - - // KHR_get_physical_device_properties2 - .GetPhysicalDeviceFeatures2KHR = terminator_GetPhysicalDeviceFeatures2KHR, - .GetPhysicalDeviceProperties2KHR = terminator_GetPhysicalDeviceProperties2KHR, - .GetPhysicalDeviceFormatProperties2KHR = terminator_GetPhysicalDeviceFormatProperties2KHR, - .GetPhysicalDeviceImageFormatProperties2KHR = terminator_GetPhysicalDeviceImageFormatProperties2KHR, - .GetPhysicalDeviceQueueFamilyProperties2KHR = terminator_GetPhysicalDeviceQueueFamilyProperties2KHR, - .GetPhysicalDeviceMemoryProperties2KHR = terminator_GetPhysicalDeviceMemoryProperties2KHR, - .GetPhysicalDeviceSparseImageFormatProperties2KHR = terminator_GetPhysicalDeviceSparseImageFormatProperties2KHR, - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - // EXT_acquire_xlib_display - .AcquireXlibDisplayEXT = terminator_AcquireXlibDisplayEXT, - .GetRandROutputDisplayEXT = terminator_GetRandROutputDisplayEXT, -#endif - - // EXT_debug_report - .CreateDebugReportCallbackEXT = terminator_CreateDebugReportCallback, - .DestroyDebugReportCallbackEXT = terminator_DestroyDebugReportCallback, - .DebugReportMessageEXT = terminator_DebugReportMessage, - - // EXT_direct_mode_display - .ReleaseDisplayEXT = terminator_ReleaseDisplayEXT, - - // EXT_display_surface_counter - .GetPhysicalDeviceSurfaceCapabilities2EXT = terminator_GetPhysicalDeviceSurfaceCapabilities2EXT, - - // NV_external_memory_capabilities - .GetPhysicalDeviceExternalImageFormatPropertiesNV = terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV, - - // NVX_device_generated_commands - .GetPhysicalDeviceGeneratedCommandsPropertiesNVX = terminator_GetPhysicalDeviceGeneratedCommandsPropertiesNVX, -}; - -// A null-terminated list of all of the instance extensions supported by the -// loader -static const char *const LOADER_INSTANCE_EXTENSIONS[] = {VK_KHR_SURFACE_EXTENSION_NAME, - VK_KHR_DISPLAY_EXTENSION_NAME, -#ifdef VK_USE_PLATFORM_XLIB_KHR - VK_KHR_XLIB_SURFACE_EXTENSION_NAME, -#endif -#ifdef VK_USE_PLATFORM_XCB_KHR - VK_KHR_XCB_SURFACE_EXTENSION_NAME, -#endif -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, -#endif -#ifdef VK_USE_PLATFORM_MIR_KHR - VK_KHR_MIR_SURFACE_EXTENSION_NAME, -#endif -#ifdef VK_USE_PLATFORM_ANDROID_KHR - VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, -#endif -#ifdef VK_USE_PLATFORM_WIN32_KHR - VK_KHR_WIN32_SURFACE_EXTENSION_NAME, -#endif - VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME, -#endif - VK_EXT_DEBUG_REPORT_EXTENSION_NAME, - VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME, - VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME, - VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME, -#ifdef VK_USE_PLATFORM_VI_NN - VK_NN_VI_SURFACE_EXTENSION_NAME, -#endif - VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, - NULL}; - LOADER_PLATFORM_THREAD_ONCE_DECLARATION(once_init); void *loader_instance_heap_alloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope alloc_scope) { @@ -215,9 +95,8 @@ void *loader_instance_heap_alloc(const struct loader_instance *instance, size_t { #else if (instance && instance->alloc_callbacks.pfnAllocation) { - /* These are internal structures, so it's best to align everything to - * the largest unit size which is the size of a uint64_t. - */ + // These are internal structures, so it's best to align everything to + // the largest unit size which is the size of a uint64_t. pMemory = instance->alloc_callbacks.pfnAllocation(instance->alloc_callbacks.pUserData, size, sizeof(uint64_t), alloc_scope); } else { #endif @@ -250,9 +129,8 @@ void *loader_instance_heap_realloc(const struct loader_instance *instance, void #if (DEBUG_DISABLE_APP_ALLOCATORS == 1) #else } else if (instance && instance->alloc_callbacks.pfnReallocation) { - /* These are internal structures, so it's best to align everything to - * the largest unit size which is the size of a uint64_t. - */ + // These are internal structures, so it's best to align everything to + // the largest unit size which is the size of a uint64_t. pNewMem = instance->alloc_callbacks.pfnReallocation(instance->alloc_callbacks.pUserData, pMemory, size, sizeof(uint64_t), alloc_scope); #endif @@ -274,9 +152,8 @@ void *loader_device_heap_alloc(const struct loader_device *device, size_t size, { #else if (device && device->alloc_callbacks.pfnAllocation) { - /* These are internal structures, so it's best to align everything to - * the largest unit size which is the size of a uint64_t. - */ + // These are internal structures, so it's best to align everything to + // the largest unit size which is the size of a uint64_t. pMemory = device->alloc_callbacks.pfnAllocation(device->alloc_callbacks.pUserData, size, sizeof(uint64_t), alloc_scope); } else { #endif @@ -309,9 +186,8 @@ void *loader_device_heap_realloc(const struct loader_device *device, void *pMemo #if (DEBUG_DISABLE_APP_ALLOCATORS == 1) #else } else if (device && device->alloc_callbacks.pfnReallocation) { - /* These are internal structures, so it's best to align everything to - * the largest unit size which is the size of a uint64_t. - */ + // These are internal structures, so it's best to align everything to + // the largest unit size which is the size of a uint64_t. pNewMem = device->alloc_callbacks.pfnReallocation(device->alloc_callbacks.pUserData, pMemory, size, sizeof(uint64_t), alloc_scope); #endif @@ -583,20 +459,17 @@ out: #endif // WIN32 -/** - * Combine path elements, separating each element with the platform-specific - * directory separator, and save the combined string to a destination buffer, - * not exceeding the given length. Path elements are given as variadic args, - * with a NULL element terminating the list. - * - * \returns the total length of the combined string, not including an ASCII - * NUL termination character. This length may exceed the available storage: - * in this case, the written string will be truncated to avoid a buffer - * overrun, and the return value will greater than or equal to the storage - * size. A NULL argument may be provided as the destination buffer in order - * to determine the required string length without actually writing a string. - */ - +// Combine path elements, separating each element with the platform-specific +// directory separator, and save the combined string to a destination buffer, +// not exceeding the given length. Path elements are given as variadic args, +// with a NULL element terminating the list. +// +// \returns the total length of the combined string, not including an ASCII +// NUL termination character. This length may exceed the available storage: +// in this case, the written string will be truncated to avoid a buffer +// overrun, and the return value will greater than or equal to the storage +// size. A NULL argument may be provided as the destination buffer in order +// to determine the required string length without actually writing a string. static size_t loader_platform_combine_path(char *dest, size_t len, ...) { size_t required_len = 0; va_list ap; @@ -630,10 +503,7 @@ static size_t loader_platform_combine_path(char *dest, size_t len, ...) { return required_len; } -/** - * Given string of three part form "maj.min.pat" convert to a vulkan version - * number. - */ +// Given string of three part form "maj.min.pat" convert to a vulkan version number. static uint32_t loader_make_version(char *vers_str) { uint32_t vers = 0, major = 0, minor = 0, patch = 0; char *vers_tok; @@ -662,10 +532,7 @@ bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkE return strcmp(op1->extensionName, op2->extensionName) == 0 ? true : false; } -/** - * Search the given ext_array for an extension - * matching the given vk_ext_prop - */ +// Search the given ext_array for an extension matching the given vk_ext_prop bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, const uint32_t count, const VkExtensionProperties *ext_array) { for (uint32_t i = 0; i < count; i++) { @@ -674,10 +541,7 @@ bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, c return false; } -/** - * Search the given ext_list for an extension - * matching the given vk_ext_prop - */ +// Search the given ext_list for an extension matching the given vk_ext_prop bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list) { for (uint32_t i = 0; i < ext_list->count; i++) { if (compare_vk_extension_properties(&ext_list->list[i], vk_ext_prop)) return true; @@ -685,9 +549,7 @@ bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const s return false; } -/** - * Search the given ext_list for a device extension matching the given ext_prop - */ +// Search the given ext_list for a device extension matching the given ext_prop bool has_vk_dev_ext_property(const VkExtensionProperties *ext_prop, const struct loader_device_extension_list *ext_list) { for (uint32_t i = 0; i < ext_list->count; i++) { if (compare_vk_extension_properties(&ext_list->list[i].props, ext_prop)) return true; @@ -695,9 +557,7 @@ bool has_vk_dev_ext_property(const VkExtensionProperties *ext_prop, const struct return false; } -/* - * Search the given layer list for a layer matching the given layer name - */ +// Search the given layer list for a layer matching the given layer name static struct loader_layer_properties *loader_get_layer_property(const char *name, const struct loader_layer_list *layer_list) { for (uint32_t i = 0; i < layer_list->count; i++) { const VkLayerProperties *item = &layer_list->list[i].info; @@ -706,9 +566,7 @@ static struct loader_layer_properties *loader_get_layer_property(const char *nam return NULL; } -/** - * Get the next unused layer property in the list. Init the property to zero. - */ +// Get the next unused layer property in the list. Init the property to zero. static struct loader_layer_properties *loader_get_next_layer_property(const struct loader_instance *inst, struct loader_layer_list *layer_list) { if (layer_list->capacity == 0) { @@ -724,7 +582,7 @@ static struct loader_layer_properties *loader_get_next_layer_property(const stru layer_list->capacity = sizeof(struct loader_layer_properties) * 64; } - // ensure enough room to add an entry + // Ensure enough room to add an entry if ((layer_list->count + 1) * sizeof(struct loader_layer_properties) > layer_list->capacity) { layer_list->list = loader_instance_heap_realloc(inst, layer_list->list, layer_list->capacity, layer_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); @@ -741,9 +599,7 @@ static struct loader_layer_properties *loader_get_next_layer_property(const stru return &(layer_list->list[layer_list->count - 1]); } -/** - * Remove all layer properties entrys from the list - */ +// Remove all layer properties entrys from the list void loader_delete_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_list) { uint32_t i, j; struct loader_device_extension_list *dev_ext_list; @@ -776,7 +632,7 @@ static VkResult loader_add_instance_extensions(const struct loader_instance *ins VkResult res = VK_SUCCESS; if (!fp_get_props) { - /* No EnumerateInstanceExtensionProperties defined */ + // No EnumerateInstanceExtensionProperties defined goto out; } @@ -790,7 +646,7 @@ static VkResult loader_add_instance_extensions(const struct loader_instance *ins } if (count == 0) { - /* No ExtensionProperties to report */ + // No ExtensionProperties to report goto out; } @@ -834,10 +690,8 @@ out: return res; } -/* - * Initialize ext_list with the physical device extensions. - * The extension properties are passed as inputs in count and ext_props. - */ +// Initialize ext_list with the physical device extensions. +// The extension properties are passed as inputs in count and ext_props. static VkResult loader_init_device_extensions(const struct loader_instance *inst, struct loader_physical_device_term *phys_dev_term, uint32_t count, VkExtensionProperties *ext_props, struct loader_extension_list *ext_list) { @@ -929,12 +783,8 @@ void loader_destroy_generic_list(const struct loader_instance *inst, struct load list->capacity = 0; } -/* - * Append non-duplicate extension properties defined in props - * to the given ext_list. - * Return - * Vk_SUCCESS on success - */ +// Append non-duplicate extension properties defined in props to the given ext_list. +// Return - Vk_SUCCESS on success VkResult loader_add_to_ext_list(const struct loader_instance *inst, struct loader_extension_list *ext_list, uint32_t prop_list_count, const VkExtensionProperties *props) { uint32_t i; @@ -978,12 +828,9 @@ VkResult loader_add_to_ext_list(const struct loader_instance *inst, struct loade return VK_SUCCESS; } -/* - * Append one extension property defined in props with entrypoints - * defined in entrys to the given ext_list. Do not append if a duplicate - * Return - * Vk_SUCCESS on success - */ +// Append one extension property defined in props with entrypoints defined in entrys to the given +// ext_list. Do not append if a duplicate. +// Return - Vk_SUCCESS on success VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct loader_device_extension_list *ext_list, const VkExtensionProperties *props, uint32_t entry_count, char **entrys) { uint32_t idx; @@ -1052,11 +899,8 @@ VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct l return VK_SUCCESS; } -/** - * Search the given search_list for any layers in the props list. - * Add these to the output layer_list. Don't add duplicates to the output - * layer_list. - */ +// Search the given search_list for any layers in the props list. Add these to the +// output layer_list. Don't add duplicates to the output layer_list. static VkResult loader_add_layer_names_to_list(const struct loader_instance *inst, struct loader_layer_list *output_list, uint32_t name_count, const char *const *names, const struct loader_layer_list *search_list) { @@ -1081,9 +925,7 @@ static VkResult loader_add_layer_names_to_list(const struct loader_instance *ins return err; } -/* - * Manage lists of VkLayerProperties - */ +// Manage lists of VkLayerProperties static bool loader_init_layer_list(const struct loader_instance *inst, struct loader_layer_list *list) { list->capacity = 32 * sizeof(struct loader_layer_properties); list->list = loader_instance_heap_alloc(inst, list->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); @@ -1106,10 +948,7 @@ void loader_destroy_layer_list(const struct loader_instance *inst, struct loader layer_list->capacity = 0; } -/* - * Search the given layer list for a list - * matching the given VkLayerProperties - */ +// Search the given layer list for a list matching the given VkLayerProperties bool has_vk_layer_property(const VkLayerProperties *vk_layer_prop, const struct loader_layer_list *list) { for (uint32_t i = 0; i < list->count; i++) { if (strcmp(vk_layer_prop->layerName, list->list[i].info.layerName) == 0) return true; @@ -1117,10 +956,7 @@ bool has_vk_layer_property(const VkLayerProperties *vk_layer_prop, const struct return false; } -/* - * Search the given layer list for a layer - * matching the given name - */ +// Search the given layer list for a layer matching the given name bool has_layer_name(const char *name, const struct loader_layer_list *list) { for (uint32_t i = 0; i < list->count; i++) { if (strcmp(name, list->list[i].info.layerName) == 0) return true; @@ -1128,10 +964,7 @@ bool has_layer_name(const char *name, const struct loader_layer_list *list) { return false; } -/* - * Append non-duplicate layer properties defined in prop_list - * to the given layer_info list - */ +// Append non-duplicate layer properties defined in prop_list to the given layer_info list VkResult loader_add_to_layer_list(const struct loader_instance *inst, struct loader_layer_list *list, uint32_t prop_list_count, const struct loader_layer_properties *props) { uint32_t i; @@ -1173,20 +1006,16 @@ VkResult loader_add_to_layer_list(const struct loader_instance *inst, struct loa return VK_SUCCESS; } -/** - * Search the search_list for any layer with a name - * that matches the given name and a type that matches the given type - * Add all matching layers to the found_list - * Do not add if found loader_layer_properties is already - * on the found_list. - */ +// Search the search_list for any layer with a name that matches the given name and a type +// that matches the given type. Add all matching layers to the found_list. +// Do not add if found loader_layer_properties is already on the found_list. void loader_find_layer_name_add_list(const struct loader_instance *inst, const char *name, const enum layer_type type, const struct loader_layer_list *search_list, struct loader_layer_list *found_list) { bool found = false; for (uint32_t i = 0; i < search_list->count; i++) { struct loader_layer_properties *layer_prop = &search_list->list[i]; if (0 == strcmp(layer_prop->info.layerName, name) && (layer_prop->type & type)) { - /* Found a layer with the same name, add to found_list */ + // Found a layer with the same name, add to found_list if (VK_SUCCESS == loader_add_to_layer_list(inst, found_list, 1, layer_prop)) { found = true; } @@ -1214,26 +1043,25 @@ static VkExtensionProperties *get_dev_extension_property(const char *name, const return NULL; } -/* - * For Instance extensions implemented within the loader (i.e. DEBUG_REPORT - * the extension must provide two entry points for the loader to use: - * - "trampoline" entry point - this is the address returned by GetProcAddr - * and will always do what's necessary to support a global call. - * - "terminator" function - this function will be put at the end of the - * instance chain and will contain the necessary logic to call / process - * the extension for the appropriate ICDs that are available. - * There is no generic mechanism for including these functions, the references - * must be placed into the appropriate loader entry points. - * GetInstanceProcAddr: call extension GetInstanceProcAddr to check for - * GetProcAddr requests - * loader_coalesce_extensions(void) - add extension records to the list of - * global - * extension available to the app. - * instance_disp - add function pointer for terminator function to this array. - * The extension itself should be in a separate file that will be - * linked directly with the loader. - */ - +// For Instance extensions implemented within the loader (i.e. DEBUG_REPORT +// the extension must provide two entry points for the loader to use: +// - "trampoline" entry point - this is the address returned by GetProcAddr +// and will always do what's necessary to support a +// global call. +// - "terminator" function - this function will be put at the end of the +// instance chain and will contain the necessary logic +// to call / process the extension for the appropriate +// ICDs that are available. +// There is no generic mechanism for including these functions, the references +// must be placed into the appropriate loader entry points. +// GetInstanceProcAddr: call extension GetInstanceProcAddr to check for GetProcAddr +// requests +// loader_coalesce_extensions(void) - add extension records to the list of global +// extension available to the app. +// instance_disp - add function pointer for terminator function +// to this array. +// The extension itself should be in a separate file that will be linked directly +// with the loader. VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list, struct loader_extension_list *inst_exts) { struct loader_extension_list icd_exts; @@ -1418,7 +1246,7 @@ static struct loader_icd_term *loader_icd_add(struct loader_instance *ptr_inst, icd_term->scanned_icd = scanned_icd; icd_term->this_instance = ptr_inst; - /* prepend to the list */ + // Prepend to the list icd_term->next = ptr_inst->icd_terms; ptr_inst->icd_terms = icd_term; ptr_inst->total_icd_count++; @@ -1426,14 +1254,12 @@ static struct loader_icd_term *loader_icd_add(struct loader_instance *ptr_inst, return icd_term; } -/** - * Determine the ICD interface version to use. - * @param icd - * @param pVersion Output parameter indicating which version to use or 0 if - * the negotiation API is not supported by the ICD - * @return bool indicating true if the selected interface version is supported - * by the loader, false indicates the version is not supported - */ +// Determine the ICD interface version to use. +// @param icd +// @param pVersion Output parameter indicating which version to use or 0 if +// the negotiation API is not supported by the ICD +// @return bool indicating true if the selected interface version is supported +// by the loader, false indicates the version is not supported bool loader_get_icd_interface_version(PFN_vkNegotiateLoaderICDInterfaceVersion fp_negotiate_icd_version, uint32_t *pVersion) { if (fp_negotiate_icd_version == NULL) { // ICD does not support the negotiation API, it supports version 0 or 1 @@ -1500,8 +1326,8 @@ static VkResult loader_scanned_icd_add(const struct loader_instance *inst, struc uint32_t interface_vers; VkResult res = VK_SUCCESS; - /* TODO implement smarter opening/closing of libraries. For now this - * function leaves libraries open and the scanned_icd_clear closes them */ + // TODO implement smarter opening/closing of libraries. For now this + // function leaves libraries open and the scanned_icd_clear closes them handle = loader_platform_open_library(filename); if (NULL == handle) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, loader_platform_open_library_error(filename)); @@ -1624,105 +1450,6 @@ out: return res; } -static bool loader_icd_init_entrys(struct loader_icd_term *icd_term, VkInstance inst, const PFN_vkGetInstanceProcAddr fp_gipa) { -/* initialize entrypoint function pointers */ - -#define LOOKUP_GIPA(func, required) \ - do { \ - icd_term->func = (PFN_vk##func)fp_gipa(inst, "vk" #func); \ - if (!icd_term->func && required) { \ - loader_log((struct loader_instance *)inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, \ - loader_platform_get_proc_address_error("vk" #func)); \ - return false; \ - } \ - } while (0) - - LOOKUP_GIPA(GetDeviceProcAddr, true); - LOOKUP_GIPA(DestroyInstance, true); - LOOKUP_GIPA(EnumeratePhysicalDevices, true); - LOOKUP_GIPA(GetPhysicalDeviceFeatures, true); - LOOKUP_GIPA(GetPhysicalDeviceFormatProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceImageFormatProperties, true); - LOOKUP_GIPA(CreateDevice, true); - LOOKUP_GIPA(GetPhysicalDeviceProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceMemoryProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceQueueFamilyProperties, true); - LOOKUP_GIPA(EnumerateDeviceExtensionProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceSparseImageFormatProperties, true); - LOOKUP_GIPA(GetPhysicalDeviceSurfaceSupportKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSurfaceCapabilitiesKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSurfaceFormatsKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSurfacePresentModesKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceDisplayPropertiesKHR, false); - LOOKUP_GIPA(GetDisplayModePropertiesKHR, false); - LOOKUP_GIPA(CreateDisplayPlaneSurfaceKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceDisplayPlanePropertiesKHR, false); - LOOKUP_GIPA(GetDisplayPlaneSupportedDisplaysKHR, false); - LOOKUP_GIPA(CreateDisplayModeKHR, false); - LOOKUP_GIPA(GetDisplayPlaneCapabilitiesKHR, false); - LOOKUP_GIPA(DestroySurfaceKHR, false); - LOOKUP_GIPA(CreateSwapchainKHR, false); -#ifdef VK_USE_PLATFORM_WIN32_KHR - LOOKUP_GIPA(CreateWin32SurfaceKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceWin32PresentationSupportKHR, false); -#endif -#ifdef VK_USE_PLATFORM_XCB_KHR - LOOKUP_GIPA(CreateXcbSurfaceKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceXcbPresentationSupportKHR, false); -#endif -#ifdef VK_USE_PLATFORM_XLIB_KHR - LOOKUP_GIPA(CreateXlibSurfaceKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceXlibPresentationSupportKHR, false); -#endif -#ifdef VK_USE_PLATFORM_MIR_KHR - LOOKUP_GIPA(CreateMirSurfaceKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceMirPresentationSupportKHR, false); -#endif -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - LOOKUP_GIPA(CreateWaylandSurfaceKHR, false); - LOOKUP_GIPA(GetPhysicalDeviceWaylandPresentationSupportKHR, false); -#endif - LOOKUP_GIPA(CreateSharedSwapchainsKHR, false); - - // KHR_get_physical_device_properties2 - LOOKUP_GIPA(GetPhysicalDeviceFeatures2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceFormatProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceImageFormatProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceQueueFamilyProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceMemoryProperties2KHR, false); - LOOKUP_GIPA(GetPhysicalDeviceSparseImageFormatProperties2KHR, false); - // EXT_debug_marker (items needing a trampoline/terminator) - LOOKUP_GIPA(DebugMarkerSetObjectTagEXT, false); - LOOKUP_GIPA(DebugMarkerSetObjectNameEXT, false); - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - // EXT_acquire_xlib_display - LOOKUP_GIPA(AcquireXlibDisplayEXT, false); - LOOKUP_GIPA(GetRandROutputDisplayEXT, false); -#endif - - // EXT_debug_report - LOOKUP_GIPA(CreateDebugReportCallbackEXT, false); - LOOKUP_GIPA(DestroyDebugReportCallbackEXT, false); - LOOKUP_GIPA(DebugReportMessageEXT, false); - - // EXT_direct_mode_display - LOOKUP_GIPA(ReleaseDisplayEXT, false); - - // EXT_display_surface_counter - LOOKUP_GIPA(GetPhysicalDeviceSurfaceCapabilities2EXT, false); - - // NV_external_memory_capabilities - LOOKUP_GIPA(GetPhysicalDeviceExternalImageFormatPropertiesNV, false); - // NVX_device_generated_commands - LOOKUP_GIPA(GetPhysicalDeviceGeneratedCommandsPropertiesNVX, false); - -#undef LOOKUP_GIPA - - return true; -} - static void loader_debug_init(void) { char *env, *orig; @@ -1730,7 +1457,7 @@ static void loader_debug_init(void) { g_loader_debug = 0; - /* parse comma-separated debug options */ + // Parse comma-separated debug options orig = env = loader_getenv("VK_LOADER_DEBUG", NULL); while (env) { char *p = strchr(env, ','); @@ -1791,14 +1518,12 @@ struct loader_manifest_files { char **filename_list; }; -/** - * Get next file or dirname given a string list or registry key path - * - * \returns - * A pointer to first char in the next path. - * The next path (or NULL) in the list is returned in next_path. - * Note: input string is modified in some cases. PASS IN A COPY! - */ +// Get next file or dirname given a string list or registry key path +// +// \returns +// A pointer to first char in the next path. +// The next path (or NULL) in the list is returned in next_path. +// Note: input string is modified in some cases. PASS IN A COPY! static char *loader_get_next_path(char *path) { uint32_t len; char *next; @@ -1816,14 +1541,11 @@ static char *loader_get_next_path(char *path) { return next; } -/** - * Given a path which is absolute or relative, expand the path if relative or - * leave the path unmodified if absolute. The base path to prepend to relative - * paths is given in rel_base. - * - * \returns - * A string in out_fullpath of the full absolute path - */ +// Given a path which is absolute or relative, expand the path if relative or +// leave the path unmodified if absolute. The base path to prepend to relative +// paths is given in rel_base. +// +// @return - A string in out_fullpath of the full absolute path static void loader_expand_path(const char *path, const char *rel_base, size_t out_size, char *out_fullpath) { if (loader_platform_is_path_absolute(path)) { // do not prepend a base to an absolute path @@ -1833,14 +1555,10 @@ static void loader_expand_path(const char *path, const char *rel_base, size_t ou loader_platform_combine_path(out_fullpath, out_size, rel_base, path, NULL); } -/** - * Given a filename (file) and a list of paths (dir), try to find an existing - * file in the paths. If filename already is a path then no - * searching in the given paths. - * - * \returns - * A string in out_fullpath of either the full path or file. - */ +// Given a filename (file) and a list of paths (dir), try to find an existing +// file in the paths. If filename already is a path then no searching in the given paths. +// +// @return - A string in out_fullpath of either the full path or file. static void loader_get_fullpath(const char *file, const char *dirs, size_t out_size, char *out_fullpath) { if (!loader_platform_is_path(file) && *dirs) { char *dirs_copy, *dir, *next_dir; @@ -1860,13 +1578,10 @@ static void loader_get_fullpath(const char *file, const char *dirs, size_t out_s (void)snprintf(out_fullpath, out_size, "%s", file); } -/** - * Read a JSON file into a buffer. - * - * \returns - * A pointer to a cJSON object representing the JSON parse tree. - * This returned buffer should be freed by caller. - */ +// Read a JSON file into a buffer. +// +// @return - A pointer to a cJSON object representing the JSON parse tree. +// This returned buffer should be freed by caller. static VkResult loader_get_json(const struct loader_instance *inst, const char *filename, cJSON **json) { FILE *file = NULL; char *json_buf; @@ -1906,7 +1621,7 @@ static VkResult loader_get_json(const struct loader_instance *inst, const char * } json_buf[len] = '\0'; - // parse text from file + // Parse text from file *json = cJSON_Parse(json_buf); if (*json == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -1926,9 +1641,7 @@ out: return res; } -/** - * Do a deep copy of the loader_layer_properties structure. - */ +// Do a deep copy of the loader_layer_properties structure. VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *dst, struct loader_layer_properties *src) { uint32_t cnt, i; @@ -2009,18 +1722,16 @@ bool loader_find_layer_name_array(const char *name, uint32_t layer_count, const return false; } -/** - * Searches through an array of layer names (ppp_layer_names) looking for a - * layer key_name. - * If not found then simply returns updating nothing. - * Otherwise, it uses expand_count, expand_names adding them to layer names. - * Any duplicate (pre-existing) expand_names in layer names are removed. - * Order is otherwise preserved, with the layer key_name being replaced by the - * expand_names. - * @param inst - * @param layer_count - * @param ppp_layer_names - */ +// Searches through an array of layer names (ppp_layer_names) looking for a +// layer key_name. +// If not found then simply returns updating nothing. +// Otherwise, it uses expand_count, expand_names adding them to layer names. +// Any duplicate (pre-existing) expand_names in layer names are removed. +// Order is otherwise preserved, with the layer key_name being replaced by the +// expand_names. +// @param inst +// @param layer_count +// @param ppp_layer_names VkResult loader_expand_layer_names(struct loader_instance *inst, const char *key_name, uint32_t expand_count, const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], uint32_t *layer_count, char const *const **ppp_layer_names) { @@ -2071,7 +1782,7 @@ VkResult loader_expand_layer_names(struct loader_instance *inst, const char *key void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, const VkInstanceCreateInfo *orig, VkInstanceCreateInfo *ours) { - /* Free the layer names array iff we had to reallocate it */ + // Free the layer names array iff we had to reallocate it if (orig->ppEnabledLayerNames != ours->ppEnabledLayerNames) { loader_instance_heap_free(inst, (void *)ours->ppEnabledLayerNames); } @@ -2087,16 +1798,14 @@ void loader_init_std_validation_props(struct loader_layer_properties *props) { props->info.specVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION); } -/** - * Searches through the existing instance layer lists looking for - * the set of required layer names. If found then it adds a meta property to the - * layer list. - * Assumes the required layers are the same for both instance and device lists. - * @param inst - * @param layer_count number of layers in layer_names - * @param layer_names array of required layer names - * @param layer_instance_list - */ +// Searches through the existing instance layer lists looking for +// the set of required layer names. If found then it adds a meta property to the +// layer list. +// Assumes the required layers are the same for both instance and device lists. +// @param inst +// @param layer_count number of layers in layer_names +// @param layer_names array of required layer names +// @param layer_instance_list static void loader_add_layer_property_meta(const struct loader_instance *inst, uint32_t layer_count, const char layer_names[][VK_MAX_EXTENSION_NAME_SIZE], struct loader_layer_list *layer_instance_list) { @@ -2145,17 +1854,14 @@ static void loader_read_json_layer(const struct loader_instance *inst, struct lo cJSON *ext_item; VkExtensionProperties ext_prop; -/* - * The following are required in the "layer" object: - * (required) "name" - * (required) "type" - * (required) “library_path” - * (required) “api_version” - * (required) “implementation_version” - * (required) “description” - * (required for implicit layers) “disable_environment” - */ - +// The following are required in the "layer" object: +// (required) "name" +// (required) "type" +// (required) “library_path” +// (required) “api_version” +// (required) “implementation_version” +// (required) “description” +// (required for implicit layers) “disable_environment” #define GET_JSON_OBJECT(node, var) \ { \ var = cJSON_GetObjectItem(node, #var); \ @@ -2265,13 +1971,11 @@ static void loader_read_json_layer(const struct loader_instance *inst, struct lo props->disable_env_var.value[sizeof(props->disable_env_var.value) - 1] = '\0'; } -/** -* Now get all optional items and objects and put in list: -* functions -* instance_extensions -* device_extensions -* enable_environment (implicit layers only) -*/ +// Now get all optional items and objects and put in list: +// functions +// instance_extensions +// device_extensions +// enable_environment (implicit layers only) #define GET_JSON_OBJECT(node, var) \ { var = cJSON_GetObjectItem(node, #var); } #define GET_JSON_ITEM(node, var) \ @@ -2453,17 +2157,15 @@ static inline bool layer_json_supports_layers_tag(const layer_json_version *laye return false; } -/** - * Given a cJSON struct (json) of the top level JSON object from layer manifest - * file, add entry to the layer_list. Fill out the layer_properties in this list - * entry from the input cJSON object. - * - * \returns - * void - * layer_list has a new entry and initialized accordingly. - * If the json input object does not have all the required fields no entry - * is added to the list. - */ +// Given a cJSON struct (json) of the top level JSON object from layer manifest +// file, add entry to the layer_list. Fill out the layer_properties in this list +// entry from the input cJSON object. +// +// \returns +// void +// layer_list has a new entry and initialized accordingly. +// If the json input object does not have all the required fields no entry +// is added to the list. static void loader_add_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_instance_list, cJSON *json, bool is_implicit, char *filename) { // The following Fields in layer manifest file that are required: @@ -2569,33 +2271,31 @@ static void loader_add_layer_properties(const struct loader_instance *inst, stru return; } -/** - * Find the Vulkan library manifest files. - * - * This function scans the "location" or "env_override" directories/files - * for a list of JSON manifest files. If env_override is non-NULL - * and has a valid value. Then the location is ignored. Otherwise - * location is used to look for manifest files. The location - * is interpreted as Registry path on Windows and a directory path(s) - * on Linux. "home_location" is an additional directory in the users home - * directory to look at. It is expanded into the dir path - * $XDG_DATA_HOME/home_location or $HOME/.local/share/home_location depending - * on environment variables. This "home_location" is only used on Linux. - * - * \returns - * VKResult - * A string list of manifest files to be opened in out_files param. - * List has a pointer to string for each manifest filename. - * When done using the list in out_files, pointers should be freed. - * Location or override string lists can be either files or directories as - *follows: - * | location | override - * -------------------------------- - * Win ICD | files | files - * Win Layer | files | dirs - * Linux ICD | dirs | files - * Linux Layer| dirs | dirs - */ +// Find the Vulkan library manifest files. +// +// This function scans the "location" or "env_override" directories/files +// for a list of JSON manifest files. If env_override is non-NULL +// and has a valid value. Then the location is ignored. Otherwise +// location is used to look for manifest files. The location +// is interpreted as Registry path on Windows and a directory path(s) +// on Linux. "home_location" is an additional directory in the users home +// directory to look at. It is expanded into the dir path +// $XDG_DATA_HOME/home_location or $HOME/.local/share/home_location depending +// on environment variables. This "home_location" is only used on Linux. +// +// \returns +// VKResult +// A string list of manifest files to be opened in out_files param. +// List has a pointer to string for each manifest filename. +// When done using the list in out_files, pointers should be freed. +// Location or override string lists can be either files or directories as +//follows: +// | location | override +// -------------------------------- +// Win ICD | files | files +// Win Layer | files | dirs +// Linux ICD | dirs | files +// Linux Layer| dirs | dirs static VkResult loader_get_manifest_files(const struct loader_instance *inst, const char *env_override, const char *source_override, bool is_layer, bool warn_if_not_present, const char *location, const char *relative_location, struct loader_manifest_files *out_files) { @@ -2619,7 +2319,7 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co } else if (env_override != NULL) { #if !defined(_WIN32) if (geteuid() != getuid() || getegid() != getgid()) { - /* Don't allow setuid apps to use the env var: */ + // Don't allow setuid apps to use the env var: env_override = NULL; } #endif @@ -2834,7 +2534,7 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co #endif } while (name) { - /* Look for files ending with ".json" suffix */ + // Look for files ending with ".json" suffix uint32_t nlen = (uint32_t)strlen(name); const char *suf = name + nlen - 5; if ((nlen > 5) && !strncmp(suf, ".json", 5)) { @@ -2986,18 +2686,17 @@ out: void loader_init_icd_lib_list() {} void loader_destroy_icd_lib_list() {} -/** - * Try to find the Vulkan ICD driver(s). - * - * This function scans the default system loader path(s) or path - * specified by the \c VK_ICD_FILENAMES environment variable in - * order to find loadable VK ICDs manifest files. From these - * manifest files it finds the ICD libraries. - * - * \returns - * Vulkan result - * (on result == VK_SUCCESS) a list of icds that were discovered - */ + +// Try to find the Vulkan ICD driver(s). +// +// This function scans the default system loader path(s) or path +// specified by the \c VK_ICD_FILENAMES environment variable in +// order to find loadable VK ICDs manifest files. From these +// manifest files it finds the ICD libraries. +// +// \returns +// Vulkan result +// (on result == VK_SUCCESS) a list of icds that were discovered VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) { char *file_str; uint16_t file_major_vers = 0; @@ -3307,7 +3006,7 @@ void loader_implicit_layer_scan(const struct loader_instance *inst, struct loade return; } - /* cleanup any previously scanned libraries */ + // Cleanup any previously scanned libraries loader_delete_layer_properties(inst, instance_layers); loader_platform_thread_lock_mutex(&loader_json_lock); @@ -3428,6 +3127,12 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpa_device_internal(VkDevice dev struct loader_device *dev; struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, NULL); + // Return this function if a layer above here is asking for the vkGetDeviceProcAddr. + // This is so we can properly intercept any device commands needing a terminator. + if (!strcmp(pName, "vkGetDeviceProcAddr")) { + return (PFN_vkVoidFunction)loader_gpa_device_internal; + } + // NOTE: Device Funcs needing Trampoline/Terminator. // Overrides for device functions needing a trampoline and // a terminator because certain device entry-points still need to go @@ -3436,30 +3141,21 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpa_device_internal(VkDevice dev // object before passing the appropriate info along to the ICD. // This is why we also have to override the direct ICD call to // vkGetDeviceProcAddr to intercept those calls. - if (!strcmp(pName, "vkGetDeviceProcAddr")) { - return (PFN_vkVoidFunction)loader_gpa_device_internal; - } else if (!strcmp(pName, "vkCreateSwapchainKHR")) { - return (PFN_vkVoidFunction)terminator_vkCreateSwapchainKHR; - } else if (!strcmp(pName, "vkCreateSharedSwapchainsKHR")) { - return (PFN_vkVoidFunction)terminator_vkCreateSharedSwapchainsKHR; - } else if (!strcmp(pName, "vkDebugMarkerSetObjectTagEXT")) { - return (PFN_vkVoidFunction)terminator_DebugMarkerSetObjectTagEXT; - } else if (!strcmp(pName, "vkDebugMarkerSetObjectNameEXT")) { - return (PFN_vkVoidFunction)terminator_DebugMarkerSetObjectNameEXT; + PFN_vkVoidFunction addr = get_extension_device_proc_terminator(pName); + if (NULL != addr) { + return addr; } - return icd_term->GetDeviceProcAddr(device, pName); + return icd_term->dispatch.GetDeviceProcAddr(device, pName); } -/** - * Initialize device_ext dispatch table entry as follows: - * If dev == NULL find all logical devices created within this instance and - * init the entry (given by idx) in the ext dispatch table. - * If dev != NULL only initialize the entry in the given dev's dispatch table. - * The initialization value is gotten by calling down the device chain with - * GDPA. - * If GDPA returns NULL then don't initialize the dispatch table entry. - */ +// Initialize device_ext dispatch table entry as follows: +// If dev == NULL find all logical devices created within this instance and +// init the entry (given by idx) in the ext dispatch table. +// If dev != NULL only initialize the entry in the given dev's dispatch table. +// The initialization value is gotten by calling down the device chain with +// GDPA. +// If GDPA returns NULL then don't initialize the dispatch table entry. static void loader_init_dispatch_dev_ext_entry(struct loader_instance *inst, struct loader_device *dev, uint32_t idx, const char *funcName) @@ -3480,11 +3176,8 @@ static void loader_init_dispatch_dev_ext_entry(struct loader_instance *inst, str } } -/** - * Find all dev extension in the hash table and initialize the dispatch table - * for dev for each of those extension entrypoints found in hash table. - - */ +// Find all dev extension in the hash table and initialize the dispatch table +// for dev for each of those extension entrypoints found in hash table. void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev) { for (uint32_t i = 0; i < MAX_NUM_UNKNOWN_EXTS; i++) { if (inst->dev_ext_disp_hash[i].func_name != NULL) @@ -3624,24 +3317,22 @@ static bool loader_name_in_dev_ext_table(struct loader_instance *inst, uint32_t return false; } -/** - * This function returns generic trampoline code address for unknown entry - * points. - * Presumably, these unknown entry points (as given by funcName) are device - * extension entrypoints. A hash table is used to keep a list of unknown entry - * points and their mapping to the device extension dispatch table - * (struct loader_dev_ext_dispatch_table). - * \returns - * For a given entry point string (funcName), if an existing mapping is found - * the - * trampoline address for that mapping is returned. Otherwise, this unknown - * entry point - * has not been seen yet. Next check if a layer or ICD supports it. If so then - * a - * new entry in the hash table is initialized and that trampoline address for - * the new entry is returned. Null is returned if the hash table is full or - * if no discovered layer or ICD returns a non-NULL GetProcAddr for it. - */ +// This function returns generic trampoline code address for unknown entry +// points. +// Presumably, these unknown entry points (as given by funcName) are device +// extension entrypoints. A hash table is used to keep a list of unknown entry +// points and their mapping to the device extension dispatch table +// (struct loader_dev_ext_dispatch_table). +// \returns +// For a given entry point string (funcName), if an existing mapping is found +// the +// trampoline address for that mapping is returned. Otherwise, this unknown +// entry point +// has not been seen yet. Next check if a layer or ICD supports it. If so then +// a +// new entry in the hash table is initialized and that trampoline address for +// the new entry is returned. Null is returned if the hash table is full or +// if no discovered layer or ICD returns a non-NULL GetProcAddr for it. void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName) { uint32_t idx; uint32_t seed = 0; @@ -3893,10 +3584,9 @@ out: } struct loader_instance *loader_get_instance(const VkInstance instance) { - /* look up the loader_instance in our list by comparing dispatch tables, as - * there is no guarantee the instance is still a loader_instance* after any - * layers which wrap the instance object. - */ + // look up the loader_instance in our list by comparing dispatch tables, as + // there is no guarantee the instance is still a loader_instance* after any + // layers which wrap the instance object. const VkLayerInstanceDispatchTable *disp; struct loader_instance *ptr_instance = NULL; disp = loader_get_instance_layer_dispatch(instance); @@ -3930,7 +3620,7 @@ static void loader_close_layer_lib(const struct loader_instance *inst, struct lo void loader_deactivate_layers(const struct loader_instance *instance, struct loader_device *device, struct loader_layer_list *list) { - /* delete instance list of enabled layers and close any layer libraries */ + // Delete instance list of enabled layers and close any layer libraries for (uint32_t i = 0; i < list->count; i++) { struct loader_layer_properties *layer_prop = &list->list[i]; @@ -3939,10 +3629,8 @@ void loader_deactivate_layers(const struct loader_instance *instance, struct loa loader_destroy_layer_list(instance, device, list); } -/** - * Go through the search_list and find any layers which match type. If layer - * type match is found in then add it to ext_list. - */ +// Go through the search_list and find any layers which match type. If layer +// type match is found in then add it to ext_list. static void loader_add_layer_implicit(const struct loader_instance *inst, const enum layer_type type, struct loader_layer_list *list, const struct loader_layer_list *search_list) { bool enable; @@ -3951,7 +3639,7 @@ static void loader_add_layer_implicit(const struct loader_instance *inst, const for (i = 0; i < search_list->count; i++) { const struct loader_layer_properties *prop = &search_list->list[i]; if (prop->type & type) { - /* Found an implicit layer, see if it should be enabled */ + // Found an implicit layer, see if it should be enabled enable = false; // if no enable_environment variable is specified, this implicit @@ -3982,11 +3670,9 @@ static void loader_add_layer_implicit(const struct loader_instance *inst, const } } -/** - * Get the layer name(s) from the env_name environment variable. If layer - * is found in search_list then add it to layer_list. But only add it to - * layer_list if type matches. - */ +// Get the layer name(s) from the env_name environment variable. If layer +// is found in search_list then add it to layer_list. But only add it to +// layer_list if type matches. static void loader_add_layer_env(struct loader_instance *inst, const enum layer_type type, const char *env_name, struct loader_layer_list *layer_list, const struct loader_layer_list *search_list) { char *layerEnv; @@ -4007,10 +3693,8 @@ static void loader_add_layer_env(struct loader_instance *inst, const enum layer_ while (name && *name) { next = loader_get_next_path(name); if (!strcmp(std_validation_str, name)) { - /* add meta list of layers - don't attempt to remove duplicate layers already added by app or - env var - */ + // Add meta list of layers + // Don't attempt to remove duplicate layers already added by app or env var loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Expanding meta layer %s found in environment variable", std_validation_str); if (type == VK_LAYER_TYPE_INSTANCE_EXPLICIT) inst->activated_layers_are_std_val = true; @@ -4039,13 +3723,13 @@ VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkIns return VK_ERROR_OUT_OF_HOST_MEMORY; } - /* Add any implicit layers first */ + // Add any implicit layers first loader_add_layer_implicit(inst, VK_LAYER_TYPE_INSTANCE_IMPLICIT, &inst->activated_layer_list, instance_layers); - /* Add any layers specified via environment variable next */ + // Add any layers specified via environment variable next loader_add_layer_env(inst, VK_LAYER_TYPE_INSTANCE_EXPLICIT, "VK_INSTANCE_LAYERS", &inst->activated_layer_list, instance_layers); - /* Add layers specified by the application */ + // Add layers specified by the application err = loader_add_layer_names_to_list(inst, &inst->activated_layer_list, pCreateInfo->enabledLayerCount, pCreateInfo->ppEnabledLayerNames, instance_layers); @@ -4082,24 +3766,22 @@ bool loader_get_layer_interface_version(PFN_vkNegotiateLoaderLayerInterfaceVersi return true; } -/* - * Given the list of layers to activate in the loader_instance - * structure. This function will add a VkLayerInstanceCreateInfo - * structure to the VkInstanceCreateInfo.pNext pointer. - * Each activated layer will have it's own VkLayerInstanceLink - * structure that tells the layer what Get*ProcAddr to call to - * get function pointers to the next layer down. - * Once the chain info has been created this function will - * execute the CreateInstance call chain. Each layer will - * then have an opportunity in it's CreateInstance function - * to setup it's dispatch table when the lower layer returns - * successfully. - * Each layer can wrap or not-wrap the returned VkInstance object - * as it sees fit. - * The instance chain is terminated by a loader function - * that will call CreateInstance on all available ICD's and - * cache those VkInstance objects for future use. - */ +// Given the list of layers to activate in the loader_instance +// structure. This function will add a VkLayerInstanceCreateInfo +// structure to the VkInstanceCreateInfo.pNext pointer. +// Each activated layer will have it's own VkLayerInstanceLink +// structure that tells the layer what Get*ProcAddr to call to +// get function pointers to the next layer down. +// Once the chain info has been created this function will +// execute the CreateInstance call chain. Each layer will +// then have an opportunity in it's CreateInstance function +// to setup it's dispatch table when the lower layer returns +// successfully. +// Each layer can wrap or not-wrap the returned VkInstance object +// as it sees fit. +// The instance chain is terminated by a loader function +// that will call CreateInstance on all available ICD's and +// cache those VkInstance objects for future use. VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, struct loader_instance *inst, VkInstance *created_instance) { uint32_t activated_layers = 0; @@ -4269,6 +3951,49 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p memcpy(&loader_create_info, pCreateInfo, sizeof(VkDeviceCreateInfo)); + // Before we continue, we need to find out if the KHX_device_group extension is in the enabled list. If it is, we then + // need to look for the corresponding VkDeviceGroupDeviceCreateInfoKHX struct in the device list. This is because we + // need to replace all the incoming physical device values (which are really loader trampoline physical device values) + // with the layer/ICD version. + if (inst->enabled_known_extensions.khx_device_group_creation == 1) { + struct VkStructureHeader *pNext = (struct VkStructureHeader *)loader_create_info.pNext; + struct VkStructureHeader *pPrev = (struct VkStructureHeader *)&loader_create_info; + while (NULL != pNext) { + if (VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHX == pNext->sType) { + VkDeviceGroupDeviceCreateInfoKHX *cur_struct = (VkDeviceGroupDeviceCreateInfoKHX *)pNext; + if (0 < cur_struct->physicalDeviceCount && NULL != cur_struct->pPhysicalDevices) { + VkDeviceGroupDeviceCreateInfoKHX *temp_struct = loader_stack_alloc(sizeof(VkDeviceGroupDeviceCreateInfoKHX)); + VkPhysicalDevice *phys_dev_array = NULL; + if (NULL == temp_struct) { + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + memcpy(temp_struct, cur_struct, sizeof(VkDeviceGroupDeviceCreateInfoKHX)); + phys_dev_array = loader_stack_alloc(sizeof(VkPhysicalDevice) * cur_struct->physicalDeviceCount); + if (NULL == phys_dev_array) { + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + + // Before calling down, replace the incoming physical device values (which are really loader trampoline + // physical devices) with the next layer (or possibly even the terminator) physical device values. + struct loader_physical_device_tramp *cur_tramp; + for (uint32_t phys_dev = 0; phys_dev < cur_struct->physicalDeviceCount; phys_dev++) { + cur_tramp = (struct loader_physical_device_tramp *)cur_struct->pPhysicalDevices[phys_dev]; + phys_dev_array[phys_dev] = cur_tramp->phys_dev; + } + temp_struct->pPhysicalDevices = phys_dev_array; + + // Replace the old struct in the pNext chain with this one. + pPrev->pNext = (const void *)temp_struct; + pNext = (struct VkStructureHeader *)(temp_struct); + } + break; + } + + pPrev = pNext; + pNext = (struct VkStructureHeader *)(pPrev->pNext); + } + } + layer_device_link_info = loader_stack_alloc(sizeof(VkLayerDeviceLink) * dev->activated_layer_list.count); if (!layer_device_link_info) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -4295,10 +4020,8 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p continue; } - // If we can negotiate an interface version, then we can also - // get everything we need from the one function call, so try - // that first, and see if we can get all the function pointers - // necessary from that one call. + // If we can negotiate an interface version, then we can also get everything we need from the one function + // call, so try that first, and see if we can get all the function pointers necessary from that one call. if (NULL == layer_prop->functions.negotiate_layer_interface) { PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_interface = NULL; if (strlen(layer_prop->functions.str_negotiate_interface) == 0) { @@ -4315,13 +4038,11 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p VkNegotiateLayerInterface interface_struct; if (loader_get_layer_interface_version(negotiate_interface, &interface_struct)) { - // Go ahead and set the properites version to the - // correct value. + // Go ahead and set the properites version to the correct value. layer_prop->interface_version = interface_struct.loaderLayerInterfaceVersion; - // If the interface is 2 or newer, we have access to the - // new GetPhysicalDeviceProcAddr function, so grab it, - // and the other necessary functions, from the structure. + // If the interface is 2 or newer, we have access to the new GetPhysicalDeviceProcAddr + // function, so grab it, and the other necessary functions, from the structure. if (interface_struct.loaderLayerInterfaceVersion > 1) { fpGIPA = interface_struct.pfnGetInstanceProcAddr; fpGDPA = interface_struct.pfnGetDeviceProcAddr; @@ -4478,20 +4199,17 @@ VkResult loader_validate_instance_extensions(const struct loader_instance *inst, extension_prop = NULL; - /* Not in global list, search layer extension lists */ + // Not in global list, search layer extension lists for (uint32_t j = 0; j < pCreateInfo->enabledLayerCount; j++) { layer_prop = loader_get_layer_property(pCreateInfo->ppEnabledLayerNames[j], instance_layers); if (!layer_prop) { - /* Should NOT get here, loader_validate_layers - * should have already filtered this case out. - */ + // Should NOT get here, loader_validate_layers should have already filtered this case out. continue; } extension_prop = get_extension_property(pCreateInfo->ppEnabledExtensionNames[i], &layer_prop->instance_extension_list); if (extension_prop) { - /* Found the extension in one of the layers enabled by the app. - */ + // Found the extension in one of the layers enabled by the app. break; } } @@ -4601,8 +4319,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI struct loader_extension_list icd_exts; loader_log(ptr_instance, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Build ICD instance extension list"); - // traverse scanned icd list adding non-duplicate extensions to the - // list + // traverse scanned icd list adding non-duplicate extensions to the list res = loader_init_generic_list(ptr_instance, (struct loader_generic_list *)&icd_exts, sizeof(VkExtensionProperties)); if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { // If out of memory, bail immediately. @@ -4624,8 +4341,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI // If out of memory, bail immediately. goto out; } else { - // Something bad happened with this ICD, so free it and try - // the next. + // Something bad happened with this ICD, so free it and try the next. ptr_instance->icd_terms = icd_term->next; icd_term->next = NULL; loader_icd_destroy(ptr_instance, icd_term, pAllocator); @@ -4660,8 +4376,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI continue; } - if (!loader_icd_init_entrys(icd_term, icd_term->instance, - ptr_instance->icd_tramp_list.scanned_list[i].GetInstanceProcAddr)) { + if (!loader_icd_init_entries(icd_term, icd_term->instance, + ptr_instance->icd_tramp_list.scanned_list[i].GetInstanceProcAddr)) { loader_log(ptr_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "terminator_CreateInstance: Failed to CreateInstance and find " "entrypoints with ICD. Skipping ICD."); @@ -4672,9 +4388,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI one_icd_successful = true; } - // If no ICDs were added to instance list and res is unchanged - // from it's initial value, the loader was unable to find - // a suitable ICD. + // If no ICDs were added to instance list and res is unchanged from it's initial value, the loader was unable to + // find a suitable ICD. if (VK_SUCCESS == res && (ptr_instance->icd_terms == NULL || !one_icd_successful)) { res = VK_ERROR_INCOMPATIBLE_DRIVER; } @@ -4686,7 +4401,7 @@ out: icd_term = ptr_instance->icd_terms; ptr_instance->icd_terms = icd_term->next; if (NULL != icd_term->instance) { - icd_term->DestroyInstance(icd_term->instance, pAllocator); + icd_term->dispatch.DestroyInstance(icd_term->instance, pAllocator); } loader_icd_destroy(ptr_instance, icd_term, pAllocator); } @@ -4721,7 +4436,7 @@ VKAPI_ATTR void VKAPI_CALL terminator_DestroyInstance(VkInstance instance, const while (NULL != icd_terms) { if (icd_terms->instance) { - icd_terms->DestroyInstance(icd_terms->instance, pAllocator); + icd_terms->dispatch.DestroyInstance(icd_terms->instance, pAllocator); } next_icd_term = icd_terms->next; icd_terms->instance = VK_NULL_HANDLE; @@ -4751,7 +4466,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_device *dev = (struct loader_device *)*pDevice; - PFN_vkCreateDevice fpCreateDevice = icd_term->CreateDevice; + PFN_vkCreateDevice fpCreateDevice = icd_term->dispatch.CreateDevice; struct loader_extension_list icd_exts; dev->phys_dev_term = phys_dev_term; @@ -4796,7 +4511,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical goto out; } - res = loader_add_device_extensions(icd_term->this_instance, icd_term->EnumerateDeviceExtensionProperties, + res = loader_add_device_extensions(icd_term->this_instance, icd_term->dispatch.EnumerateDeviceExtensionProperties, phys_dev_term->phys_dev, icd_term->scanned_icd->lib_name, &icd_exts); if (res != VK_SUCCESS) { goto out; @@ -4816,6 +4531,48 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical } } + // Before we continue, If KHX_device_group is the list of enabled and viable extensions, then we then need to look for the + // corresponding VkDeviceGroupDeviceCreateInfoKHX struct in the device list and replace all the physical device values (which + // are really loader physical device terminator values) with the ICD versions. + if (icd_term->this_instance->enabled_known_extensions.khx_device_group_creation == 1) { + struct VkStructureHeader *pNext = (struct VkStructureHeader *)localCreateInfo.pNext; + struct VkStructureHeader *pPrev = (struct VkStructureHeader *)&localCreateInfo; + while (NULL != pNext) { + if (VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHX == pNext->sType) { + VkDeviceGroupDeviceCreateInfoKHX *cur_struct = (VkDeviceGroupDeviceCreateInfoKHX *)pNext; + if (0 < cur_struct->physicalDeviceCount && NULL != cur_struct->pPhysicalDevices) { + VkDeviceGroupDeviceCreateInfoKHX *temp_struct = loader_stack_alloc(sizeof(VkDeviceGroupDeviceCreateInfoKHX)); + VkPhysicalDevice *phys_dev_array = NULL; + if (NULL == temp_struct) { + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + memcpy(temp_struct, cur_struct, sizeof(VkDeviceGroupDeviceCreateInfoKHX)); + phys_dev_array = loader_stack_alloc(sizeof(VkPhysicalDevice) * cur_struct->physicalDeviceCount); + if (NULL == phys_dev_array) { + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + + // Before calling down, replace the incoming physical device values (which are really loader terminator + // physical devices) with the ICDs physical device values. + struct loader_physical_device_term *cur_term; + for (uint32_t phys_dev = 0; phys_dev < cur_struct->physicalDeviceCount; phys_dev++) { + cur_term = (struct loader_physical_device_term *)cur_struct->pPhysicalDevices[phys_dev]; + phys_dev_array[phys_dev] = cur_term->phys_dev; + } + temp_struct->pPhysicalDevices = phys_dev_array; + + // Replace the old struct in the pNext chain with this one. + pPrev->pNext = (const void *)temp_struct; + pNext = (struct VkStructureHeader *)(temp_struct); + } + break; + } + + pPrev = pNext; + pNext = (struct VkStructureHeader *)(pPrev->pNext); + } + } + res = fpCreateDevice(phys_dev_term->phys_dev, &localCreateInfo, pAllocator, &dev->icd_device); if (res != VK_SUCCESS) { loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -4828,7 +4585,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical *pDevice = dev->icd_device; loader_add_logical_device(icd_term->this_instance, icd_term, dev); - /* Init dispatch pointer in new device object */ + // Init dispatch pointer in new device object loader_init_dispatch(*pDevice, &dev->loader_dispatch); out: @@ -4983,7 +4740,7 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { // For each ICD, query the number of physical devices, and then get an // internal value for those physical devices. for (uint32_t icd_idx = 0; NULL != icd_term; icd_term = icd_term->next, icd_idx++) { - res = icd_term->EnumeratePhysicalDevices(icd_term->instance, &icd_phys_dev_array[icd_idx].count, NULL); + res = icd_term->dispatch.EnumeratePhysicalDevices(icd_term->instance, &icd_phys_dev_array[icd_idx].count, NULL); if (VK_SUCCESS != res) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevs: Call to " @@ -5004,8 +4761,8 @@ VkResult setupLoaderTermPhysDevs(struct loader_instance *inst) { goto out; } - res = icd_term->EnumeratePhysicalDevices(icd_term->instance, &(icd_phys_dev_array[icd_idx].count), - icd_phys_dev_array[icd_idx].phys_devs); + res = icd_term->dispatch.EnumeratePhysicalDevices(icd_term->instance, &(icd_phys_dev_array[icd_idx].count), + icd_phys_dev_array[icd_idx].phys_devs); if (VK_SUCCESS != res) { goto out; } @@ -5149,8 +4906,8 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties(VkPhysicalDevi VkPhysicalDeviceProperties *pProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL != icd_term->GetPhysicalDeviceProperties) { - icd_term->GetPhysicalDeviceProperties(phys_dev_term->phys_dev, pProperties); + if (NULL != icd_term->dispatch.GetPhysicalDeviceProperties) { + icd_term->dispatch.GetPhysicalDeviceProperties(phys_dev_term->phys_dev, pProperties); } } @@ -5159,8 +4916,8 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties(VkP VkQueueFamilyProperties *pProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL != icd_term->GetPhysicalDeviceQueueFamilyProperties) { - icd_term->GetPhysicalDeviceQueueFamilyProperties(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, pProperties); + if (NULL != icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties) { + icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, pProperties); } } @@ -5168,8 +4925,8 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties(VkPhysic VkPhysicalDeviceMemoryProperties *pProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL != icd_term->GetPhysicalDeviceMemoryProperties) { - icd_term->GetPhysicalDeviceMemoryProperties(phys_dev_term->phys_dev, pProperties); + if (NULL != icd_term->dispatch.GetPhysicalDeviceMemoryProperties) { + icd_term->dispatch.GetPhysicalDeviceMemoryProperties(phys_dev_term->phys_dev, pProperties); } } @@ -5177,8 +4934,8 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice VkPhysicalDeviceFeatures *pFeatures) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL != icd_term->GetPhysicalDeviceFeatures) { - icd_term->GetPhysicalDeviceFeatures(phys_dev_term->phys_dev, pFeatures); + if (NULL != icd_term->dispatch.GetPhysicalDeviceFeatures) { + icd_term->dispatch.GetPhysicalDeviceFeatures(phys_dev_term->phys_dev, pFeatures); } } @@ -5186,8 +4943,8 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties(VkPhysic VkFormatProperties *pFormatInfo) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL != icd_term->GetPhysicalDeviceFormatProperties) { - icd_term->GetPhysicalDeviceFormatProperties(phys_dev_term->phys_dev, format, pFormatInfo); + if (NULL != icd_term->dispatch.GetPhysicalDeviceFormatProperties) { + icd_term->dispatch.GetPhysicalDeviceFormatProperties(phys_dev_term->phys_dev, format, pFormatInfo); } } @@ -5197,14 +4954,14 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties VkImageFormatProperties *pImageFormatProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL == icd_term->GetPhysicalDeviceImageFormatProperties) { + if (NULL == icd_term->dispatch.GetPhysicalDeviceImageFormatProperties) { loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Encountered the vkEnumerateDeviceLayerProperties " "terminator. This means a layer improperly continued."); return VK_ERROR_INITIALIZATION_FAILED; } - return icd_term->GetPhysicalDeviceImageFormatProperties(phys_dev_term->phys_dev, format, type, tiling, usage, flags, - pImageFormatProperties); + return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties(phys_dev_term->phys_dev, format, type, tiling, usage, flags, + pImageFormatProperties); } VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, @@ -5214,9 +4971,9 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperti VkSparseImageFormatProperties *pProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (NULL != icd_term->GetPhysicalDeviceSparseImageFormatProperties) { - icd_term->GetPhysicalDeviceSparseImageFormatProperties(phys_dev_term->phys_dev, format, type, samples, usage, tiling, - pNumProperties, pProperties); + if (NULL != icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties) { + icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties(phys_dev_term->phys_dev, format, type, samples, usage, + tiling, pNumProperties, pProperties); } } @@ -5231,18 +4988,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties(VkP assert(pLayerName == NULL || strlen(pLayerName) == 0); - /* Any layer or trampoline wrapping should be removed at this point in time - * can just cast to the expected type for VkPhysicalDevice. */ + // Any layer or trampoline wrapping should be removed at this point in time can just cast to the expected + // type for VkPhysicalDevice. phys_dev_term = (struct loader_physical_device_term *)physicalDevice; - /* this case is during the call down the instance chain with pLayerName - * == NULL*/ + // This case is during the call down the instance chain with pLayerName == NULL struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; uint32_t icd_ext_count = *pPropertyCount; VkResult res; - /* get device extensions */ - res = icd_term->EnumerateDeviceExtensionProperties(phys_dev_term->phys_dev, NULL, &icd_ext_count, pProperties); + // Get the available device extensions + res = icd_term->dispatch.EnumerateDeviceExtensionProperties(phys_dev_term->phys_dev, NULL, &icd_ext_count, pProperties); if (res != VK_SUCCESS) { goto out; } @@ -5254,22 +5010,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties(VkP loader_add_layer_implicit(icd_term->this_instance, VK_LAYER_TYPE_INSTANCE_IMPLICIT, &implicit_layer_list, &icd_term->this_instance->instance_layer_list); - /* we need to determine which implicit layers are active, - * and then add their extensions. This can't be cached as - * it depends on results of environment variables (which can change). - */ + // We need to determine which implicit layers are active, and then add their extensions. This can't be cached as + // it depends on results of environment variables (which can change). if (pProperties != NULL) { - /* initialize dev_extension list within the physicalDevice object */ + // Initialize dev_extension list within the physicalDevice object res = loader_init_device_extensions(icd_term->this_instance, phys_dev_term, icd_ext_count, pProperties, &icd_exts); if (res != VK_SUCCESS) { goto out; } - /* we need to determine which implicit layers are active, - * and then add their extensions. This can't be cached as - * it depends on results of environment variables (which can - * change). - */ + // We need to determine which implicit layers are active, and then add their extensions. This can't be cached as + // it depends on results of environment variables (which can change). res = loader_add_to_ext_list(icd_term->this_instance, &all_exts, icd_exts.count, icd_exts.list); if (res != VK_SUCCESS) { goto out; @@ -5293,17 +5044,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties(VkP for (uint32_t i = 0; i < all_exts.count && i < capacity; i++) { props[i] = all_exts.list[i]; } - /* wasn't enough space for the extensions, we did partial copy now - * return VK_INCOMPLETE */ + + // Wasn't enough space for the extensions, we did partial copy now return VK_INCOMPLETE if (capacity < all_exts.count) { res = VK_INCOMPLETE; } else { *pPropertyCount = all_exts.count; } } else { - /* just return the count; need to add in the count of implicit layer - * extensions - * don't worry about duplicates being added in the count */ + // Just return the count; need to add in the count of implicit layer extensions + // don't worry about duplicates being added in the count *pPropertyCount = icd_ext_count; for (uint32_t i = 0; i < implicit_layer_list.count; i++) { diff --git a/loader/loader.h b/loader/loader.h index 9a4fd8fc..417588ea 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -32,9 +32,9 @@ #include "vk_loader_platform.h" #include "vk_loader_layer.h" #include <vulkan/vk_layer.h> - #include <vulkan/vk_icd.h> #include <assert.h> +#include "vk_loader_extensions.h" #if defined(__GNUC__) && __GNUC__ >= 4 #define LOADER_EXPORT __attribute__((visibility("default"))) @@ -189,121 +189,29 @@ struct loader_device { struct loader_device *next; }; -/* per ICD structure */ +// Per ICD information + +// Per ICD structure struct loader_icd_term { // pointers to find other structs const struct loader_scanned_icd *scanned_icd; const struct loader_instance *this_instance; struct loader_device *logical_device_list; VkInstance instance; // instance object from the icd - PFN_vkGetDeviceProcAddr GetDeviceProcAddr; - PFN_vkDestroyInstance DestroyInstance; - PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; - PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; - PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties; - PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties; - PFN_vkCreateDevice CreateDevice; - PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; - PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties; - PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; - PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties; - PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties; - // WSI extensions - PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR; - PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR; - PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR; - PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR; -#ifdef VK_USE_PLATFORM_WIN32_KHR - PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR; - PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR GetPhysicalDeviceWin32PresentationSupportKHR; -#endif -#ifdef VK_USE_PLATFORM_MIR_KHR - PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR; - PFN_vkGetPhysicalDeviceMirPresentationSupportKHR GetPhysicalDeviceMirPresentationSupportKHR; -#endif -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR; - PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR GetPhysicalDeviceWaylandPresentationSupportKHR; -#endif -#ifdef VK_USE_PLATFORM_XCB_KHR - PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR; - PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR GetPhysicalDeviceXcbPresentationSupportKHR; -#endif -#ifdef VK_USE_PLATFORM_XLIB_KHR - PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR; - PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR GetPhysicalDeviceXlibPresentationSupportKHR; -#endif - PFN_vkGetPhysicalDeviceDisplayPropertiesKHR GetPhysicalDeviceDisplayPropertiesKHR; - PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR GetPhysicalDeviceDisplayPlanePropertiesKHR; - PFN_vkGetDisplayPlaneSupportedDisplaysKHR GetDisplayPlaneSupportedDisplaysKHR; - PFN_vkGetDisplayModePropertiesKHR GetDisplayModePropertiesKHR; - PFN_vkCreateDisplayModeKHR CreateDisplayModeKHR; - PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR; - PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR; - PFN_vkDestroySurfaceKHR DestroySurfaceKHR; - PFN_vkCreateSwapchainKHR CreateSwapchainKHR; - PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR; - - // KHR_get_physical_device_properties2 - PFN_vkGetPhysicalDeviceFeatures2KHR GetPhysicalDeviceFeatures2KHR; - PFN_vkGetPhysicalDeviceProperties2KHR GetPhysicalDeviceProperties2KHR; - PFN_vkGetPhysicalDeviceFormatProperties2KHR GetPhysicalDeviceFormatProperties2KHR; - PFN_vkGetPhysicalDeviceImageFormatProperties2KHR GetPhysicalDeviceImageFormatProperties2KHR; - PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR GetPhysicalDeviceQueueFamilyProperties2KHR; - PFN_vkGetPhysicalDeviceMemoryProperties2KHR GetPhysicalDeviceMemoryProperties2KHR; - PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR GetPhysicalDeviceSparseImageFormatProperties2KHR; - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT - // EXT_acquire_xlib_display - PFN_vkAcquireXlibDisplayEXT AcquireXlibDisplayEXT; - PFN_vkGetRandROutputDisplayEXT GetRandROutputDisplayEXT; -#endif - - // EXT_debug_report - PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT; - PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT; - PFN_vkDebugReportMessageEXT DebugReportMessageEXT; - - // EXT_debug_marker (items needing a trampoline/terminator) - PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT; - PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT; - - // EXT_direct_mode_display - PFN_vkReleaseDisplayEXT ReleaseDisplayEXT; - - // EXT_display_surface_counter - PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT GetPhysicalDeviceSurfaceCapabilities2EXT; - - // NV_external_memory_capabilities - PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV GetPhysicalDeviceExternalImageFormatPropertiesNV; - - // NVX_device_generated_commands - PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX GetPhysicalDeviceGeneratedCommandsPropertiesNVX; + struct loader_icd_term_dispatch dispatch; struct loader_icd_term *next; PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; }; -// per ICD library structure +// Per ICD library structure struct loader_icd_tramp_list { size_t capacity; uint32_t count; struct loader_scanned_icd *scanned_list; }; -union loader_instance_extension_enables { - struct { - uint8_t khr_get_physical_device_properties2 : 1; - uint8_t ext_acquire_xlib_display : 1; - uint8_t ext_debug_report : 1; - uint8_t ext_direct_mode_display : 1; - uint8_t ext_display_surface_counter : 1; - uint8_t nv_external_memory_capabilities : 1; - }; - uint64_t padding[4]; -}; - struct loader_instance_dispatch_table { VkLayerInstanceDispatchTable layer_inst_disp; // must be first entry in structure @@ -311,7 +219,7 @@ struct loader_instance_dispatch_table { PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; }; -// per instance structure +// Per instance structure struct loader_instance { struct loader_instance_dispatch_table *disp; // must be first entry in structure @@ -369,27 +277,27 @@ struct loader_instance { bool wsi_display_enabled; }; -/* VkPhysicalDevice requires special treatment by loader. Firstly, terminator - * code must be able to get the struct loader_icd_term to call into the proper - * driver (multiple ICD/gpu case). This can be accomplished by wrapping the - * created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices(). - * Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice - * in trampoline code. This implies, that the loader trampoline code must also - * wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to - * wrap the VkPhysicalDevice created object twice. In trampoline code it can't - * rely on the terminator object wrapping since a layer may also wrap. Since - * trampoline code wraps the VkPhysicalDevice this means all loader trampoline - * code that passes a VkPhysicalDevice should unwrap it. */ - -/* per enumerated PhysicalDevice structure, used to wrap in trampoline code and - also same structure used to wrap in terminator code */ +// VkPhysicalDevice requires special treatment by loader. Firstly, terminator +// code must be able to get the struct loader_icd_term to call into the proper +// driver (multiple ICD/gpu case). This can be accomplished by wrapping the +// created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices(). +// Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice +// in trampoline code. This implies, that the loader trampoline code must also +// wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to +// wrap the VkPhysicalDevice created object twice. In trampoline code it can't +// rely on the terminator object wrapping since a layer may also wrap. Since +// trampoline code wraps the VkPhysicalDevice this means all loader trampoline +// code that passes a VkPhysicalDevice should unwrap it. + +// Per enumerated PhysicalDevice structure, used to wrap in trampoline code and +// also same structure used to wrap in terminator code struct loader_physical_device_tramp { struct loader_instance_dispatch_table *disp; // must be first entry in structure struct loader_instance *this_instance; VkPhysicalDevice phys_dev; // object from layers/loader terminator }; -/* per enumerated PhysicalDevice structure, used to wrap in terminator code */ +// Per enumerated PhysicalDevice structure, used to wrap in terminator code struct loader_physical_device_term { struct loader_instance_dispatch_table *disp; // must be first entry in structure struct loader_icd_term *this_icd_term; @@ -445,13 +353,12 @@ static inline void loader_init_dispatch(void *obj, const void *data) { loader_set_dispatch(obj, data); } -/* global variables used across files */ +// Global variables used across files extern struct loader_struct loader; extern THREAD_LOCAL_DECL struct loader_instance *tls_instance; extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init); extern loader_platform_thread_mutex loader_lock; extern loader_platform_thread_mutex loader_json_lock; -extern const VkLayerInstanceDispatchTable instance_disp; extern const char *std_validation_str; struct loader_msg_callback_map_entry { @@ -459,7 +366,7 @@ struct loader_msg_callback_map_entry { VkDebugReportCallbackEXT loader_obj; }; -/* helper function definitions */ +// Helper function definitions void *loader_instance_heap_alloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope allocationScope); void loader_instance_heap_free(const struct loader_instance *instance, void *pMemory); void *loader_instance_heap_realloc(const struct loader_instance *instance, void *pMemory, size_t orig_size, size_t size, @@ -563,51 +470,6 @@ VkResult loader_validate_device_extensions(struct loader_physical_device_tramp * VkResult setupLoaderTrampPhysDevs(VkInstance instance); VkResult setupLoaderTermPhysDevs(struct loader_instance *inst); -/* instance layer chain termination entrypoint definitions */ -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkInstance *pInstance); - -VKAPI_ATTR void VKAPI_CALL terminator_DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, - VkPhysicalDevice *pPhysicalDevices); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures *pFeatures); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, - VkFormatProperties *pFormatInfo); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, - VkImageType type, VkImageTiling tiling, - VkImageUsageFlags usage, VkImageCreateFlags flags, - VkImageFormatProperties *pImageFormatProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, - VkImageType type, VkSampleCountFlagBits samples, - VkImageUsageFlags usage, VkImageTiling tiling, - uint32_t *pNumProperties, - VkSparseImageFormatProperties *pProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties *pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, - const char *pLayerName, uint32_t *pCount, - VkExtensionProperties *pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, - VkLayerProperties *pProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, - VkQueueFamilyProperties *pProperties); - -VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceMemoryProperties *pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkDevice *pDevice); - VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array); -#endif /* LOADER_H */ +#endif // LOADER_H diff --git a/loader/trampoline.c b/loader/trampoline.c index 23a1b702..2550cbf5 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -30,70 +30,62 @@ #include "loader.h" #include "debug_report.h" #include "wsi.h" -#include "extensions.h" +#include "vk_loader_extensions.h" #include "gpa_helper.h" -#include "table_ops.h" - -/* Trampoline entrypoints are in this file for core Vulkan commands */ -/** - * Get an instance level or global level entry point address. - * @param instance - * @param pName - * @return - * If instance == NULL returns a global level functions only - * If instance is valid returns a trampoline entry point for all dispatchable - * Vulkan - * functions both core and extensions. - */ + +// Trampoline entrypoints are in this file for core Vulkan commands + +// Get an instance level or global level entry point address. +// @param instance +// @param pName +// @return +// If instance == NULL returns a global level functions only +// If instance is valid returns a trampoline entry point for all dispatchable Vulkan +// functions both core and extensions. LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName) { void *addr; addr = globalGetProcAddr(pName); if (instance == VK_NULL_HANDLE) { - // get entrypoint addresses that are global (no dispatchable object) + // Get entrypoint addresses that are global (no dispatchable object) return addr; } else { - // if a global entrypoint return NULL + // If a global entrypoint return NULL if (addr) return NULL; } struct loader_instance *ptr_instance = loader_get_instance(instance); if (ptr_instance == NULL) return NULL; - // Return trampoline code for non-global entrypoints including any - // extensions. + // Return trampoline code for non-global entrypoints including any extensions. // Device extensions are returned if a layer or ICD supports the extension. // Instance extensions are returned if the extension is enabled and the // loader or someone else supports the extension return trampolineGetProcAddr(ptr_instance, pName); } -/** - * Get a device level or global level entry point address. - * @param device - * @param pName - * @return - * If device is valid, returns a device relative entry point for device level - * entry points both core and extensions. - * Device relative means call down the device chain. - */ +// Get a device level or global level entry point address. +// @param device +// @param pName +// @return +// If device is valid, returns a device relative entry point for device level +// entry points both core and extensions. +// Device relative means call down the device chain. LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *pName) { void *addr; - /* for entrypoints that loader must handle (ie non-dispatchable or create - object) - make sure the loader entrypoint is returned */ + // For entrypoints that loader must handle (ie non-dispatchable or create object) + // make sure the loader entrypoint is returned addr = loader_non_passthrough_gdpa(pName); if (addr) { return addr; } - /* Although CreateDevice is on device chain it's dispatchable object isn't - * a VkDevice or child of VkDevice so return NULL. - */ + // Although CreateDevice is on device chain it's dispatchable object isn't + // a VkDevice or child of VkDevice so return NULL. if (!strcmp(pName, "CreateDevice")) return NULL; - /* return the dispatch table entrypoint for the fastest case */ + // Return the dispatch table entrypoint for the fastest case const VkLayerDispatchTable *disp_table = *(VkLayerDispatchTable **)device; if (disp_table == NULL) return NULL; @@ -119,7 +111,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionPropert memset(&instance_layers, 0, sizeof(instance_layers)); loader_platform_thread_once(&once_init, loader_initialize); - /* get layer libraries if needed */ + // Get layer libraries if needed if (pLayerName && strlen(pLayerName) != 0) { if (vk_string_validate(MaxLoaderStringLength, pLayerName) != VK_STRING_ERROR_NONE) { assert(VK_FALSE && @@ -154,13 +146,13 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionPropert } } } else { - /* Scan/discover all ICD libraries */ + // Scan/discover all ICD libraries memset(&icd_tramp_list, 0, sizeof(struct loader_icd_tramp_list)); res = loader_icd_scan(NULL, &icd_tramp_list); if (VK_SUCCESS != res) { goto out; } - /* get extensions from all ICD's, merge so no duplicates */ + // Get extensions from all ICD's, merge so no duplicates res = loader_get_icd_loader_instance_extensions(NULL, &icd_tramp_list, &local_ext_list); if (VK_SUCCESS != res) { goto out; @@ -214,7 +206,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( uint32_t copy_size; - /* get layer libraries */ + // Get layer libraries memset(&instance_layer_list, 0, sizeof(instance_layer_list)); loader_layer_scan(NULL, &instance_layer_list); @@ -276,10 +268,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr ptr_instance->alloc_callbacks = *pAllocator; } - /* - * Look for one or more debug report create info structures - * and setup a callback(s) for each one found. - */ + // Look for one or more debug report create info structures + // and setup a callback(s) for each one found. ptr_instance->num_tmp_callbacks = 0; ptr_instance->tmp_dbg_create_infos = NULL; ptr_instance->tmp_callbacks = NULL; @@ -300,13 +290,13 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr } } - /* 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_layer_scan(). */ + // 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_layer_scan(). memset(&ptr_instance->instance_layer_list, 0, sizeof(ptr_instance->instance_layer_list)); loader_layer_scan(ptr_instance, &ptr_instance->instance_layer_list); - /* validate the app requested layers to be enabled */ + // Validate the app requested layers to be enabled if (pCreateInfo->enabledLayerCount > 0) { res = loader_validate_layers(ptr_instance, pCreateInfo->enabledLayerCount, pCreateInfo->ppEnabledLayerNames, &ptr_instance->instance_layer_list); @@ -315,7 +305,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr } } - /* convert any meta layers to the actual layers makes a copy of layer name*/ + // Convert any meta layers to the actual layers makes a copy of layer name VkResult layerErr = loader_expand_layer_names(ptr_instance, std_validation_str, sizeof(std_validation_names) / sizeof(std_validation_names[0]), std_validation_names, &ici.enabledLayerCount, &ici.ppEnabledLayerNames); @@ -324,14 +314,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr goto out; } - /* Scan/discover all ICD libraries */ + // Scan/discover all ICD libraries memset(&ptr_instance->icd_tramp_list, 0, sizeof(ptr_instance->icd_tramp_list)); res = loader_icd_scan(ptr_instance, &ptr_instance->icd_tramp_list); if (res != VK_SUCCESS) { goto out; } - /* get extensions from all ICD's, merge so no duplicates, then validate */ + // Get extensions from all ICD's, merge so no duplicates, then validate res = loader_get_icd_loader_instance_extensions(ptr_instance, &ptr_instance->icd_tramp_list, &ptr_instance->ext_list); if (res != VK_SUCCESS) { goto out; @@ -354,7 +344,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr ptr_instance->next = loader.instances; loader.instances = ptr_instance; - /* activate any layers on instance chain */ + // Activate any layers on instance chain res = loader_enable_instance_layers(ptr_instance, &ici, &ptr_instance->instance_layer_list); if (res != VK_SUCCESS) { goto out; @@ -372,12 +362,10 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr *pInstance = created_instance; - /* - * Finally have the layers in place and everyone has seen - * the CreateInstance command go by. This allows the layer's - * GetInstanceProcAddr functions to return valid extension functions - * if enabled. - */ + // Finally have the layers in place and everyone has seen + // the CreateInstance command go by. This allows the layer's + // GetInstanceProcAddr functions to return valid extension functions + // if enabled. loader_activate_instance_layer_extensions(ptr_instance, *pInstance); } @@ -406,7 +394,7 @@ out: loader_instance_heap_free(ptr_instance, ptr_instance); } else { - /* Remove temporary debug_report callback */ + // Remove temporary debug_report callback util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks, ptr_instance->tmp_callbacks); loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici); @@ -484,8 +472,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstan } if (NULL == pPhysicalDevices || 0 == inst->total_gpu_count) { - // Call down. At the lower levels, this will setup the terminator - // structures in the loader. + // Call down. At the lower levels, this will setup the terminator structures in the loader. res = disp->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); if (VK_SUCCESS != res) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -506,15 +493,15 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstan } // Wrap the PhysDev object for loader usage, return wrapped objects - if (inst->total_gpu_count > *pPhysicalDeviceCount) { + if (inst->phys_dev_count_tramp > *pPhysicalDeviceCount) { loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "vkEnumeratePhysicalDevices: Trimming device count down" " by application request from %d to %d physical devices", - inst->total_gpu_count, *pPhysicalDeviceCount); + inst->phys_dev_count_tramp, *pPhysicalDeviceCount); count = *pPhysicalDeviceCount; res = VK_INCOMPLETE; } else { - count = inst->total_gpu_count; + count = inst->phys_dev_count_tramp; *pPhysicalDeviceCount = count; } @@ -593,7 +580,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice phy phys_dev = (struct loader_physical_device_tramp *)physicalDevice; inst = (struct loader_instance *)phys_dev->this_instance; - /* Get the physical device (ICD) extensions */ + // Get the physical device (ICD) extensions struct loader_extension_list icd_exts; icd_exts.list = NULL; res = loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts, sizeof(VkExtensionProperties)); @@ -609,7 +596,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice phy goto out; } - /* make sure requested extensions to be enabled are supported */ + // Make sure requested extensions to be enabled are supported res = loader_validate_device_extensions(phys_dev, &inst->activated_layer_list, &icd_exts, pCreateInfo); if (res != VK_SUCCESS) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkCreateDevice: Failed to validate extensions in list"); @@ -622,7 +609,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice phy goto out; } - /* copy the instance layer list into the device */ + // Copy the instance layer list into the device dev->activated_layer_list.capacity = inst->activated_layer_list.capacity; dev->activated_layer_list.count = inst->activated_layer_list.count; dev->activated_layer_list.list = @@ -701,10 +688,10 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionPropertie loader_platform_thread_lock_mutex(&loader_lock); - /* If pLayerName == NULL, then querying ICD extensions, pass this call - down the instance chain which will terminate in the ICD. This allows - layers to filter the extensions coming back up the chain. - If pLayerName != NULL then get layer extensions from manifest file. */ + // If pLayerName == NULL, then querying ICD extensions, pass this call + // down the instance chain which will terminate in the ICD. This allows + // layers to filter the extensions coming back up the chain. + // If pLayerName != NULL then get layer extensions from manifest file. if (pLayerName == NULL || strlen(pLayerName) == 0) { const VkLayerInstanceDispatchTable *disp; @@ -784,8 +771,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(Vk memset(&layers_list, 0, sizeof(layers_list)); loader_platform_thread_lock_mutex(&loader_lock); - /* Don't dispatch this call down the instance chain, want all device layers - enumerated and instance chain may not contain all device layers */ + // Don't dispatch this call down the instance chain, want all device layers + // enumerated and instance chain may not contain all device layers // TODO re-evaluate the above statement we maybe able to start calling // down the chain @@ -799,8 +786,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(Vk loader_platform_thread_unlock_mutex(&loader_lock); return VK_SUCCESS; } - /* make sure to enumerate standard_validation if that is what was used - at the instance layer enablement */ + // Make sure to enumerate standard_validation if that is what was used + // at the instance layer enablement if (inst->activated_layers_are_std_val) { enabled_layers = &layers_list; enabled_layers->count = count; diff --git a/loader/wsi.c b/loader/wsi.c index 257e1141..131ca518 100644 --- a/loader/wsi.c +++ b/loader/wsi.c @@ -155,8 +155,8 @@ VKAPI_ATTR void VKAPI_CALL terminator_DestroySurfaceKHR(VkInstance instance, VkS uint32_t i = 0; for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->DestroySurfaceKHR && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[i]) { - icd_term->DestroySurfaceKHR(icd_term->instance, icd_surface->real_icd_surfaces[i], pAllocator); + if (NULL != icd_term->dispatch.DestroySurfaceKHR && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[i]) { + icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, icd_surface->real_icd_surfaces[i], pAllocator); icd_surface->real_icd_surfaces[i] = (VkSurfaceKHR)NULL; } } else { @@ -195,24 +195,30 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(VkP struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_VK_KHR_surface extension not enabled. " - "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n"); + "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(pSupported && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported"); + if (NULL == pSupported) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "NULL pointer passed into vkGetPhysicalDeviceSurfaceSupportKHR for pSupported!\n"); + assert(false && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported"); + } *pSupported = false; - assert(icd_term->GetPhysicalDeviceSurfaceSupportKHR && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfaceSupportKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfaceSupportKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer"); + } VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { - return icd_term->GetPhysicalDeviceSurfaceSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, - icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pSupported); + return icd_term->dispatch.GetPhysicalDeviceSurfaceSupportKHR( + phys_dev_term->phys_dev, queueFamilyIndex, icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pSupported); } - return icd_term->GetPhysicalDeviceSurfaceSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, surface, pSupported); + return icd_term->dispatch.GetPhysicalDeviceSurfaceSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, surface, pSupported); } // This is the trampoline entrypoint for GetPhysicalDeviceSurfaceCapabilitiesKHR @@ -236,25 +242,29 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilitiesKH struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_surface extension not enabled. " - "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n"); + "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(pSurfaceCapabilities && - "GetPhysicalDeviceSurfaceCapabilitiesKHR: " - "Error, null pSurfaceCapabilities"); + if (NULL == pSurfaceCapabilities) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "NULL pointer passed into vkGetPhysicalDeviceSurfaceCapabilitiesKHR for pSurfaceCapabilities!\n"); + assert(false && "GetPhysicalDeviceSurfaceCapabilitiesKHR: Error, null pSurfaceCapabilities"); + } - assert(icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfaceCapabilitiesKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer"); + } VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { - return icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR( + return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR( phys_dev_term->phys_dev, icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pSurfaceCapabilities); } - return icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, surface, pSurfaceCapabilities); + return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, surface, pSurfaceCapabilities); } // This is the trampoline entrypoint for GetPhysicalDeviceSurfaceFormatsKHR @@ -280,24 +290,31 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(VkP struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_surface extension not enabled. " - "vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n"); + "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(pSurfaceFormatCount && "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount"); + if (NULL == pSurfaceFormatCount) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "NULL pointer passed into vkGetPhysicalDeviceSurfaceFormatsKHR for pSurfaceFormatCount!\n"); + assert(false && "GetPhysicalDeviceSurfaceFormatsKHR(: Error, null pSurfaceFormatCount"); + } - assert(icd_term->GetPhysicalDeviceSurfaceFormatsKHR && "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfaceCapabilitiesKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer"); + } VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { - return icd_term->GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, - icd_surface->real_icd_surfaces[phys_dev_term->icd_index], - pSurfaceFormatCount, pSurfaceFormats); + return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, + icd_surface->real_icd_surfaces[phys_dev_term->icd_index], + pSurfaceFormatCount, pSurfaceFormats); } - return icd_term->GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats); + return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, pSurfaceFormatCount, + pSurfaceFormats); } // This is the trampoline entrypoint for GetPhysicalDeviceSurfacePresentModesKHR @@ -323,25 +340,30 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModesKH struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_surface extension not enabled. " - "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n"); + "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(pPresentModeCount && - "GetPhysicalDeviceSurfacePresentModesKHR: " - "Error, null pPresentModeCount"); + if (NULL == pPresentModeCount) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "NULL pointer passed into vkGetPhysicalDeviceSurfacePresentModesKHR for pPresentModeCount!\n"); + assert(false && "GetPhysicalDeviceSurfacePresentModesKHR(: Error, null pPresentModeCount"); + } - assert(icd_term->GetPhysicalDeviceSurfacePresentModesKHR && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfacePresentModesKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfacePresentModesKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer"); + } VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { - return icd_term->GetPhysicalDeviceSurfacePresentModesKHR( + return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModesKHR( phys_dev_term->phys_dev, icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pPresentModeCount, pPresentModes); } - return icd_term->GetPhysicalDeviceSurfacePresentModesKHR(phys_dev_term->phys_dev, surface, pPresentModeCount, pPresentModes); + return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModesKHR(phys_dev_term->phys_dev, surface, pPresentModeCount, + pPresentModes); } // Functions for the VK_KHR_swapchain extension: @@ -355,13 +377,13 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice devic return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); } -VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSwapchainKHR *pSwapchain) { +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkSwapchainKHR *pSwapchain) { uint32_t icd_index = 0; struct loader_device *dev; struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); - if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) { + if (NULL != icd_term && NULL != icd_term->dispatch.CreateSwapchainKHR) { VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pCreateInfo->surface; if (NULL != icd_surface->real_icd_surfaces) { if ((VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) { @@ -374,10 +396,10 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSwapchainKHR(VkDevice device, } memcpy(pCreateCopy, pCreateInfo, sizeof(VkSwapchainCreateInfoKHR)); pCreateCopy->surface = icd_surface->real_icd_surfaces[icd_index]; - return icd_term->CreateSwapchainKHR(device, pCreateCopy, pAllocator, pSwapchain); + return icd_term->dispatch.CreateSwapchainKHR(device, pCreateCopy, pAllocator, pSwapchain); } } - return icd_term->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); + return icd_term->dispatch.CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); } return VK_SUCCESS; } @@ -390,10 +412,7 @@ LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, disp->DestroySwapchainKHR(device, swapchain, pAllocator); } -/* - * This is the trampoline entrypoint - * for GetSwapchainImagesKHR - */ +// This is the trampoline entrypoint for GetSwapchainImagesKHR LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) { const VkLayerDispatchTable *disp; @@ -401,10 +420,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice de return disp->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); } -/* - * This is the trampoline entrypoint - * for AcquireNextImageKHR - */ +// This is the trampoline entrypoint for AcquireNextImageKHR LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) { const VkLayerDispatchTable *disp; @@ -472,8 +488,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance insta struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_win32_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_win32_surface extension not enabled. " - "vkCreateWin32SurfaceKHR not executed!\n"); + "VK_KHR_win32_surface extension not enabled. vkCreateWin32SurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -492,9 +507,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance insta // Loop through each ICD and determine if they need to create a surface for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->CreateWin32SurfaceKHR) { - vkRes = icd_term->CreateWin32SurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, - &pIcdSurface->real_icd_surfaces[i]); + if (NULL != icd_term->dispatch.CreateWin32SurfaceKHR) { + vkRes = icd_term->dispatch.CreateWin32SurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); if (VK_SUCCESS != vkRes) { goto out; } @@ -510,8 +525,8 @@ out: if (NULL != pIcdSurface->real_icd_surfaces) { i = 0; for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->DestroySurfaceKHR) { - icd_term->DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); + if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { + icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); } } loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); @@ -543,17 +558,17 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWin32PresentationSupp struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_win32_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_win32_surface extension not enabled. " - "vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n"); + "VK_KHR_win32_surface extension not enabled. vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetPhysicalDeviceWin32PresentationSupportKHR && - "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD " - "pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceWin32PresentationSupportKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceWin32PresentationSupportKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD pointer"); + } - return icd_term->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex); + return icd_term->dispatch.GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex); } #endif // VK_USE_PLATFORM_WIN32_KHR @@ -585,8 +600,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(VkInstance instanc struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_mir_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_mir_surface extension not enabled. " - "vkCreateMirSurfaceKHR not executed!\n"); + "VK_KHR_mir_surface extension not enabled. vkCreateMirSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -605,9 +619,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(VkInstance instanc // Loop through each ICD and determine if they need to create a surface for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->CreateMirSurfaceKHR) { - vkRes = - icd_term->CreateMirSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, &pIcdSurface->real_icd_surfaces[i]); + if (NULL != icd_term->dispatch.CreateMirSurfaceKHR) { + vkRes = icd_term->dispatch.CreateMirSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); if (VK_SUCCESS != vkRes) { goto out; } @@ -623,8 +637,8 @@ out: if (NULL != pIcdSurface->real_icd_surfaces) { i = 0; for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->DestroySurfaceKHR) { - icd_term->DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); + if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { + icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); } } loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); @@ -658,25 +672,23 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceMirPresentationSuppor struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_mir_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_mir_surface extension not enabled. " - "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n"); + "VK_KHR_mir_surface extension not enabled. vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetPhysicalDeviceMirPresentationSupportKHR && - "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceMirPresentationSupportKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceMirPresentationSupportKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer"); + } - return icd_term->GetPhysicalDeviceMirPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, connection); + return icd_term->dispatch.GetPhysicalDeviceMirPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, connection); } #endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR -/* - * This is the trampoline entrypoint - * for CreateWaylandSurfaceKHR - */ +// This is the trampoline entrypoint for CreateWaylandSurfaceKHR LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, @@ -701,8 +713,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance ins struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_wayland_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_wayland_surface extension not enabled. " - "vkCreateWaylandSurfaceKHR not executed!\n"); + "VK_KHR_wayland_surface extension not enabled. vkCreateWaylandSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -721,9 +732,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance ins // Loop through each ICD and determine if they need to create a surface for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->CreateWaylandSurfaceKHR) { - vkRes = icd_term->CreateWaylandSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, - &pIcdSurface->real_icd_surfaces[i]); + if (NULL != icd_term->dispatch.CreateWaylandSurfaceKHR) { + vkRes = icd_term->dispatch.CreateWaylandSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); if (VK_SUCCESS != vkRes) { goto out; } @@ -739,8 +750,8 @@ out: if (NULL != pIcdSurface->real_icd_surfaces) { i = 0; for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->DestroySurfaceKHR) { - icd_term->DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); + if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { + icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); } } loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); @@ -773,18 +784,19 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWaylandPresentationSu struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_wayland_surface_enabled) { - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_wayland_surface extension not enabled. " - "vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n"); + loader_log( + ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "VK_KHR_wayland_surface extension not enabled. vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetPhysicalDeviceWaylandPresentationSupportKHR && - "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD " - "pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceWaylandPresentationSupportKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceWaylandPresentationSupportKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD pointer"); + } - return icd_term->GetPhysicalDeviceWaylandPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, display); + return icd_term->dispatch.GetPhysicalDeviceWaylandPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, display); } #endif // VK_USE_PLATFORM_WAYLAND_KHR @@ -816,8 +828,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(VkInstance instanc struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_xcb_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_xcb_surface extension not enabled. " - "vkCreateXcbSurfaceKHR not executed!\n"); + "VK_KHR_xcb_surface extension not enabled. vkCreateXcbSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -836,9 +847,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(VkInstance instanc // Loop through each ICD and determine if they need to create a surface for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->CreateXcbSurfaceKHR) { - vkRes = - icd_term->CreateXcbSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, &pIcdSurface->real_icd_surfaces[i]); + if (NULL != icd_term->dispatch.CreateXcbSurfaceKHR) { + vkRes = icd_term->dispatch.CreateXcbSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); if (VK_SUCCESS != vkRes) { goto out; } @@ -854,8 +865,8 @@ out: if (NULL != pIcdSurface->real_icd_surfaces) { i = 0; for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->DestroySurfaceKHR) { - icd_term->DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); + if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { + icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); } } loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); @@ -891,16 +902,18 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXcbPresentationSuppor struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_xcb_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_xcb_surface extension not enabled. " - "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n"); + "VK_KHR_xcb_surface extension not enabled. vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetPhysicalDeviceXcbPresentationSupportKHR && - "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceXcbPresentationSupportKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceXcbPresentationSupportKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer"); + } - return icd_term->GetPhysicalDeviceXcbPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, connection, visual_id); + return icd_term->dispatch.GetPhysicalDeviceXcbPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, connection, + visual_id); } #endif // VK_USE_PLATFORM_XCB_KHR @@ -932,8 +945,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(VkInstance instan struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_xlib_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_xlib_surface extension not enabled. " - "vkCreateXlibSurfaceKHR not executed!\n"); + "VK_KHR_xlib_surface extension not enabled. vkCreateXlibSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -952,9 +964,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(VkInstance instan // Loop through each ICD and determine if they need to create a surface for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->CreateXlibSurfaceKHR) { - vkRes = - icd_term->CreateXlibSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, &pIcdSurface->real_icd_surfaces[i]); + if (NULL != icd_term->dispatch.CreateXlibSurfaceKHR) { + vkRes = icd_term->dispatch.CreateXlibSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); if (VK_SUCCESS != vkRes) { goto out; } @@ -970,8 +982,8 @@ out: if (NULL != pIcdSurface->real_icd_surfaces) { i = 0; for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->DestroySurfaceKHR) { - icd_term->DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); + if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { + icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); } } loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); @@ -1005,16 +1017,17 @@ VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXlibPresentationSuppo struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_xlib_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_xlib_surface extension not enabled. " - "vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n"); + "VK_KHR_xlib_surface extension not enabled. vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetPhysicalDeviceXlibPresentationSupportKHR && - "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceXlibPresentationSupportKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceXlibPresentationSupportKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer"); + } - return icd_term->GetPhysicalDeviceXlibPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, dpy, visualID); + return icd_term->dispatch.GetPhysicalDeviceXlibPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, dpy, visualID); } #endif // VK_USE_PLATFORM_XLIB_KHR @@ -1041,8 +1054,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(VkInstance ins struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_display extension not enabled. " - "vkCreateAndroidSurfaceKHR not executed!\n"); + "VK_KHR_display extension not enabled. vkCreateAndroidSurfaceKHR not executed!\n"); return VK_ERROR_EXTENSION_NOT_PRESENT; } @@ -1084,15 +1096,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR( struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_display extension not enabled. " - "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n"); + "VK_KHR_display extension not enabled. vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetPhysicalDeviceDisplayPropertiesKHR && "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceDisplayPropertiesKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceDisplayPropertiesKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer"); + } - return icd_term->GetPhysicalDeviceDisplayPropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); + return icd_term->dispatch.GetPhysicalDeviceDisplayPropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); } LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlanePropertiesKHR( @@ -1113,16 +1127,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPlanePropertie struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_display extension not enabled. " - "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n"); + "VK_KHR_display extension not enabled. vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetPhysicalDeviceDisplayPlanePropertiesKHR && - "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetPhysicalDeviceDisplayPlanePropertiesKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetPhysicalDeviceDisplayPlanePropertiesKHR!\n"); + assert(false && "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer"); + } - return icd_term->GetPhysicalDeviceDisplayPlanePropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); + return icd_term->dispatch.GetPhysicalDeviceDisplayPlanePropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); } LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, @@ -1143,15 +1158,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneSupportedDisplaysKHR(Vk struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_display extension not enabled. " - "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n"); + "VK_KHR_display extension not enabled. vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetDisplayPlaneSupportedDisplaysKHR && "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetDisplayPlaneSupportedDisplaysKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetDisplayPlaneSupportedDisplaysKHR!\n"); + assert(false && "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer"); + } - return icd_term->GetDisplayPlaneSupportedDisplaysKHR(phys_dev_term->phys_dev, planeIndex, pDisplayCount, pDisplays); + return icd_term->dispatch.GetDisplayPlaneSupportedDisplaysKHR(phys_dev_term->phys_dev, planeIndex, pDisplayCount, pDisplays); } LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, @@ -1173,15 +1190,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(VkPhysical struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_display extension not enabled. " - "vkGetDisplayModePropertiesKHR not executed!\n"); + "VK_KHR_display extension not enabled. vkGetDisplayModePropertiesKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetDisplayModePropertiesKHR && "loader: null GetDisplayModePropertiesKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetDisplayModePropertiesKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetDisplayModePropertiesKHR!\n"); + assert(false && "loader: null GetDisplayModePropertiesKHR ICD pointer"); + } - return icd_term->GetDisplayModePropertiesKHR(phys_dev_term->phys_dev, display, pPropertyCount, pProperties); + return icd_term->dispatch.GetDisplayModePropertiesKHR(phys_dev_term->phys_dev, display, pPropertyCount, pProperties); } LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, @@ -1204,15 +1223,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(VkPhysicalDevice struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_display extension not enabled. " - "vkCreateDisplayModeKHR not executed!\n"); + "VK_KHR_display extension not enabled. vkCreateDisplayModeKHR not executed!\n"); return VK_ERROR_EXTENSION_NOT_PRESENT; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->CreateDisplayModeKHR && "loader: null CreateDisplayModeKHR ICD pointer"); + if (NULL == icd_term->dispatch.CreateDisplayModeKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkCreateDisplayModeKHR!\n"); + assert(false && "loader: null CreateDisplayModeKHR ICD pointer"); + } - return icd_term->CreateDisplayModeKHR(phys_dev_term->phys_dev, display, pCreateInfo, pAllocator, pMode); + return icd_term->dispatch.CreateDisplayModeKHR(phys_dev_term->phys_dev, display, pCreateInfo, pAllocator, pMode); } LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, @@ -1234,15 +1255,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(VkPhysi struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_display extension not enabled. " - "vkGetDisplayPlaneCapabilitiesKHR not executed!\n"); + "VK_KHR_display extension not enabled. vkGetDisplayPlaneCapabilitiesKHR not executed!\n"); return VK_SUCCESS; } - // Next, if so, proceed with the implementation of this function: - assert(icd_term->GetDisplayPlaneCapabilitiesKHR && "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer"); + if (NULL == icd_term->dispatch.GetDisplayPlaneCapabilitiesKHR) { + loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD for selected physical device is not exporting vkGetDisplayPlaneCapabilitiesKHR!\n"); + assert(false && "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer"); + } - return icd_term->GetDisplayPlaneCapabilitiesKHR(phys_dev_term->phys_dev, mode, planeIndex, pCapabilities); + return icd_term->dispatch.GetDisplayPlaneCapabilitiesKHR(phys_dev_term->phys_dev, mode, planeIndex, pCapabilities); } LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(VkInstance instance, @@ -1268,8 +1291,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstanc if (!inst->wsi_display_enabled) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "VK_KHR_surface extension not enabled. " - "vkCreateDisplayPlaneSurfaceKHR not executed!\n"); + "VK_KHR_surface extension not enabled. vkCreateDisplayPlaneSurfaceKHR not executed!\n"); vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; goto out; } @@ -1293,9 +1315,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstanc // Loop through each ICD and determine if they need to create a surface for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { - if (NULL != icd_term->CreateDisplayPlaneSurfaceKHR) { - vkRes = icd_term->CreateDisplayPlaneSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, - &pIcdSurface->real_icd_surfaces[i]); + if (NULL != icd_term->dispatch.CreateDisplayPlaneSurfaceKHR) { + vkRes = icd_term->dispatch.CreateDisplayPlaneSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); if (VK_SUCCESS != vkRes) { goto out; } @@ -1311,8 +1333,8 @@ out: if (NULL != pIcdSurface->real_icd_surfaces) { i = 0; for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { - if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->DestroySurfaceKHR) { - icd_term->DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); + if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { + icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); } } loader_instance_heap_free(inst, pIcdSurface->real_icd_surfaces); @@ -1334,14 +1356,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(VkDevic return disp->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains); } -VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, - const VkSwapchainCreateInfoKHR *pCreateInfos, - const VkAllocationCallbacks *pAllocator, - VkSwapchainKHR *pSwapchains) { +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, + const VkSwapchainCreateInfoKHR *pCreateInfos, + const VkAllocationCallbacks *pAllocator, + VkSwapchainKHR *pSwapchains) { uint32_t icd_index = 0; struct loader_device *dev; struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); - if (NULL != icd_term && NULL != icd_term->CreateSharedSwapchainsKHR) { + if (NULL != icd_term && NULL != icd_term->dispatch.CreateSharedSwapchainsKHR) { VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pCreateInfos->surface; if (NULL != icd_surface->real_icd_surfaces) { if ((VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) { @@ -1356,10 +1378,10 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSharedSwapchainsKHR(VkDevice d for (uint32_t sc = 0; sc < swapchainCount; sc++) { pCreateCopy[sc].surface = icd_surface->real_icd_surfaces[icd_index]; } - return icd_term->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateCopy, pAllocator, pSwapchains); + return icd_term->dispatch.CreateSharedSwapchainsKHR(device, swapchainCount, pCreateCopy, pAllocator, pSwapchains); } } - return icd_term->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains); + return icd_term->dispatch.CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains); } return VK_SUCCESS; } diff --git a/loader/wsi.h b/loader/wsi.h index 5a13bf44..519a7aac 100644 --- a/loader/wsi.h +++ b/loader/wsi.h @@ -56,8 +56,8 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo); bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop); -VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain); +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain); VKAPI_ATTR void VKAPI_CALL terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator); @@ -137,9 +137,9 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstanc const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface); -VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, - const VkSwapchainCreateInfoKHR *pCreateInfos, - const VkAllocationCallbacks *pAllocator, - VkSwapchainKHR *pSwapchains); +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, + const VkSwapchainCreateInfoKHR *pCreateInfos, + const VkAllocationCallbacks *pAllocator, + VkSwapchainKHR *pSwapchains); -#endif /* WSI_H */ +#endif // WSI_H |
