Update the vulkan loader and headers.

This commit is contained in:
Dr. Chat
2016-06-17 19:32:21 -05:00
parent 27c16b1936
commit 2e34a98cef
20 changed files with 3278 additions and 2306 deletions

View File

@@ -5,24 +5,17 @@
* Copyright (c) 2014-2016 LunarG, Inc.
* Copyright (C) 2015 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and/or associated documentation files (the "Materials"), to
* deal in the Materials without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Materials, and to permit persons to whom the Materials are
* furnished to do so, subject to the following conditions:
* 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
*
* The above copyright notice(s) and this permission notice shall be included in
* all copies or substantial portions of the Materials.
* http://www.apache.org/licenses/LICENSE-2.0
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
* USE OR OTHER DEALINGS IN THE MATERIALS.
* 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: Jon Ashburn <jon@lunarg.com>
* Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
@@ -36,10 +29,10 @@
#define LOADER_H
#include <vulkan/vulkan.h>
#include <vk_loader_platform.h>
#include "vk_loader_platform.h"
#include "vk_loader_layer.h"
#include <vulkan/vk_layer.h>
#include <vulkan/vk_icd.h>
#include <assert.h>
@@ -57,13 +50,9 @@
#define VK_PATCH(version) (version & 0xfff)
enum layer_type {
VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // instance and device layer, bitwise
VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // instance and device layer, bitwise
VK_LAYER_TYPE_META_EXPLICT = 0x10,
VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x1,
VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x2,
VK_LAYER_TYPE_META_EXPLICT = 0x4,
};
typedef enum VkStringErrorFlagBits {
@@ -83,12 +72,11 @@ static const char UTF8_THREE_BYTE_MASK = 0xF8;
static const char UTF8_DATA_BYTE_CODE = 0x80;
static const char UTF8_DATA_BYTE_MASK = 0xC0;
static const char std_validation_names[9][VK_MAX_EXTENSION_NAME_SIZE] = {
"VK_LAYER_LUNARG_threading", "VK_LAYER_LUNARG_param_checker",
static const char std_validation_names[8][VK_MAX_EXTENSION_NAME_SIZE] = {
"VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation",
"VK_LAYER_LUNARG_device_limits", "VK_LAYER_LUNARG_object_tracker",
"VK_LAYER_LUNARG_image", "VK_LAYER_LUNARG_mem_tracker",
"VK_LAYER_LUNARG_draw_state", "VK_LAYER_LUNARG_swapchain",
"VK_LAYER_GOOGLE_unique_objects"};
"VK_LAYER_LUNARG_image", "VK_LAYER_LUNARG_core_validation",
"VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects"};
// form of all dynamic lists/arrays
// only the list element should be changed
@@ -121,12 +109,6 @@ struct loader_name_value {
char value[MAX_STRING_SIZE];
};
struct loader_lib_info {
char lib_name[MAX_STRING_SIZE];
uint32_t ref_count;
loader_platform_dl_handle lib_handle;
};
struct loader_layer_functions {
char str_gipa[MAX_STRING_SIZE];
char str_gdpa[MAX_STRING_SIZE];
@@ -138,6 +120,7 @@ struct loader_layer_properties {
VkLayerProperties info;
enum layer_type type;
char lib_name[MAX_STRING_SIZE];
loader_platform_dl_handle lib_handle;
struct loader_layer_functions functions;
struct loader_extension_list instance_extension_list;
struct loader_device_extension_list device_extension_list;
@@ -151,12 +134,6 @@ struct loader_layer_list {
struct loader_layer_properties *list;
};
struct loader_layer_library_list {
size_t capacity;
uint32_t count;
struct loader_lib_info *list;
};
struct loader_dispatch_hash_list {
size_t capacity;
uint32_t count;
@@ -201,7 +178,6 @@ struct loader_icd {
// pointers to find other structs
const struct loader_scanned_icds *this_icd_lib;
const struct loader_instance *this_instance;
struct loader_device *logical_device_list;
VkInstance instance; // instance object from the icd
PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
@@ -248,7 +224,17 @@ struct loader_icd {
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;
struct loader_icd *next;
};
@@ -263,25 +249,29 @@ struct loader_icd_libs {
struct loader_instance {
VkLayerInstanceDispatchTable *disp; // must be first entry in structure
uint32_t total_gpu_count;
struct loader_physical_device *phys_devs;
uint32_t total_gpu_count; // count of the next two arrays
struct loader_physical_device *phys_devs_term;
struct loader_physical_device_tramp *
phys_devs; // tramp wrapped physDev obj list
uint32_t total_icd_count;
struct loader_icd *icds;
struct loader_instance *next;
struct loader_extension_list ext_list; // icds and loaders extensions
struct loader_icd_libs icd_libs;
struct loader_layer_list instance_layer_list;
struct loader_layer_list device_layer_list;
struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS];
struct loader_msg_callback_map_entry *icd_msg_callback_map;
struct loader_layer_list activated_layer_list;
VkInstance instance;
bool activated_layers_are_std_val;
VkInstance instance; // layers/ICD instance returned to trampoline
bool debug_report_enabled;
VkLayerDbgFunctionNode *DbgFunctionHead;
uint32_t num_tmp_callbacks;
VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos;
VkDebugReportCallbackEXT *tmp_callbacks;
VkAllocationCallbacks alloc_callbacks;
@@ -304,36 +294,45 @@ struct loader_instance {
#ifdef VK_USE_PLATFORM_ANDROID_KHR
bool wsi_android_surface_enabled;
#endif
bool wsi_display_enabled;
};
/* per enumerated PhysicalDevice structure */
struct loader_physical_device {
/* VkPhysicalDevice requires special treatment by loader. Firstly, terminator
* code must be able to get the struct loader_icd 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 {
VkLayerInstanceDispatchTable *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 {
VkLayerInstanceDispatchTable *disp; // must be first entry in structure
struct loader_icd *this_icd;
VkPhysicalDevice phys_dev; // object from ICD
/*
* Fill in the cache of available device extensions from
* this physical device. This cache can be used during CreateDevice
*/
struct loader_extension_list device_extension_cache;
};
struct loader_struct {
struct loader_instance *instances;
unsigned int loaded_layer_lib_count;
size_t loaded_layer_lib_capacity;
struct loader_lib_info *loaded_layer_lib_list;
// TODO add ref counting of ICD libraries
// TODO use this struct loader_layer_library_list scanned_layer_libraries;
// TODO add list of icd libraries for ref counting them for closure
};
struct loader_scanned_icds {
char *lib_name;
loader_platform_dl_handle handle;
uint32_t api_version;
uint32_t interface_version;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
PFN_vkCreateInstance CreateInstance;
PFN_vkEnumerateInstanceExtensionProperties
@@ -344,6 +343,13 @@ static inline struct loader_instance *loader_instance(VkInstance instance) {
return (struct loader_instance *)instance;
}
static inline VkPhysicalDevice
loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) {
struct loader_physical_device_tramp *phys_dev =
(struct loader_physical_device_tramp *)physicalDevice;
return phys_dev->phys_dev;
}
static inline void loader_set_dispatch(void *obj, const void *data) {
*((const void **)obj) = data;
}
@@ -386,8 +392,18 @@ struct loader_msg_callback_map_entry {
VkDebugReportCallbackEXT loader_obj;
};
/* helper function definitions */
void *loader_heap_alloc(const struct loader_instance *instance, size_t size,
VkSystemAllocationScope allocationScope);
void loader_heap_free(const struct loader_instance *instance, void *pMemory);
void *loader_tls_heap_alloc(size_t size);
void loader_tls_heap_free(void *pMemory);
void loader_log(const struct loader_instance *inst, VkFlags msg_type,
int32_t msg_code, const char *format, ...);
int32_t msg_code, const char *format, ...);
bool compare_vk_extension_properties(const VkExtensionProperties *op1,
const VkExtensionProperties *op2);
@@ -403,76 +419,10 @@ VkResult loader_validate_instance_extensions(
const struct loader_layer_list *instance_layer,
const VkInstanceCreateInfo *pCreateInfo);
/* instance layer chain termination entrypoint definitions */
VKAPI_ATTR VkResult VKAPI_CALL
loader_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkInstance *pInstance);
VKAPI_ATTR void VKAPI_CALL
loader_DestroyInstance(VkInstance instance,
const VkAllocationCallbacks *pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL
loader_EnumeratePhysicalDevices(VkInstance instance,
uint32_t *pPhysicalDeviceCount,
VkPhysicalDevice *pPhysicalDevices);
VKAPI_ATTR void VKAPI_CALL
loader_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceFeatures *pFeatures);
VKAPI_ATTR void VKAPI_CALL
loader_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice,
VkFormat format,
VkFormatProperties *pFormatInfo);
VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceImageFormatProperties(
VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
VkImageFormatProperties *pImageFormatProperties);
VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceSparseImageFormatProperties(
VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
VkSampleCountFlagBits samples, VkImageUsageFlags usage,
VkImageTiling tiling, uint32_t *pNumProperties,
VkSparseImageFormatProperties *pProperties);
VKAPI_ATTR void VKAPI_CALL
loader_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties *pProperties);
VKAPI_ATTR VkResult VKAPI_CALL
loader_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
const char *pLayerName,
uint32_t *pCount,
VkExtensionProperties *pProperties);
VKAPI_ATTR VkResult VKAPI_CALL
loader_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice,
uint32_t *pCount,
VkLayerProperties *pProperties);
VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceQueueFamilyProperties(
VkPhysicalDevice physicalDevice, uint32_t *pCount,
VkQueueFamilyProperties *pProperties);
VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceMemoryProperties(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceMemoryProperties *pProperties);
VKAPI_ATTR VkResult VKAPI_CALL
loader_create_device_terminator(VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDevice *pDevice);
VKAPI_ATTR VkResult VKAPI_CALL
loader_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
/* helper function definitions */
void loader_initialize(void);
void loader_copy_layer_properties(const struct loader_instance *inst,
struct loader_layer_properties *dst,
struct loader_layer_properties *src);
bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop,
const uint32_t count,
const VkExtensionProperties *ext_array);
@@ -483,42 +433,73 @@ 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);
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);
VkResult loader_add_device_extensions(const struct loader_instance *inst,
PFN_vkEnumerateDeviceExtensionProperties
fpEnumerateDeviceExtensionProperties,
VkPhysicalDevice physical_device,
const char *lib_name,
struct loader_extension_list *ext_list);
bool loader_init_generic_list(const struct loader_instance *inst,
struct loader_generic_list *list_info,
size_t element_size);
void loader_destroy_generic_list(const struct loader_instance *inst,
struct loader_generic_list *list);
void loader_destroy_layer_list(const struct loader_instance *inst,
struct loader_layer_list *layer_list);
void loader_delete_layer_properties(const struct loader_instance *inst,
struct loader_layer_list *layer_list);
bool loader_find_layer_name_array(const char *name, uint32_t layer_count,
const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]);
void loader_expand_layer_names(
const struct loader_instance *inst, const char *key_name,
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 ***ppp_layer_names);
void loader_unexpand_dev_layer_names(const struct loader_instance *inst,
uint32_t layer_count, char **layer_names,
char **layer_ptr,
const VkDeviceCreateInfo *pCreateInfo);
void loader_unexpand_inst_layer_names(const struct loader_instance *inst,
uint32_t layer_count, char **layer_names,
char **layer_ptr,
const VkInstanceCreateInfo *pCreateInfo);
uint32_t *layer_count, char const *const **ppp_layer_names);
void loader_init_std_validation_props(struct loader_layer_properties *props);
void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst,
const VkDeviceCreateInfo *orig,
VkDeviceCreateInfo *ours);
void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst,
const VkInstanceCreateInfo *orig,
VkInstanceCreateInfo *ours);
void 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);
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);
void loader_scanned_icd_clear(const struct loader_instance *inst,
struct loader_icd_libs *icd_libs);
void loader_icd_scan(const struct loader_instance *inst,
struct loader_icd_libs *icds);
void loader_layer_scan(const struct loader_instance *inst,
struct loader_layer_list *instance_layers,
struct loader_layer_list *device_layers);
struct loader_layer_list *instance_layers);
void loader_implicit_layer_scan(const struct loader_instance *inst,
struct loader_layer_list *instance_layers);
void loader_get_icd_loader_instance_extensions(
const struct loader_instance *inst, struct loader_icd_libs *icd_libs,
struct loader_extension_list *inst_exts);
struct loader_icd *loader_get_icd_and_device(const VkDevice device,
struct loader_device **found_dev);
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);
struct loader_instance *loader_get_instance(const VkInstance instance);
void loader_deactivate_layers(const struct loader_instance *instance,
struct loader_layer_list *list);
struct loader_device *
loader_create_logical_device(const struct loader_instance *inst);
void loader_add_logical_device(const struct loader_instance *inst,
struct loader_icd *icd,
struct loader_device *found_dev);
void loader_remove_logical_device(const struct loader_instance *inst,
struct loader_icd *icd,
struct loader_device *found_dev);
@@ -535,15 +516,87 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo,
void loader_activate_instance_layer_extensions(struct loader_instance *inst,
VkInstance created_inst);
VkResult
loader_enable_device_layers(const struct loader_instance *inst,
struct loader_layer_list *activated_layer_list,
const VkDeviceCreateInfo *pCreateInfo,
const struct loader_layer_list *device_layers);
void *loader_heap_alloc(const struct loader_instance *instance, size_t size,
VkSystemAllocationScope allocationScope);
VkResult
loader_create_device_chain(const struct loader_physical_device_tramp *pd,
const VkDeviceCreateInfo *pCreateInfo,
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,
const struct loader_extension_list *icd_exts,
const VkDeviceCreateInfo *pCreateInfo);
void loader_heap_free(const struct loader_instance *instance, void *pMemory);
/* instance layer chain termination entrypoint definitions */
VKAPI_ATTR VkResult VKAPI_CALL
terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkInstance *pInstance);
void *loader_tls_heap_alloc(size_t size);
VKAPI_ATTR void VKAPI_CALL
terminator_DestroyInstance(VkInstance instance,
const VkAllocationCallbacks *pAllocator);
void loader_tls_heap_free(void *pMemory);
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);