diff options
author | Jon Ashburn <jon@lunarg.com> | 2016-05-16 14:01:18 -0600 |
---|---|---|
committer | Jon Ashburn <jon@lunarg.com> | 2016-05-16 14:20:35 -0600 |
commit | 7a5e4c7b7aa31bb361d14525586407d173f6dac9 (patch) | |
tree | f6165c3c73ccf799e751ad2710f14323904e00f4 /loader | |
parent | 4c863b97517963e10147a8ce91d24d127cf8b266 (diff) |
loader: deprecate device layers
Change-Id: I43c279e36368bf1ef9a2f446007e34366bfff777
Diffstat (limited to 'loader')
-rw-r--r-- | loader/loader.c | 200 | ||||
-rw-r--r-- | loader/loader.h | 27 | ||||
-rw-r--r-- | loader/trampoline.c | 144 |
3 files changed, 145 insertions, 226 deletions
diff --git a/loader/loader.c b/loader/loader.c index f5fd6da2..c8e91531 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -480,13 +480,6 @@ bool has_vk_dev_ext_property( return false; } -static inline bool loader_is_layer_type_device(const enum layer_type type) { - if ((type & VK_LAYER_TYPE_DEVICE_EXPLICIT) || - (type & VK_LAYER_TYPE_DEVICE_IMPLICIT)) - return true; - return false; -} - /* * Search the given layer list for a layer matching the given layer name */ @@ -1608,7 +1601,7 @@ static cJSON *loader_get_json(const struct loader_instance *inst, /** * Do a deep copy of the loader_layer_properties structure. */ -static void loader_copy_layer_properties(const struct loader_instance *inst, +void loader_copy_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *dst, struct loader_layer_properties *src) { uint32_t cnt, i; @@ -1667,7 +1660,7 @@ static bool loader_find_layer_name(const char *name, uint32_t layer_count, return false; } -static bool loader_find_layer_name_array( +bool loader_find_layer_name_array( const char *name, uint32_t layer_count, const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]) { if (!layer_list) @@ -1691,7 +1684,7 @@ static bool loader_find_layer_name_array( * @param ppp_layer_names */ 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 const *const **ppp_layer_names) { @@ -1699,13 +1692,16 @@ void loader_expand_layer_names( char const *const *pp_src_layers = *ppp_layer_names; if (!loader_find_layer_name(key_name, *layer_count, - (char const **)pp_src_layers)) + (char const **)pp_src_layers)) { + inst->activated_layers_are_std_val = false; return; // didn't find the key_name in the list. + } loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Found meta layer %s, replacing with actual layer group", key_name); + inst->activated_layers_are_std_val = true; char const **pp_dst_layers = loader_heap_alloc( inst, (expand_count + *layer_count - 1) * sizeof(char const *), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); @@ -1736,15 +1732,6 @@ void loader_expand_layer_names( *layer_count = dst_index; } -void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst, - const VkDeviceCreateInfo *orig, - VkDeviceCreateInfo *ours) { - /* Free the layer names array iff we had to reallocate it */ - if (orig->ppEnabledLayerNames != ours->ppEnabledLayerNames) { - loader_heap_free(inst, (void *)ours->ppEnabledLayerNames); - } -} - void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, const VkInstanceCreateInfo *orig, VkInstanceCreateInfo *ours) { @@ -1754,8 +1741,20 @@ void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, } } +void loader_init_std_validation_props(struct loader_layer_properties *props) { + memset(props, 0, sizeof(struct loader_layer_properties)); + props->type = VK_LAYER_TYPE_META_EXPLICT; + strncpy(props->info.description, "LunarG Standard Validation Layer", + sizeof (props->info.description)); + props->info.implementationVersion = 1; + strncpy(props->info.layerName, std_validation_str, + sizeof (props->info.layerName)); + // TODO what about specVersion? for now insert loader's built version + props->info.specVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION); +} + /** - * Searches through the existing instance and device layer lists looking for + * 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. @@ -1763,52 +1762,40 @@ void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, * @param layer_count number of layers in layer_names * @param layer_names array of required layer names * @param layer_instance_list - * @param layer_device_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, - struct loader_layer_list *layer_device_list) { - uint32_t i, j; + struct loader_layer_list *layer_instance_list) { + uint32_t i; bool found; struct loader_layer_list *layer_list; - if (0 == layer_count || (!layer_instance_list && !layer_device_list)) + if (0 == layer_count || (!layer_instance_list)) return; - if ((layer_instance_list && (layer_count > layer_instance_list->count)) && - (layer_device_list && (layer_count > layer_device_list->count))) + if (layer_instance_list && (layer_count > layer_instance_list->count)) return; - for (j = 0; j < 2; j++) { - if (j == 0) - layer_list = layer_instance_list; - else - layer_list = layer_device_list; - found = true; - if (layer_list == NULL) + + layer_list = layer_instance_list; + + found = true; + if (layer_list == NULL) + return; + for (i = 0; i < layer_count; i++) { + if (loader_find_layer_name_list(layer_names[i], layer_list)) continue; - for (i = 0; i < layer_count; i++) { - if (loader_find_layer_name_list(layer_names[i], layer_list)) - continue; - found = false; - break; - } + found = false; + break; + } + + struct loader_layer_properties *props; + if (found) { + props = loader_get_next_layer_property(inst, layer_list); + loader_init_std_validation_props(props); - struct loader_layer_properties *props; - if (found) { - props = loader_get_next_layer_property(inst, layer_list); - props->type = VK_LAYER_TYPE_META_EXPLICT; - strncpy(props->info.description, "LunarG Standard Validation Layer", - sizeof(props->info.description)); - props->info.implementationVersion = 1; - strncpy(props->info.layerName, std_validation_str, - sizeof(props->info.layerName)); - // TODO what about specVersion? for now insert loader's built - // version - props->info.specVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION); - } } + } /** @@ -1825,7 +1812,6 @@ static void loader_add_layer_property_meta( static void loader_add_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_instance_list, - struct loader_layer_list *layer_device_list, cJSON *json, bool is_implicit, char *filename) { /* Fields in layer manifest file that are required: * (required) “file_format_version” @@ -1915,13 +1901,11 @@ loader_add_layer_properties(const struct loader_instance *inst, // add list entry struct loader_layer_properties *props = NULL; if (!strcmp(type, "DEVICE")) { - if (layer_device_list == NULL) { + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "Device layers are deprecated skipping this layer"); layer_node = layer_node->next; continue; - } - props = loader_get_next_layer_property(inst, layer_device_list); - props->type = (is_implicit) ? VK_LAYER_TYPE_DEVICE_IMPLICIT - : VK_LAYER_TYPE_DEVICE_EXPLICIT; + } if (!strcmp(type, "INSTANCE")) { if (layer_instance_list == NULL) { @@ -1933,17 +1917,15 @@ loader_add_layer_properties(const struct loader_instance *inst, : VK_LAYER_TYPE_INSTANCE_EXPLICIT; } if (!strcmp(type, "GLOBAL")) { - if (layer_instance_list != NULL) - props = - loader_get_next_layer_property(inst, layer_instance_list); - else if (layer_device_list != NULL) - props = loader_get_next_layer_property(inst, layer_device_list); - else { + loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, + "Global layers are treated the same as instance layers"); + if (layer_instance_list == NULL) { layer_node = layer_node->next; continue; } - props->type = (is_implicit) ? VK_LAYER_TYPE_GLOBAL_IMPLICIT - : VK_LAYER_TYPE_GLOBAL_EXPLICIT; + props = loader_get_next_layer_property(inst, layer_instance_list); + props->type = (is_implicit) ? VK_LAYER_TYPE_INSTANCE_IMPLICIT + : VK_LAYER_TYPE_INSTANCE_EXPLICIT; } if (props == NULL) { @@ -2140,17 +2122,6 @@ loader_add_layer_properties(const struct loader_instance *inst, } #undef GET_JSON_ITEM #undef GET_JSON_OBJECT - // for global layers need to add them to both device and instance list - if (!strcmp(type, "GLOBAL")) { - struct loader_layer_properties *dev_props; - if (layer_instance_list == NULL || layer_device_list == NULL) { - layer_node = layer_node->next; - continue; - } - dev_props = loader_get_next_layer_property(inst, layer_device_list); - // copy into device layer list - loader_copy_layer_properties(inst, dev_props, props); - } layer_node = layer_node->next; } while (layer_node != NULL); return; @@ -2520,8 +2491,7 @@ void loader_icd_scan(const struct loader_instance *inst, } 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) { char *file_str; struct loader_manifest_files manifest_files[2]; // [0] = explicit, [1] = implicit @@ -2542,7 +2512,6 @@ void loader_layer_scan(const struct loader_instance *inst, /* cleanup any previously scanned libraries */ loader_delete_layer_properties(inst, instance_layers); - loader_delete_layer_properties(inst, device_layers); loader_platform_thread_lock_mutex(&loader_json_lock); for (implicit = 0; implicit < 2; implicit++) { @@ -2557,10 +2526,8 @@ void loader_layer_scan(const struct loader_instance *inst, continue; } - // TODO error if device layers expose instance_extensions - // TODO error if instance layers expose device extensions - loader_add_layer_properties(inst, instance_layers, device_layers, - json, (implicit == 1), file_str); + loader_add_layer_properties(inst, instance_layers, json, + (implicit == 1), file_str); loader_heap_free(inst, file_str); cJSON_Delete(json); @@ -2575,14 +2542,13 @@ void loader_layer_scan(const struct loader_instance *inst, // add a meta layer for validation if the validation layers are all present loader_add_layer_property_meta( inst, sizeof(std_validation_names) / sizeof(std_validation_names[0]), - std_validation_names, instance_layers, device_layers); + std_validation_names, instance_layers); loader_platform_thread_unlock_mutex(&loader_json_lock); } void loader_implicit_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) { char *file_str; struct loader_manifest_files manifest_files; cJSON *json; @@ -2598,7 +2564,6 @@ void loader_implicit_layer_scan(const struct loader_instance *inst, /* cleanup any previously scanned libraries */ loader_delete_layer_properties(inst, instance_layers); - loader_delete_layer_properties(inst, device_layers); loader_platform_thread_lock_mutex(&loader_json_lock); @@ -2614,7 +2579,7 @@ void loader_implicit_layer_scan(const struct loader_instance *inst, continue; } - loader_add_layer_properties(inst, instance_layers, device_layers, json, + loader_add_layer_properties(inst, instance_layers, json, true, file_str); loader_heap_free(inst, file_str); @@ -2628,7 +2593,7 @@ void loader_implicit_layer_scan(const struct loader_instance *inst, // add a meta layer for validation if the validation layers are all present loader_add_layer_property_meta( inst, sizeof(std_validation_names) / sizeof(std_validation_names[0]), - std_validation_names, instance_layers, device_layers); + std_validation_names, instance_layers); loader_platform_thread_unlock_mutex(&loader_json_lock); } @@ -2772,11 +2737,6 @@ loader_check_layers_for_address(const struct loader_instance *const inst, return true; } - if (loader_check_layer_list_for_address(&inst->device_layer_list, - funcName)) { - return true; - } - return false; } @@ -3035,7 +2995,7 @@ loader_add_layer_implicit(const struct loader_instance *inst, * 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(const struct loader_instance *inst, +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, @@ -3065,6 +3025,8 @@ static void loader_add_layer_env(const struct loader_instance *inst, 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; for (uint32_t i = 0; i < sizeof(std_validation_names) / sizeof(std_validation_names[0]); i++) { @@ -3245,45 +3207,6 @@ void loader_activate_instance_layer_extensions(struct loader_instance *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) - -{ - VkResult err; - - assert(activated_layer_list && "Cannot have null output layer list"); - - if (activated_layer_list->list == NULL || - activated_layer_list->capacity == 0) { - loader_init_layer_list(inst, activated_layer_list); - } - - if (activated_layer_list->list == NULL) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "Failed to alloc device activated layer list"); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - /* Add any implicit layers first */ - loader_add_layer_implicit(inst, VK_LAYER_TYPE_DEVICE_IMPLICIT, - activated_layer_list, device_layers); - - /* Add any layers specified via environment variable next */ - loader_add_layer_env(inst, VK_LAYER_TYPE_DEVICE_EXPLICIT, - "VK_DEVICE_LAYERS", activated_layer_list, - device_layers); - - /* Add layers specified by the application */ - err = loader_add_layer_names_to_list( - inst, activated_layer_list, pCreateInfo->enabledLayerCount, - pCreateInfo->ppEnabledLayerNames, device_layers); - - return err; -} - -VkResult loader_create_device_chain(const struct loader_physical_device_tramp *pd, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, @@ -3676,8 +3599,7 @@ terminator_DestroyInstance(VkInstance instance, icds = next_icd; } - loader_delete_layer_properties(ptr_instance, - &ptr_instance->device_layer_list); + loader_delete_layer_properties(ptr_instance, &ptr_instance->instance_layer_list); loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_libs); diff --git a/loader/loader.h b/loader/loader.h index 1b12311e..95803c01 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -49,13 +49,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 { @@ -262,13 +258,12 @@ struct loader_instance { 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; - + bool activated_layers_are_std_val; VkInstance instance; // layers/ICD instance returned to trampoline bool debug_report_enabled; @@ -424,6 +419,9 @@ VkResult loader_validate_instance_extensions( const VkInstanceCreateInfo *pCreateInfo); 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); @@ -454,11 +452,14 @@ 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 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); @@ -478,11 +479,9 @@ void loader_scanned_icd_clear(const struct loader_instance *inst, 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, - struct loader_layer_list *device_layers); + 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); diff --git a/loader/trampoline.c b/loader/trampoline.c index f9264d7b..8b1117d0 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -137,7 +137,7 @@ vkEnumerateInstanceExtensionProperties(const char *pLayerName, return VK_ERROR_EXTENSION_NOT_PRESENT; } - loader_layer_scan(NULL, &instance_layers, NULL); + loader_layer_scan(NULL, &instance_layers); if (strcmp(pLayerName, std_validation_str) == 0) { struct loader_layer_list local_list; memset(&local_list, 0, sizeof(local_list)); @@ -177,7 +177,7 @@ vkEnumerateInstanceExtensionProperties(const char *pLayerName, loader_scanned_icd_clear(NULL, &icd_libs); // Append implicit layers. - loader_implicit_layer_scan(NULL, &instance_layers, NULL); + loader_implicit_layer_scan(NULL, &instance_layers); for (uint32_t i = 0; i < instance_layers.count; i++) { struct loader_extension_list *ext_list = &instance_layers.list[i].instance_extension_list; @@ -234,7 +234,7 @@ vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, /* get layer libraries */ memset(&instance_layer_list, 0, sizeof(instance_layer_list)); - loader_layer_scan(NULL, &instance_layer_list, NULL); + loader_layer_scan(NULL, &instance_layer_list); if (pProperties == NULL) { *pPropertyCount = instance_layer_list.count; @@ -270,6 +270,7 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, loader_platform_thread_once(&once_init, loader_initialize); + //TODO start handling the pAllocators again #if 0 if (pAllocator) { ptr_instance = (struct loader_instance *) pAllocator->pfnAllocation( @@ -330,13 +331,10 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, /* 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 (both instance and device) via loader_layer_scan(). */ + * get layer list via loader_layer_scan(). */ memset(&ptr_instance->instance_layer_list, 0, sizeof(ptr_instance->instance_layer_list)); - memset(&ptr_instance->device_layer_list, 0, - sizeof(ptr_instance->device_layer_list)); - loader_layer_scan(ptr_instance, &ptr_instance->instance_layer_list, - &ptr_instance->device_layer_list); + loader_layer_scan(ptr_instance, &ptr_instance->instance_layer_list); /* validate the app requested layers to be enabled */ if (pCreateInfo->enabledLayerCount > 0) { @@ -377,8 +375,6 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, if (res != VK_SUCCESS) { loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici); loader_delete_layer_properties(ptr_instance, - &ptr_instance->device_layer_list); - loader_delete_layer_properties(ptr_instance, &ptr_instance->instance_layer_list); loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_libs); loader_destroy_generic_list( @@ -400,8 +396,7 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (ptr_instance->disp == NULL) { loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici); - loader_delete_layer_properties(ptr_instance, - &ptr_instance->device_layer_list); + loader_delete_layer_properties(ptr_instance, &ptr_instance->instance_layer_list); loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_libs); @@ -428,8 +423,6 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, if (res != VK_SUCCESS) { loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici); loader_delete_layer_properties(ptr_instance, - &ptr_instance->device_layer_list); - loader_delete_layer_properties(ptr_instance, &ptr_instance->instance_layer_list); loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_libs); loader_destroy_generic_list( @@ -658,7 +651,6 @@ vkCreateDevice(VkPhysicalDevice physicalDevice, struct loader_physical_device_tramp *phys_dev; struct loader_device *dev; struct loader_instance *inst; - struct loader_layer_list activated_layer_list = {0}; assert(pCreateInfo->queueCreateInfoCount >= 1); @@ -667,17 +659,6 @@ vkCreateDevice(VkPhysicalDevice physicalDevice, phys_dev = (struct loader_physical_device_tramp *)physicalDevice; inst = (struct loader_instance *)phys_dev->this_instance; - /* validate any app enabled layers are available */ - if (pCreateInfo->enabledLayerCount > 0) { - res = loader_validate_layers(inst, pCreateInfo->enabledLayerCount, - pCreateInfo->ppEnabledLayerNames, - &inst->device_layer_list); - if (res != VK_SUCCESS) { - loader_platform_thread_unlock_mutex(&loader_lock); - return res; - } - } - /* Get the physical device (ICD) extensions */ struct loader_extension_list icd_exts; if (!loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts, @@ -694,61 +675,36 @@ vkCreateDevice(VkPhysicalDevice physicalDevice, return res; } - /* convert any meta layers to the actual layers makes a copy of layer name*/ - VkDeviceCreateInfo dci = *pCreateInfo; - loader_expand_layer_names( - inst, std_validation_str, - sizeof(std_validation_names) / sizeof(std_validation_names[0]), - std_validation_names, &dci.enabledLayerCount, &dci.ppEnabledLayerNames); - - /* fetch a list of all layers activated, explicit and implicit */ - res = loader_enable_device_layers(inst, &activated_layer_list, &dci, - &inst->device_layer_list); - if (res != VK_SUCCESS) { - loader_delete_shadow_dev_layer_names(inst, pCreateInfo, &dci); - loader_platform_thread_unlock_mutex(&loader_lock); - return res; - } - /* make sure requested extensions to be enabled are supported */ - res = loader_validate_device_extensions(phys_dev, &activated_layer_list, - &icd_exts, &dci); + res = loader_validate_device_extensions(phys_dev, &inst->activated_layer_list, + &icd_exts, pCreateInfo); if (res != VK_SUCCESS) { - loader_delete_shadow_dev_layer_names(inst, pCreateInfo, &dci); - loader_destroy_generic_list( - inst, (struct loader_generic_list *)&activated_layer_list); loader_platform_thread_unlock_mutex(&loader_lock); return res; } dev = loader_create_logical_device(inst); if (dev == NULL) { - loader_delete_shadow_dev_layer_names(inst, pCreateInfo, &dci); - loader_destroy_generic_list( - inst, (struct loader_generic_list *)&activated_layer_list); loader_platform_thread_unlock_mutex(&loader_lock); return VK_ERROR_OUT_OF_HOST_MEMORY; } - /* move the locally filled layer list into the device, and pass ownership of - * the memory */ - dev->activated_layer_list.capacity = activated_layer_list.capacity; - dev->activated_layer_list.count = activated_layer_list.count; - dev->activated_layer_list.list = activated_layer_list.list; - memset(&activated_layer_list, 0, sizeof(activated_layer_list)); - - /* activate any layers on device chain which terminates with device*/ - res = loader_enable_device_layers(inst, &dev->activated_layer_list, &dci, - &inst->device_layer_list); - if (res != VK_SUCCESS) { - loader_delete_shadow_dev_layer_names(inst, pCreateInfo, &dci); + /* 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 = loader_heap_alloc(inst, + inst->activated_layer_list.capacity, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (dev->activated_layer_list.list == NULL) { loader_platform_thread_unlock_mutex(&loader_lock); - return res; + return VK_ERROR_OUT_OF_HOST_MEMORY; } + memcpy(dev->activated_layer_list.list, inst->activated_layer_list.list, + sizeof(*dev->activated_layer_list.list) * dev->activated_layer_list.count); - res = loader_create_device_chain(phys_dev, &dci, pAllocator, inst, dev); + + res = loader_create_device_chain(phys_dev, pCreateInfo, pAllocator, inst, dev); if (res != VK_SUCCESS) { - loader_delete_shadow_dev_layer_names(inst, pCreateInfo, &dci); loader_platform_thread_unlock_mutex(&loader_lock); return res; } @@ -765,8 +721,6 @@ vkCreateDevice(VkPhysicalDevice physicalDevice, &dev->loader_dispatch, dev->loader_dispatch.core_dispatch.GetDeviceProcAddr, *pDevice); - loader_delete_shadow_dev_layer_names(inst, pCreateInfo, &dci); - loader_platform_thread_unlock_mutex(&loader_lock); return res; } @@ -832,7 +786,7 @@ vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, i++) { loader_find_layer_name_add_list( NULL, std_validation_names[i], - VK_LAYER_TYPE_DEVICE_EXPLICIT, &inst->device_layer_list, + VK_LAYER_TYPE_INSTANCE_EXPLICIT, &inst->instance_layer_list, &local_list); } for (uint32_t i = 0; i < local_list.count; i++) { @@ -847,9 +801,9 @@ vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, dev_ext_list = &local_ext_list; } else { - for (uint32_t i = 0; i < inst->device_layer_list.count; i++) { + for (uint32_t i = 0; i < inst->instance_layer_list.count; i++) { struct loader_layer_properties *props = - &inst->device_layer_list.list[i]; + &inst->instance_layer_list.list[i]; if (strcmp(props->info.layerName, pLayerName) == 0) { dev_ext_list = &props->device_extension_list; } @@ -897,29 +851,73 @@ vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, VkLayerProperties *pProperties) { uint32_t copy_size; struct loader_physical_device_tramp *phys_dev; - + struct loader_layer_list *enabled_layers, layers_list; + uint32_t std_val_count = sizeof(std_validation_names) / + sizeof(std_validation_names[0]); + 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 */ + // TODO re-evaluate the above statement we maybe able to start calling + // down the chain phys_dev = (struct loader_physical_device_tramp *)physicalDevice; const struct loader_instance *inst = phys_dev->this_instance; - uint32_t count = inst->device_layer_list.count; + uint32_t count = inst->activated_layer_list.count; + if (inst->activated_layers_are_std_val) + count = count - std_val_count + 1; if (pProperties == NULL) { *pPropertyCount = count; 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 */ + if (inst->activated_layers_are_std_val) { + enabled_layers = &layers_list; + enabled_layers->count = count; + enabled_layers->capacity = enabled_layers->count * + sizeof(struct loader_layer_properties); + enabled_layers->list = loader_heap_alloc(inst, enabled_layers->capacity, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (!enabled_layers->list) + return VK_ERROR_OUT_OF_HOST_MEMORY; + + uint32_t j = 0; + for (uint32_t i = 0; i < inst->activated_layer_list.count; j++) { + + if (loader_find_layer_name_array( + inst->activated_layer_list.list[i].info.layerName, + std_val_count, std_validation_names)) { + struct loader_layer_properties props; + loader_init_std_validation_props(&props); + loader_copy_layer_properties(inst, + &enabled_layers->list[j], &props); + i += std_val_count; + } + else { + loader_copy_layer_properties(inst, + &enabled_layers->list[j], + &inst->activated_layer_list.list[i++]); + } + } + } + else { + enabled_layers = (struct loader_layer_list *) &inst->activated_layer_list; + } + copy_size = (*pPropertyCount < count) ? *pPropertyCount : count; for (uint32_t i = 0; i < copy_size; i++) { - memcpy(&pProperties[i], &(inst->device_layer_list.list[i].info), + memcpy(&pProperties[i], &(enabled_layers->list[i].info), sizeof(VkLayerProperties)); } *pPropertyCount = copy_size; + if (inst->activated_layers_are_std_val) + loader_delete_layer_properties(inst, enabled_layers); if (copy_size < count) { loader_platform_thread_unlock_mutex(&loader_lock); return VK_INCOMPLETE; |