From 82ea0b0103880d011ca679b14f0fc5542c5b2012 Mon Sep 17 00:00:00 2001 From: Mark Young Date: Thu, 19 Jan 2017 21:10:49 -0700 Subject: loader: Update the loader to 1.0.39 Add new extensions for 1.0.39. Also, updated layers to include minimal set of functionality for 1.0.39 extensions. Extensions include: - VK_KHR_get_physical_device_properties2 - VK_KHR_shader_draw_parameters - VK_EXT_direct_mode_display - VK_EXT_display_surface_counter - VK_EXT_display_control Also, redo the LoaderAndLayerIf document. Change-Id: I10412086da7a798afe832a3892e18f606259b5af --- loader/loader.h | 105 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 90 insertions(+), 15 deletions(-) (limited to 'loader/loader.h') diff --git a/loader/loader.h b/loader/loader.h index 45dc223b..019125f0 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -52,6 +52,13 @@ #define VK_MINOR(version) ((version >> 12) & 0x3ff) #define VK_PATCH(version) (version & 0xfff) +// This is defined in vk_layer.h, but if there's problems we need to create the define +// here. +#ifndef MAX_NUM_UNKNOWN_EXTS +#define MAX_NUM_UNKNOWN_EXTS 250 +#endif + + enum layer_type { VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x1, VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x2, @@ -81,6 +88,11 @@ static const char std_validation_names[7][VK_MAX_EXTENSION_NAME_SIZE] = { "VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects"}; +struct VkStructureHeader { + VkStructureType sType; + const void* pNext; +}; + // form of all dynamic lists/arrays // only the list element should be changed struct loader_generic_list { @@ -115,13 +127,17 @@ struct loader_name_value { struct loader_layer_functions { char str_gipa[MAX_STRING_SIZE]; char str_gdpa[MAX_STRING_SIZE]; + char str_negotiate_interface[MAX_STRING_SIZE]; + PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_layer_interface; PFN_vkGetInstanceProcAddr get_instance_proc_addr; PFN_vkGetDeviceProcAddr get_device_proc_addr; + PFN_GetPhysicalDeviceProcAddr get_physical_device_proc_addr; }; struct loader_layer_properties { VkLayerProperties info; enum layer_type type; + uint32_t interface_version; // PFN_vkNegotiateLoaderLayerInterfaceVersion char lib_name[MAX_STRING_SIZE]; loader_platform_dl_handle lib_handle; struct loader_layer_functions functions; @@ -143,7 +159,7 @@ struct loader_dispatch_hash_list { uint32_t *index; // index into the dev_ext dispatch table }; -#define MAX_NUM_DEV_EXTS 250 + // loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.dev_ext have // one to one correspondence; one loader_dispatch_hash_entry for one dev_ext // dispatch entry. @@ -155,7 +171,7 @@ struct loader_dispatch_hash_entry { typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device); struct loader_dev_ext_dispatch_table { - PFN_vkDevExt dev_ext[MAX_NUM_DEV_EXTS]; + PFN_vkDevExt dev_ext[MAX_NUM_UNKNOWN_EXTS]; }; struct loader_dev_dispatch_table { @@ -199,19 +215,13 @@ struct loader_icd_term { PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties; PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties; - PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT; - PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT; - PFN_vkDebugReportMessageEXT DebugReportMessageEXT; - PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT; - PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT; + // WSI extensions PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR; PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR; PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR; PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR; - PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV - GetPhysicalDeviceExternalImageFormatPropertiesNV; #ifdef VK_USE_PLATFORM_WIN32_KHR PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR; PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR @@ -249,12 +259,55 @@ struct loader_icd_term { 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 *next; + + PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; }; // per ICD library structure @@ -266,15 +319,26 @@ struct loader_icd_tramp_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 + + // Physical device functions unknown to the loader + PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; +}; + // per instance structure struct loader_instance { - VkLayerInstanceDispatchTable *disp; // must be first entry in structure + struct loader_instance_dispatch_table *disp; // must be first entry in structure uint32_t total_gpu_count; uint32_t phys_dev_count_term; @@ -288,7 +352,8 @@ struct loader_instance { struct loader_icd_term *icd_terms; struct loader_icd_tramp_list icd_tramp_list; - struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS]; + struct loader_dispatch_hash_entry dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS]; + struct loader_dispatch_hash_entry phys_dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS]; struct loader_msg_callback_map_entry *icd_msg_callback_map; @@ -344,14 +409,14 @@ struct loader_instance { /* 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 { - VkLayerInstanceDispatchTable *disp; // must be first entry in structure + 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 */ struct loader_physical_device_term { - VkLayerInstanceDispatchTable *disp; // must be first entry in structure + struct loader_instance_dispatch_table *disp; // must be first entry in structure struct loader_icd_term *this_icd_term; uint8_t icd_index; VkPhysicalDevice phys_dev; // object from ICD @@ -367,6 +432,7 @@ struct loader_scanned_icd { uint32_t api_version; uint32_t interface_version; PFN_vkGetInstanceProcAddr GetInstanceProcAddr; + PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr; PFN_vkCreateInstance CreateInstance; PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; @@ -397,10 +463,15 @@ loader_get_dev_dispatch(const void *obj) { } static inline VkLayerInstanceDispatchTable * -loader_get_instance_dispatch(const void *obj) { +loader_get_instance_layer_dispatch(const void *obj) { return *((VkLayerInstanceDispatchTable **)obj); } +static inline struct loader_instance_dispatch_table * +loader_get_instance_dispatch(const void *obj) { + return *((struct loader_instance_dispatch_table **)obj); +} + static inline void loader_init_dispatch(void *obj, const void *data) { #ifdef DEBUG assert(valid_loader_magic_value(obj) && @@ -537,7 +608,10 @@ void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev); void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName); void *loader_get_dev_ext_trampoline(uint32_t index); -void loader_override_terminating_device_proc(struct loader_device *dev); +bool loader_phys_dev_ext_gpa(struct loader_instance *inst, const char *funcName, + bool perform_checking, void **tramp_addr, void **term_addr); +void *loader_get_phys_dev_ext_tramp(uint32_t index); +void *loader_get_phys_dev_ext_termin(uint32_t index); struct loader_instance *loader_get_instance(const VkInstance instance); void loader_deactivate_layers(const struct loader_instance *instance, struct loader_device *device, @@ -583,6 +657,7 @@ loader_create_device_chain(const struct loader_physical_device_tramp *pd, const VkAllocationCallbacks *pAllocator, const struct loader_instance *inst, struct loader_device *dev); + VkResult loader_validate_device_extensions( struct loader_physical_device_tramp *phys_dev, const struct loader_layer_list *activated_device_layers, -- cgit v1.2.3