-/*
+/*
*
* Copyright (c) 2014-2016 The Khronos Group Inc.
* Copyright (c) 2014-2016 Valve Corporation
LOADER_PLATFORM_THREAD_ONCE_DECLARATION(once_init);
-void *loader_instance_heap_alloc(const struct loader_instance *instance,
- size_t size,
- VkSystemAllocationScope alloc_scope) {
- void *pMemory = NULL;
-#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
- {
-#else
+void *loader_heap_alloc(const struct loader_instance *instance, size_t size,
+ VkSystemAllocationScope alloc_scope) {
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.
- */
- pMemory = instance->alloc_callbacks.pfnAllocation(
- instance->alloc_callbacks.pUserData, size, sizeof(uint64_t),
+ /* TODO: What should default alignment be? 1, 4, 8, other? */
+ return instance->alloc_callbacks.pfnAllocation(
+ instance->alloc_callbacks.pUserData, size, sizeof(int),
alloc_scope);
- } else {
-#endif
- pMemory = malloc(size);
- }
- return pMemory;
-}
-
-void loader_instance_heap_free(const struct loader_instance *instance,
- void *pMemory) {
- if (pMemory != NULL) {
-#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
- {
-#else
- if (instance && instance->alloc_callbacks.pfnFree) {
- instance->alloc_callbacks.pfnFree(
- instance->alloc_callbacks.pUserData, pMemory);
- } else {
-#endif
- free(pMemory);
- }
}
+ return malloc(size);
}
-void *loader_instance_heap_realloc(const struct loader_instance *instance,
- void *pMemory, size_t orig_size, size_t size,
- VkSystemAllocationScope alloc_scope) {
- void *pNewMem = NULL;
- if (pMemory == NULL || orig_size == 0) {
- pNewMem = loader_instance_heap_alloc(instance, size, alloc_scope);
- } else if (size == 0) {
- loader_instance_heap_free(instance, pMemory);
-#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.
- */
- pNewMem = instance->alloc_callbacks.pfnReallocation(
- instance->alloc_callbacks.pUserData, pMemory, size,
- sizeof(uint64_t), alloc_scope);
-#endif
- } else {
- pNewMem = realloc(pMemory, size);
+void loader_heap_free(const struct loader_instance *instance, void *pMemory) {
+ if (pMemory == NULL)
+ return;
+ if (instance && instance->alloc_callbacks.pfnFree) {
+ instance->alloc_callbacks.pfnFree(instance->alloc_callbacks.pUserData,
+ pMemory);
+ return;
}
- return pNewMem;
-}
-
-void *loader_instance_tls_heap_alloc(size_t size) {
- return loader_instance_heap_alloc(tls_instance, size,
- VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
-}
-
-void loader_instance_tls_heap_free(void *pMemory) {
- loader_instance_heap_free(tls_instance, pMemory);
+ free(pMemory);
}
-void *loader_device_heap_alloc(const struct loader_device *device, size_t size,
- VkSystemAllocationScope alloc_scope) {
- void *pMemory = NULL;
-#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
- {
-#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.
- */
- pMemory = device->alloc_callbacks.pfnAllocation(
- device->alloc_callbacks.pUserData, size, sizeof(uint64_t),
- alloc_scope);
- } else {
-#endif
- pMemory = malloc(size);
+void *loader_heap_realloc(const struct loader_instance *instance, void *pMemory,
+ size_t orig_size, size_t size,
+ VkSystemAllocationScope alloc_scope) {
+ if (pMemory == NULL || orig_size == 0)
+ return loader_heap_alloc(instance, size, alloc_scope);
+ if (size == 0) {
+ loader_heap_free(instance, pMemory);
+ return NULL;
}
- return pMemory;
-}
-
-void loader_device_heap_free(const struct loader_device *device,
- void *pMemory) {
- if (pMemory != NULL) {
-#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
- {
-#else
- if (device && device->alloc_callbacks.pfnFree) {
- device->alloc_callbacks.pfnFree(device->alloc_callbacks.pUserData,
- pMemory);
- } else {
-#endif
- free(pMemory);
+ // TODO use the callback realloc function
+ if (instance && instance->alloc_callbacks.pfnAllocation) {
+ if (size <= orig_size) {
+ memset(((uint8_t *)pMemory) + size, 0, orig_size - size);
+ return pMemory;
}
- }
-}
-
-void *loader_device_heap_realloc(const struct loader_device *device,
- void *pMemory, size_t orig_size, size_t size,
- VkSystemAllocationScope alloc_scope) {
- void *pNewMem = NULL;
- if (pMemory == NULL || orig_size == 0) {
- pNewMem = loader_device_heap_alloc(device, size, alloc_scope);
- } else if (size == 0) {
- loader_device_heap_free(device, pMemory);
-#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.
- */
- pNewMem = device->alloc_callbacks.pfnReallocation(
- device->alloc_callbacks.pUserData, pMemory, size, sizeof(uint64_t),
+ /* TODO: What should default alignment be? 1, 4, 8, other? */
+ void *new_ptr = instance->alloc_callbacks.pfnAllocation(
+ instance->alloc_callbacks.pUserData, size, sizeof(int),
alloc_scope);
-#endif
- } else {
- pNewMem = realloc(pMemory, size);
- }
- return pNewMem;
-}
-
-// Environment variables
-#if defined(__linux__)
-
-static inline char *loader_getenv(const char *name,
- const struct loader_instance *inst) {
- // No allocation of memory necessary for Linux, but we should at least touch
- // the inst pointer to get rid of compiler warnings.
- (void)inst;
- return getenv(name);
-}
-static inline void loader_free_getenv(const char *val,
- const struct loader_instance *inst) {
- // No freeing of memory necessary for Linux, but we should at least touch
- // the val and inst pointers to get rid of compiler warnings.
- (void)val;
- (void)inst;
-}
-
-#elif defined(WIN32)
-
-static inline char *loader_getenv(const char *name,
- const struct loader_instance *inst) {
- char *retVal;
- DWORD valSize;
-
- valSize = GetEnvironmentVariableA(name, NULL, 0);
-
- // valSize DOES include the null terminator, so for any set variable
- // will always be at least 1. If it's 0, the variable wasn't set.
- if (valSize == 0)
- return NULL;
-
- // Allocate the space necessary for the registry entry
- if (NULL != inst && NULL != inst->alloc_callbacks.pfnAllocation) {
- retVal = (char *)inst->alloc_callbacks.pfnAllocation(
- inst->alloc_callbacks.pUserData, valSize, sizeof(char *),
- VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
- } else {
- retVal = (char *)malloc(valSize);
- }
-
- if (NULL != retVal) {
- GetEnvironmentVariableA(name, retVal, valSize);
+ if (!new_ptr)
+ return NULL;
+ memcpy(new_ptr, pMemory, orig_size);
+ instance->alloc_callbacks.pfnFree(instance->alloc_callbacks.pUserData,
+ pMemory);
+ return new_ptr;
}
-
- return retVal;
+ return realloc(pMemory, size);
}
-static inline void loader_free_getenv(char *val,
- const struct loader_instance *inst) {
- if (NULL != inst && NULL != inst->alloc_callbacks.pfnFree) {
- inst->alloc_callbacks.pfnFree(inst->alloc_callbacks.pUserData, val);
- } else {
- free((void *)val);
- }
+void *loader_tls_heap_alloc(size_t size) {
+ return loader_heap_alloc(tls_instance, size,
+ VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
}
-#else
-
-static inline char *loader_getenv(const char *name,
- const struct loader_instance *inst) {
- // stub func
- (void)inst;
- (void)name;
- return NULL;
+void loader_tls_heap_free(void *pMemory) {
+ loader_heap_free(tls_instance, pMemory);
}
-static inline void loader_free_getenv(const char *val,
- const struct loader_instance *inst) {
- // stub func
- (void)val;
- (void)inst;
-}
-
-#endif
void loader_log(const struct loader_instance *inst, VkFlags msg_type,
int32_t msg_code, const char *format, ...) {
ERROR_SUCCESS) {
if (value_size == sizeof(value) && value == 0) {
if (out == NULL) {
- out = loader_instance_heap_alloc(
+ out = loader_heap_alloc(
inst, total_size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == out) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "Out of memory can't alloc space for registry data");
- return NULL;
- }
out[0] = '\0';
} else if (strlen(out) + name_size + 1 > total_size) {
- out = loader_instance_heap_realloc(
+ out = loader_heap_realloc(
inst, out, total_size, total_size * 2,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == out) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "Out of memory can't realloc space for registry data");
- return NULL;
- }
total_size *= 2;
}
+ if (out == NULL) {
+ loader_log(
+ inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
+ "Out of memory, failed loader_get_registry_files");
+ return NULL;
+ }
if (strlen(out) == 0)
snprintf(out, name_size + 1, "%s", name);
else
struct loader_layer_list *layer_list) {
if (layer_list->capacity == 0) {
layer_list->list =
- loader_instance_heap_alloc(
- inst, sizeof(struct loader_layer_properties) * 64,
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ loader_heap_alloc(inst, sizeof(struct loader_layer_properties) * 64,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (layer_list->list == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Out of memory can't add any layer properties to list");
// 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(
+ layer_list->list = loader_heap_realloc(
inst, layer_list->list, layer_list->capacity,
layer_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (layer_list->list == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"realloc failed for layer list");
- return NULL;
}
layer_list->capacity *= 2;
}
.instance_extension_list);
dev_ext_list = &layer_list->list[i].device_extension_list;
if (dev_ext_list->capacity > 0 &&
- NULL != dev_ext_list->list &&
dev_ext_list->list->entrypoint_count > 0) {
for (j = 0; j < dev_ext_list->list->entrypoint_count; j++) {
- loader_instance_heap_free(inst, dev_ext_list->list->entrypoints[j]);
+ loader_heap_free(inst, dev_ext_list->list->entrypoints[j]);
}
- loader_instance_heap_free(inst, dev_ext_list->list->entrypoints);
+ loader_heap_free(inst, dev_ext_list->list->entrypoints);
}
loader_destroy_generic_list(inst,
(struct loader_generic_list *)dev_ext_list);
if (layer_list->capacity > 0) {
layer_list->capacity = 0;
- loader_instance_heap_free(inst, layer_list->list);
+ loader_heap_free(inst, layer_list->list);
}
}
struct loader_generic_list *list_info,
size_t element_size) {
list_info->capacity = 32 * element_size;
- list_info->list = loader_instance_heap_alloc(
- inst, list_info->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ list_info->list = loader_heap_alloc(inst, list_info->capacity,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (list_info->list == NULL) {
return false;
}
void loader_destroy_generic_list(const struct loader_instance *inst,
struct loader_generic_list *list) {
- loader_instance_heap_free(inst, list->list);
+ loader_heap_free(inst, list->list);
list->count = 0;
list->capacity = 0;
}
if (ext_list->count * sizeof(VkExtensionProperties) >=
ext_list->capacity) {
- ext_list->list = loader_instance_heap_realloc(
+ ext_list->list = loader_heap_realloc(
inst, ext_list->list, ext_list->capacity,
ext_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
// check for enough capacity
if (idx * sizeof(struct loader_dev_ext_props) >= ext_list->capacity) {
- ext_list->list = loader_instance_heap_realloc(
+ ext_list->list = loader_heap_realloc(
inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
sizeof(struct loader_dev_ext_props));
ext_list->list[idx].entrypoint_count = entry_count;
ext_list->list[idx].entrypoints =
- loader_instance_heap_alloc(inst, sizeof(char *) * entry_count,
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (ext_list->list[idx].entrypoints == NULL) {
- ext_list->list[idx].entrypoint_count = 0;
+ loader_heap_alloc(inst, sizeof(char *) * entry_count,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ if (ext_list->list[idx].entrypoints == NULL)
return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
for (uint32_t i = 0; i < entry_count; i++) {
- ext_list->list[idx].entrypoints[i] = loader_instance_heap_alloc(
+ ext_list->list[idx].entrypoints[i] = loader_heap_alloc(
inst, strlen(entrys[i]) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (ext_list->list[idx].entrypoints[i] == NULL) {
- for (uint32_t j = 0; j < i; j++) {
- loader_instance_heap_free(inst,
- ext_list->list[idx].entrypoints[j]);
- }
- loader_instance_heap_free(inst, ext_list->list[idx].entrypoints);
- ext_list->list[idx].entrypoint_count = 0;
- ext_list->list[idx].entrypoints = NULL;
+ if (ext_list->list[idx].entrypoints[i] == NULL)
return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
strcpy(ext_list->list[idx].entrypoints[i], entrys[i]);
}
ext_list->count++;
continue;
}
- err = loader_add_to_layer_list(inst, output_list, 1, layer_prop);
+ loader_add_to_layer_list(inst, output_list, 1, layer_prop);
}
return err;
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);
+ list->list = loader_heap_alloc(inst, list->capacity,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (list->list == NULL) {
return false;
}
}
void loader_destroy_layer_list(const struct loader_instance *inst,
- struct loader_device *device,
struct loader_layer_list *layer_list) {
- if (device) {
- loader_device_heap_free(device, layer_list->list);
- } else {
- loader_instance_heap_free(inst, layer_list->list);
- }
+ loader_heap_free(inst, layer_list->list);
layer_list->count = 0;
layer_list->capacity = 0;
}
* 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) {
+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) {
uint32_t i;
struct loader_layer_properties *layer;
}
if (list->list == NULL)
- return VK_SUCCESS;
+ return;
for (i = 0; i < prop_list_count; i++) {
layer = (struct loader_layer_properties *)&props[i];
if (list->count * sizeof(struct loader_layer_properties) >=
list->capacity) {
- list->list = loader_instance_heap_realloc(
+ list->list = loader_heap_realloc(
inst, list->list, list->capacity, list->capacity * 2,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == list->list) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "realloc failed for layer list when attempting to "
- "add new layer");
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
// double capacity
list->capacity *= 2;
}
sizeof(struct loader_layer_properties));
list->count++;
}
-
- return VK_SUCCESS;
}
/**
if (0 == strcmp(layer_prop->info.layerName, name) &&
(layer_prop->type & type)) {
/* 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;
- }
+ loader_add_to_layer_list(inst, found_list, 1, layer_prop);
+ found = true;
}
}
if (!found) {
return NULL;
}
-void loader_destroy_logical_device(const struct loader_instance *inst,
- struct loader_device *dev,
- const VkAllocationCallbacks *pAllocator) {
- if (pAllocator) {
- dev->alloc_callbacks = *pAllocator;
- }
- if (NULL != dev->app_extension_props) {
- loader_device_heap_free(dev, dev->app_extension_props);
- }
- if (NULL != dev->activated_layer_list.list) {
- loader_deactivate_layers(inst, dev, &dev->activated_layer_list);
- }
- loader_device_heap_free(dev, dev);
+static void loader_destroy_logical_device(const struct loader_instance *inst,
+ struct loader_device *dev) {
+ loader_heap_free(inst, dev->app_extension_props);
+ loader_deactivate_layers(inst, &dev->activated_layer_list);
+ loader_heap_free(inst, dev);
}
struct loader_device *
-loader_create_logical_device(const struct loader_instance *inst,
- const VkAllocationCallbacks *pAllocator) {
+loader_create_logical_device(const struct loader_instance *inst) {
struct loader_device *new_dev;
-#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
- {
-#else
- if (pAllocator) {
- new_dev = (struct loader_device *)pAllocator->pfnAllocation(
- pAllocator->pUserData, sizeof(struct loader_device), sizeof(int *),
- VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
- } else {
-#endif
- new_dev = (struct loader_device *)malloc(sizeof(struct loader_device));
- }
+ new_dev = loader_heap_alloc(inst, sizeof(struct loader_device),
+ VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (!new_dev) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Failed to alloc struct loader-device");
}
memset(new_dev, 0, sizeof(struct loader_device));
- if (pAllocator) {
- new_dev->alloc_callbacks = *pAllocator;
- }
return new_dev;
}
void loader_remove_logical_device(const struct loader_instance *inst,
struct loader_icd *icd,
- struct loader_device *found_dev,
- const VkAllocationCallbacks *pAllocator) {
+ struct loader_device *found_dev) {
struct loader_device *dev, *prev_dev;
if (!icd || !found_dev)
prev_dev->next = found_dev->next;
else
icd->logical_device_list = found_dev->next;
- loader_destroy_logical_device(inst, found_dev, pAllocator);
+ loader_destroy_logical_device(inst, found_dev);
}
static void loader_icd_destroy(struct loader_instance *ptr_inst,
- struct loader_icd *icd,
- const VkAllocationCallbacks *pAllocator) {
+ struct loader_icd *icd) {
ptr_inst->total_icd_count--;
for (struct loader_device *dev = icd->logical_device_list; dev;) {
struct loader_device *next_dev = dev->next;
- loader_destroy_logical_device(ptr_inst, dev, pAllocator);
+ loader_destroy_logical_device(ptr_inst, dev);
dev = next_dev;
}
- loader_instance_heap_free(ptr_inst, icd);
+ loader_heap_free(ptr_inst, icd);
}
static struct loader_icd *
loader_icd_create(const struct loader_instance *inst) {
struct loader_icd *icd;
- icd = loader_instance_heap_alloc(inst, sizeof(*icd),
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ icd = loader_heap_alloc(inst, sizeof(*icd),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (!icd)
return NULL;
return;
for (uint32_t i = 0; i < icd_libs->count; i++) {
loader_platform_close_library(icd_libs->list[i].handle);
- loader_instance_heap_free(inst, icd_libs->list[i].lib_name);
+ loader_heap_free(inst, icd_libs->list[i].lib_name);
}
- loader_instance_heap_free(inst, icd_libs->list);
+ loader_heap_free(inst, icd_libs->list);
icd_libs->capacity = 0;
icd_libs->count = 0;
icd_libs->list = NULL;
}
-static VkResult loader_scanned_icd_init(const struct loader_instance *inst,
- struct loader_icd_libs *icd_libs) {
- VkResult err = VK_SUCCESS;
+static void loader_scanned_icd_init(const struct loader_instance *inst,
+ struct loader_icd_libs *icd_libs) {
loader_scanned_icd_clear(inst, icd_libs);
icd_libs->capacity = 8 * sizeof(struct loader_scanned_icds);
- icd_libs->list = loader_instance_heap_alloc(
- inst, icd_libs->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == icd_libs->list) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "realloc failed for layer list when attempting to add new layer");
- err = VK_ERROR_OUT_OF_HOST_MEMORY;
- }
- return err;
+ icd_libs->list = loader_heap_alloc(inst, icd_libs->capacity,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
}
static void loader_scanned_icd_add(const struct loader_instance *inst,
}
// Get and settle on an ICD interface version
- fp_negotiate_icd_version = loader_platform_get_proc_address(
- handle, "vk_icdNegotiateLoaderICDInterfaceVersion");
+ fp_negotiate_icd_version =
+ loader_platform_get_proc_address(handle, "vk_icdNegotiateLoaderICDInterfaceVersion");
if (!loader_get_icd_interface_version(fp_negotiate_icd_version,
- &interface_vers)) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "ICD (%s) doesn't support interface version compatible"
- "with loader, skip this ICD %s",
- filename);
- return;
+ &interface_vers)) {
+ loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
+ "ICD (%s) doesn't support interface version compatible"
+ "with loader, skip this ICD %s", filename);
+ return;
}
fp_get_proc_addr =
loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
"Using deprecated ICD interface of "
"vkGetInstanceProcAddr instead of "
- "vk_icdGetInstanceProcAddr for ICD %s",
- filename);
+ "vk_icdGetInstanceProcAddr for ICD %s", filename);
}
fp_create_inst =
loader_platform_get_proc_address(handle, "vkCreateInstance");
if (!fp_create_inst) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "Couldn't get vkCreateInstance via dlsym/loadlibrary "
- "for ICD %s",
- filename);
+ loader_log(
+ inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
+ "Couldn't get vkCreateInstance via dlsym/loadlibrary for ICD %s",
+ filename);
return;
}
fp_get_inst_ext_props = loader_platform_get_proc_address(
if (!fp_get_inst_ext_props) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Couldn't get vkEnumerateInstanceExtensionProperties "
- "via dlsym/loadlibrary for ICD %s",
- filename);
+ "via dlsym/loadlibrary for ICD %s", filename);
return;
}
} else {
if (!fp_create_inst) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Couldn't get vkCreateInstance via "
- "vk_icdGetInstanceProcAddr for ICD %s",
- filename);
+ "vk_icdGetInstanceProcAddr for ICD %s", filename);
return;
}
fp_get_inst_ext_props =
if (!fp_get_inst_ext_props) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Couldn't get vkEnumerateInstanceExtensionProperties "
- "via vk_icdGetInstanceProcAddr for ICD %s",
- filename);
+ "via vk_icdGetInstanceProcAddr for ICD %s", filename);
return;
}
}
if ((icd_libs->count * sizeof(struct loader_scanned_icds)) >=
icd_libs->capacity) {
- icd_libs->list = loader_instance_heap_realloc(
+ icd_libs->list = loader_heap_realloc(
inst, icd_libs->list, icd_libs->capacity, icd_libs->capacity * 2,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == icd_libs->list) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "realloc failed on icd library list");
- return;
- }
// double capacity
icd_libs->capacity *= 2;
}
new_node->CreateInstance = fp_create_inst;
new_node->interface_version = interface_vers;
- new_node->lib_name = (char *)loader_instance_heap_alloc(
+ new_node->lib_name = (char *)loader_heap_alloc(
inst, strlen(filename) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == new_node->lib_name) {
+ if (!new_node->lib_name) {
loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
"Out of memory can't add icd");
return;
}
static void loader_debug_init(void) {
- char *env, *orig;
+ const char *env, *orig;
if (g_loader_debug > 0)
return;
g_loader_debug = 0;
/* parse comma-separated debug options */
- orig = env = loader_getenv("VK_LOADER_DEBUG", NULL);
+ orig = env = loader_getenv("VK_LOADER_DEBUG");
while (env) {
- char *p = strchr(env, ',');
+ const char *p = strchr(env, ',');
size_t len;
if (p)
env = p + 1;
}
- loader_free_getenv(orig, NULL);
+ loader_free_getenv(orig);
}
void loader_initialize(void) {
// initial cJSON to use alloc callbacks
cJSON_Hooks alloc_fns = {
- .malloc_fn = loader_instance_tls_heap_alloc,
- .free_fn = loader_instance_tls_heap_free,
+ .malloc_fn = loader_tls_heap_alloc, .free_fn = loader_tls_heap_free,
};
cJSON_InitHooks(&alloc_fns);
}
/**
* 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) {
+void loader_copy_layer_properties(const struct loader_instance *inst,
+ struct loader_layer_properties *dst,
+ struct loader_layer_properties *src) {
uint32_t cnt, i;
memcpy(dst, src, sizeof(*src));
dst->instance_extension_list.list =
- loader_instance_heap_alloc(inst, sizeof(VkExtensionProperties) *
- src->instance_extension_list.count,
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == dst->instance_extension_list.list) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "alloc failed for instance extension list");
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
+ loader_heap_alloc(inst, sizeof(VkExtensionProperties) *
+ src->instance_extension_list.count,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
dst->instance_extension_list.capacity =
sizeof(VkExtensionProperties) * src->instance_extension_list.count;
memcpy(dst->instance_extension_list.list, src->instance_extension_list.list,
dst->instance_extension_list.capacity);
dst->device_extension_list.list =
- loader_instance_heap_alloc(inst, sizeof(struct loader_dev_ext_props) *
- src->device_extension_list.count,
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == dst->device_extension_list.list) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "alloc failed for device extension list");
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
- memset(dst->device_extension_list.list, 0, sizeof(struct loader_dev_ext_props) *
- src->device_extension_list.count);
+ loader_heap_alloc(inst, sizeof(struct loader_dev_ext_props) *
+ src->device_extension_list.count,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
dst->device_extension_list.capacity =
sizeof(struct loader_dev_ext_props) * src->device_extension_list.count;
if (src->device_extension_list.count > 0 &&
src->device_extension_list.list->entrypoint_count > 0) {
cnt = src->device_extension_list.list->entrypoint_count;
- dst->device_extension_list.list->entrypoints =
- loader_instance_heap_alloc(inst, sizeof(char *) * cnt,
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == dst->device_extension_list.list->entrypoints) {
- loader_log(
- inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "alloc failed for device extension list entrypoint array");
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
- memset(dst->device_extension_list.list->entrypoints, 0, sizeof(char *) * cnt);
-
+ dst->device_extension_list.list->entrypoints = loader_heap_alloc(
+ inst, sizeof(char *) * cnt, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
for (i = 0; i < cnt; i++) {
- dst->device_extension_list.list->entrypoints[i] =
- loader_instance_heap_alloc(
- inst,
- strlen(src->device_extension_list.list->entrypoints[i]) + 1,
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == dst->device_extension_list.list->entrypoints[i]) {
- loader_log(
- inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "alloc failed for device extension list entrypoint %d", i);
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
+ dst->device_extension_list.list->entrypoints[i] = loader_heap_alloc(
+ inst,
+ strlen(src->device_extension_list.list->entrypoints[i]) + 1,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
strcpy(dst->device_extension_list.list->entrypoints[i],
src->device_extension_list.list->entrypoints[i]);
}
}
-
- return VK_SUCCESS;
}
static bool
* @param layer_count
* @param ppp_layer_names
*/
-VkResult loader_expand_layer_names(
- struct loader_instance *inst, const char *key_name, uint32_t expand_count,
+void 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) {
if (!loader_find_layer_name(key_name, *layer_count,
(char const **)pp_src_layers)) {
inst->activated_layers_are_std_val = false;
- return VK_SUCCESS; // didn't find the key_name in the list.
+ return; // didn't find the key_name in the list.
}
loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
key_name);
inst->activated_layers_are_std_val = true;
- char const **pp_dst_layers = loader_instance_heap_alloc(
+ char const **pp_dst_layers = loader_heap_alloc(
inst, (expand_count + *layer_count - 1) * sizeof(char const *),
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
- if (NULL == pp_dst_layers) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "alloc failed for dst layer array");
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
// copy layers from src to dst, stripping key_name and anything in
// expand_names.
*ppp_layer_names = pp_dst_layers;
*layer_count = dst_index;
-
- return VK_SUCCESS;
}
void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst,
VkInstanceCreateInfo *ours) {
/* Free the layer names array iff we had to reallocate it */
if (orig->ppEnabledLayerNames != ours->ppEnabledLayerNames) {
- loader_instance_heap_free(inst, (void *)ours->ppEnabledLayerNames);
+ loader_heap_free(inst, (void *)ours->ppEnabledLayerNames);
}
}
struct loader_layer_properties *props;
if (found) {
props = loader_get_next_layer_property(inst, layer_list);
- if (NULL == props) {
- // Error already triggered in loader_get_next_layer_property.
- return;
- }
loader_init_std_validation_props(props);
}
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) \
{ \
return; \
} \
temp = cJSON_Print(item); \
- if (temp == NULL) { \
- layer_node = layer_node->next; \
- loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, \
- "Problem accessing layer value %s in manifest JSON " \
- "file, skipping this layer", \
- #var); \
- return; \
- } \
temp[strlen(temp) - 1] = '\0'; \
var = loader_stack_alloc(strlen(temp) + 1); \
strcpy(var, &temp[1]); \
- cJSON_Free(temp); \
+ loader_tls_heap_free(temp); \
}
GET_JSON_ITEM(layer_node, name)
GET_JSON_ITEM(layer_node, type)
return;
}
props = loader_get_next_layer_property(inst, layer_instance_list);
- if (NULL == props) {
- // Error already triggered in loader_get_next_layer_property.
- return;
- }
props->type = (is_implicit) ? VK_LAYER_TYPE_INSTANCE_IMPLICIT
: VK_LAYER_TYPE_INSTANCE_EXPLICIT;
}
item = cJSON_GetObjectItem(node, #var); \
if (item != NULL) { \
temp = cJSON_Print(item); \
- if (temp != NULL) { \
- temp[strlen(temp) - 1] = '\0'; \
- var = loader_stack_alloc(strlen(temp) + 1); \
- strcpy(var, &temp[1]); \
- cJSON_Free(temp); \
- } \
+ temp[strlen(temp) - 1] = '\0'; \
+ var = loader_stack_alloc(strlen(temp) + 1); \
+ strcpy(var, &temp[1]); \
+ loader_tls_heap_free(temp); \
} \
}
for (i = 0; i < count; i++) {
ext_item = cJSON_GetArrayItem(instance_extensions, i);
GET_JSON_ITEM(ext_item, name)
+ GET_JSON_ITEM(ext_item, spec_version)
if (name != NULL) {
strncpy(ext_prop.extensionName, name,
sizeof(ext_prop.extensionName));
ext_prop.extensionName[sizeof(ext_prop.extensionName) - 1] =
'\0';
}
- GET_JSON_ITEM(ext_item, spec_version)
- if (NULL != spec_version) {
- ext_prop.specVersion = atoi(spec_version);
- } else {
- ext_prop.specVersion = 0;
- }
+ ext_prop.specVersion = atoi(spec_version);
bool ext_unsupported =
wsi_unsupported_instance_extension(&ext_prop);
if (!ext_unsupported) {
ext_prop.extensionName[sizeof(ext_prop.extensionName) - 1] =
'\0';
}
- if (NULL != spec_version) {
- ext_prop.specVersion = atoi(spec_version);
- } else {
- ext_prop.specVersion = 0;
- }
+ ext_prop.specVersion = atoi(spec_version);
// entrypoints = cJSON_GetObjectItem(ext_item, "entrypoints");
GET_JSON_OBJECT(ext_item, entrypoints)
int entry_count;
continue;
}
entry_count = cJSON_GetArraySize(entrypoints);
- if (entry_count) {
+ if (entry_count)
entry_array =
(char **)loader_stack_alloc(sizeof(char *) * entry_count);
- }
for (j = 0; j < entry_count; j++) {
ext_item = cJSON_GetArrayItem(entrypoints, j);
if (ext_item != NULL) {
temp = cJSON_Print(ext_item);
- if (NULL == temp) {
- entry_array[j] = NULL;
- continue;
- }
temp[strlen(temp) - 1] = '\0';
entry_array[j] = loader_stack_alloc(strlen(temp) + 1);
strcpy(entry_array[j], &temp[1]);
- cJSON_Free(temp);
+ loader_tls_heap_free(temp);
}
}
loader_add_to_dev_ext_list(inst, &props->device_extension_list,
/* Fields in layer manifest file that are required:
* (required) “file_format_version”
*
- * If more than one "layer" object are to be used, use the "layers" array
- * instead.
+ * If more than one "layer" object are to be used, use the "layers" array instead.
*
* First get all required items and if any missing abort
*/
return;
}
char *file_vers = cJSON_PrintUnformatted(item);
- if (NULL == file_vers) {
- return;
- }
loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
"Found manifest file %s, version %s", filename, file_vers);
// Get the major/minor/and patch as integers for easier comparison
"1.0.1), may cause errors",
filename);
}
- cJSON_Free(file_vers);
+ loader_tls_heap_free(file_vers);
// If "layers" is present, read in the array of layer objects
layers_node = cJSON_GetObjectItem(json, "layers");
if (layers_node != NULL) {
* 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.
* Linux ICD | dirs | files
* Linux Layer| dirs | dirs
*/
-static VkResult loader_get_manifest_files(
- const struct loader_instance *inst, const char *env_override,
- char *source_override, bool is_layer, const char *location,
- const char *home_location, struct loader_manifest_files *out_files) {
- char * override = NULL;
- char *loc, *orig_loc = NULL;
- char *reg = NULL;
+static void loader_get_manifest_files(const struct loader_instance *inst,
+ const char *env_override,
+ const char *source_override, bool is_layer,
+ const char *location,
+ const char *home_location,
+ struct loader_manifest_files *out_files) {
+ const char *override = NULL;
+ char *loc;
char *file, *next_file, *name;
size_t alloced_count = 64;
char full_path[2048];
DIR *sysdir = NULL;
bool list_is_dirs = false;
struct dirent *dent;
- VkResult res = VK_SUCCESS;
out_files->count = 0;
out_files->filename_list = NULL;
if (source_override != NULL) {
override = source_override;
- } else if (env_override != NULL &&
- (override = loader_getenv(env_override, inst))) {
+ } else if (env_override != NULL && (override = loader_getenv(env_override))) {
#if !defined(_WIN32)
if (geteuid() != getuid() || getegid() != getgid()) {
/* Don't allow setuid apps to use the env var: */
- loader_free_getenv(override, inst);
+ loader_free_getenv(override);
override = NULL;
}
#endif
inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Can't get manifest files with NULL location, env_override=%s",
env_override);
- res = VK_ERROR_INITIALIZATION_FAILED;
- goto out;
+ return;
}
#if defined(_WIN32)
if (loc == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Out of memory can't get manifest files");
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ return;
}
strcpy(loc, location);
#if defined(_WIN32)
- reg = loader_get_registry_files(inst, loc);
- if (reg == NULL) {
+ loc = loader_get_registry_files(inst, loc);
+ if (loc == NULL) {
if (!is_layer) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Registry lookup failed can't get ICD manifest "
"files, do you have a Vulkan driver installed");
- // This typically only fails when out of memory, which is
- // critical
- // if this is for the loader.
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
} else {
// warning only for layers
loader_log(
inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
"Registry lookup failed can't get layer manifest files");
- // Return success for now since it's not critical for layers
- res = VK_SUCCESS;
}
- goto out;
+ return;
}
- orig_loc = loc;
- loc = reg;
#endif
} else {
loc = loader_stack_alloc(strlen(override) + 1);
if (loc == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Out of memory can't get manifest files");
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ return;
}
strcpy(loc, override);
if (source_override == NULL) {
- loader_free_getenv(override, inst);
+ loader_free_getenv(override);
}
}
if (dir == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Out of memory can't get manifest files");
- goto out;
+ return;
}
strcpy(dir, loc);
const char *suf = name + nlen - 5;
if ((nlen > 5) && !strncmp(suf, ".json", 5)) {
if (out_files->count == 0) {
- out_files->filename_list = loader_instance_heap_alloc(
- inst, alloced_count * sizeof(char *),
- VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
+ out_files->filename_list =
+ loader_heap_alloc(inst, alloced_count * sizeof(char *),
+ VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
} else if (out_files->count == alloced_count) {
- out_files->filename_list = loader_instance_heap_realloc(
- inst, out_files->filename_list,
- alloced_count * sizeof(char *),
- alloced_count * sizeof(char *) * 2,
- VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
+ out_files->filename_list =
+ loader_heap_realloc(inst, out_files->filename_list,
+ alloced_count * sizeof(char *),
+ alloced_count * sizeof(char *) * 2,
+ VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
alloced_count *= 2;
}
if (out_files->filename_list == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Out of memory can't alloc manifest file list");
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ return;
}
- out_files->filename_list[out_files->count] =
- loader_instance_heap_alloc(
- inst, strlen(name) + 1,
- VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
+ out_files->filename_list[out_files->count] = loader_heap_alloc(
+ inst, strlen(name) + 1, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (out_files->filename_list[out_files->count] == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Out of memory can't get manifest files");
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ return;
}
strcpy(out_files->filename_list[out_files->count], name);
out_files->count++;
}
if (list_is_dirs) {
dent = readdir(sysdir);
- if (dent == NULL) {
+ if (dent == NULL)
break;
- }
name = &(dent->d_name[0]);
loader_get_fullpath(name, file, sizeof(full_path), full_path);
name = full_path;
break;
}
}
- if (sysdir) {
+ if (sysdir)
closedir(sysdir);
- sysdir = NULL;
- }
file = next_file;
#if !defined(_WIN32)
if (home_location != NULL &&
if (home_loc == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"Out of memory can't get manifest files");
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ return;
}
strcpy(home_loc, home);
// Add directory separator if needed
}
#endif
}
-
-out:
- if (VK_SUCCESS != res && NULL != out_files->filename_list) {
- for (uint32_t remove = 0; remove < out_files->count; remove++) {
- loader_instance_heap_free(inst, out_files->filename_list[remove]);
- }
- loader_instance_heap_free(inst, out_files->filename_list);
- out_files->count = 0;
- out_files->filename_list = NULL;
- }
-
- if (NULL != sysdir) {
- closedir(sysdir);
- }
-
- if (NULL != reg && reg != orig_loc) {
- loader_instance_heap_free(inst, reg);
- }
- return res;
+ return;
}
void loader_init_icd_lib_list() {}
* manifest files it finds the ICD libraries.
*
* \returns
- * Vulkan result
- * (on result == VK_SUCCESS) a list of icds that were discovered
+ * a list of icds that were discovered
*/
-VkResult loader_icd_scan(const struct loader_instance *inst,
- struct loader_icd_libs *icds) {
+void loader_icd_scan(const struct loader_instance *inst,
+ struct loader_icd_libs *icds) {
char *file_str;
uint16_t file_major_vers = 0;
uint16_t file_minor_vers = 0;
uint16_t file_patch_vers = 0;
char *vers_tok;
struct loader_manifest_files manifest_files;
- VkResult res = VK_SUCCESS;
- bool lockedMutex = false;
- cJSON *json = NULL;
-
- memset(&manifest_files, 0, sizeof(struct loader_manifest_files));
-
- res = loader_scanned_icd_init(inst, icds);
- if (VK_SUCCESS != res) {
- goto out;
- }
+ loader_scanned_icd_init(inst, icds);
// Get a list of manifest files for ICDs
- res = loader_get_manifest_files(inst, "VK_ICD_FILENAMES", NULL, false,
- DEFAULT_VK_DRIVERS_INFO,
- HOME_VK_DRIVERS_INFO, &manifest_files);
- if (VK_SUCCESS != res || manifest_files.count == 0) {
- goto out;
- }
+ loader_get_manifest_files(inst, "VK_ICD_FILENAMES", NULL, false,
+ DEFAULT_VK_DRIVERS_INFO, HOME_VK_DRIVERS_INFO,
+ &manifest_files);
+ if (manifest_files.count == 0)
+ return;
loader_platform_thread_lock_mutex(&loader_json_lock);
- lockedMutex = true;
for (uint32_t i = 0; i < manifest_files.count; i++) {
file_str = manifest_files.filename_list[i];
- if (file_str == NULL) {
+ if (file_str == NULL)
continue;
- }
+ cJSON *json;
json = loader_get_json(inst, file_str);
- if (!json) {
+ if (!json)
continue;
- }
cJSON *item, *itemICD;
item = cJSON_GetObjectItem(json, "file_format_version");
if (item == NULL) {
- res = VK_ERROR_INITIALIZATION_FAILED;
- goto out;
+ loader_platform_thread_unlock_mutex(&loader_json_lock);
+ return;
}
char *file_vers = cJSON_Print(item);
- if (NULL == file_vers) {
- // Only reason the print can fail is if there was an allocation
- // issue
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
- }
loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
"Found manifest file %s, version %s", file_str, file_vers);
// Get the major/minor/and patch as integers for easier comparison
}
if (file_major_vers != 1 || file_minor_vers != 0 || file_patch_vers > 1)
loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
- "Unexpected manifest file version (expected 1.0.0 or "
- "1.0.1), may "
+ "Unexpected manifest file version (expected 1.0.0 or 1.0.1), may "
"cause errors");
- cJSON_Free(file_vers);
+ loader_tls_heap_free(file_vers);
itemICD = cJSON_GetObjectItem(json, "ICD");
if (itemICD != NULL) {
item = cJSON_GetObjectItem(itemICD, "library_path");
"Can't find \"library_path\" in ICD JSON file "
"%s, skipping",
file_str);
- cJSON_Free(temp);
+ loader_tls_heap_free(temp);
+ loader_heap_free(inst, file_str);
cJSON_Delete(json);
- json = NULL;
continue;
}
// strip out extra quotes
temp[strlen(temp) - 1] = '\0';
char *library_path = loader_stack_alloc(strlen(temp) + 1);
strcpy(library_path, &temp[1]);
- cJSON_Free(temp);
+ loader_tls_heap_free(temp);
if (!library_path || strlen(library_path) == 0) {
loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
"Can't find \"library_path\" in ICD JSON file "
"%s, skipping",
file_str);
+ loader_heap_free(inst, file_str);
cJSON_Delete(json);
- json = NULL;
continue;
}
char fullpath[MAX_STRING_SIZE];
item = cJSON_GetObjectItem(itemICD, "api_version");
if (item != NULL) {
temp = cJSON_Print(item);
- if (NULL == temp) {
- // Only reason the print can fail is if there was an
- // allocation issue
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
- }
vers = loader_make_version(temp);
- cJSON_Free(temp);
+ loader_tls_heap_free(temp);
}
loader_scanned_icd_add(inst, icds, fullpath, vers);
- } else {
+ } else
loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
"Can't find \"library_path\" object in ICD JSON "
"file %s, skipping",
file_str);
- }
- } else {
+ } else
loader_log(
inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0,
"Can't find \"ICD\" object in ICD JSON file %s, skipping",
file_str);
- }
+ loader_heap_free(inst, file_str);
cJSON_Delete(json);
- json = NULL;
}
-
-out:
- if (NULL != json) {
- cJSON_Delete(json);
- }
- if (NULL != manifest_files.filename_list) {
- for (uint32_t i = 0; i < manifest_files.count; i++) {
- if (NULL != manifest_files.filename_list[i]) {
- loader_instance_heap_free(inst,
- manifest_files.filename_list[i]);
- }
- }
- loader_instance_heap_free(inst, manifest_files.filename_list);
- }
- if (lockedMutex) {
- loader_platform_thread_unlock_mutex(&loader_json_lock);
- }
- return res;
+ loader_heap_free(inst, manifest_files.filename_list);
+ loader_platform_thread_unlock_mutex(&loader_json_lock);
}
void loader_layer_scan(const struct loader_instance *inst,
cJSON *json;
uint32_t i;
uint32_t implicit;
- bool lockedMutex = false;
-
- memset(manifest_files, 0, sizeof(struct loader_manifest_files) * 2);
// Get a list of manifest files for explicit layers
- VkResult res = loader_get_manifest_files(
- inst, LAYERS_PATH_ENV, LAYERS_SOURCE_PATH, true,
- DEFAULT_VK_ELAYERS_INFO, HOME_VK_ELAYERS_INFO, &manifest_files[0]);
- if (VK_SUCCESS != res || manifest_files[0].count == 0) {
- goto out;
- }
+ loader_get_manifest_files(inst, LAYERS_PATH_ENV, LAYERS_SOURCE_PATH, true,
+ DEFAULT_VK_ELAYERS_INFO, HOME_VK_ELAYERS_INFO,
+ &manifest_files[0]);
// Pass NULL for environment variable override - implicit layers are not
// overridden by LAYERS_PATH_ENV
- res = loader_get_manifest_files(inst, NULL, NULL, true,
- DEFAULT_VK_ILAYERS_INFO,
- HOME_VK_ILAYERS_INFO, &manifest_files[1]);
- if (VK_SUCCESS != res || manifest_files[1].count == 0) {
- goto out;
- }
+ loader_get_manifest_files(inst, NULL, NULL, true, DEFAULT_VK_ILAYERS_INFO,
+ HOME_VK_ILAYERS_INFO, &manifest_files[1]);
+ if (manifest_files[0].count == 0 && manifest_files[1].count == 0)
+ return;
/* cleanup any previously scanned libraries */
loader_delete_layer_properties(inst, instance_layers);
loader_platform_thread_lock_mutex(&loader_json_lock);
- lockedMutex = true;
for (implicit = 0; implicit < 2; implicit++) {
for (i = 0; i < manifest_files[implicit].count; i++) {
file_str = manifest_files[implicit].filename_list[i];
loader_add_layer_properties(inst, instance_layers, json,
(implicit == 1), file_str);
+
+ loader_heap_free(inst, file_str);
cJSON_Delete(json);
}
}
+ if (manifest_files[0].count != 0)
+ loader_heap_free(inst, manifest_files[0].filename_list);
+
+ if (manifest_files[1].count != 0)
+ loader_heap_free(inst, manifest_files[1].filename_list);
// 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);
-
-out:
- for (uint32_t manFile = 0; manFile < 2; manFile++) {
- if (NULL != manifest_files[manFile].filename_list) {
- for (uint32_t i = 0; i < manifest_files[manFile].count; i++) {
- if (NULL != manifest_files[manFile].filename_list[i]) {
- loader_instance_heap_free(
- inst, manifest_files[manFile].filename_list[i]);
- }
- }
- loader_instance_heap_free(inst,
- manifest_files[manFile].filename_list);
- }
- }
- if (lockedMutex) {
- loader_platform_thread_unlock_mutex(&loader_json_lock);
- }
+ loader_add_layer_property_meta(
+ inst, sizeof(std_validation_names) / sizeof(std_validation_names[0]),
+ std_validation_names, instance_layers);
+
+ loader_platform_thread_unlock_mutex(&loader_json_lock);
}
void loader_implicit_layer_scan(const struct loader_instance *inst,
// Pass NULL for environment variable override - implicit layers are not
// overridden by LAYERS_PATH_ENV
- VkResult res = loader_get_manifest_files(
- inst, NULL, NULL, true, DEFAULT_VK_ILAYERS_INFO, HOME_VK_ILAYERS_INFO,
- &manifest_files);
- if (VK_SUCCESS != res || manifest_files.count == 0) {
+ loader_get_manifest_files(inst, NULL, NULL, true, DEFAULT_VK_ILAYERS_INFO,
+ HOME_VK_ILAYERS_INFO, &manifest_files);
+ if (manifest_files.count == 0) {
return;
}
continue;
}
- loader_add_layer_properties(inst, instance_layers, json, true,
- file_str);
+ loader_add_layer_properties(inst, instance_layers, json,
+ true, file_str);
- loader_instance_heap_free(inst, file_str);
+ loader_heap_free(inst, file_str);
cJSON_Delete(json);
}
- loader_instance_heap_free(inst, manifest_files.filename_list);
+
+ if (manifest_files.count != 0) {
+ loader_heap_free(inst, manifest_files.filename_list);
+ }
// 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);
+ loader_add_layer_property_meta(
+ inst, sizeof(std_validation_names) / sizeof(std_validation_names[0]),
+ std_validation_names, instance_layers);
loader_platform_thread_unlock_mutex(&loader_json_lock);
}
static void loader_free_dev_ext_table(struct loader_instance *inst) {
for (uint32_t i = 0; i < MAX_NUM_DEV_EXTS; i++) {
- loader_instance_heap_free(inst, inst->disp_hash[i].func_name);
- loader_instance_heap_free(inst, inst->disp_hash[i].list.index);
+ loader_heap_free(inst, inst->disp_hash[i].func_name);
+ loader_heap_free(inst, inst->disp_hash[i].list.index);
}
memset(inst->disp_hash, 0, sizeof(inst->disp_hash));
}
if (!inst->disp_hash[idx].func_name) {
// no entry here at this idx, so use it
assert(list->capacity == 0);
- inst->disp_hash[idx].func_name = (char *)loader_instance_heap_alloc(
+ inst->disp_hash[idx].func_name = (char *)loader_heap_alloc(
inst, strlen(funcName) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (inst->disp_hash[idx].func_name == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
// check for enough capacity
if (list->capacity == 0) {
- list->index = loader_instance_heap_alloc(inst, 8 * sizeof(*(list->index)),
+ list->index = loader_heap_alloc(inst, 8 * sizeof(*(list->index)),
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (list->index == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
}
list->capacity = 8 * sizeof(*(list->index));
} else if (list->capacity < (list->count + 1) * sizeof(*(list->index))) {
- list->index = loader_instance_heap_realloc(inst, list->index, list->capacity,
+ list->index = loader_heap_realloc(inst, list->index, list->capacity,
list->capacity * 2,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (list->index == NULL) {
if (!inst->disp_hash[i].func_name) {
assert(inst->disp_hash[i].list.capacity == 0);
inst->disp_hash[i].func_name =
- (char *)loader_instance_heap_alloc(inst, strlen(funcName) + 1,
+ (char *)loader_heap_alloc(inst, strlen(funcName) + 1,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (inst->disp_hash[i].func_name == NULL) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
}
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 */
for (uint32_t i = 0; i < list->count; i++) {
loader_close_layer_lib(instance, layer_prop);
}
- loader_destroy_layer_list(instance, device, list);
+ loader_destroy_layer_list(instance, list);
}
/**
if (prop->enable_env_var.name[0] == 0) {
enable = true;
} else {
- env_value = loader_getenv(prop->enable_env_var.name, inst);
+ env_value = loader_getenv(prop->enable_env_var.name);
if (env_value && !strcmp(prop->enable_env_var.value, env_value))
enable = true;
- loader_free_getenv(env_value, inst);
+ loader_free_getenv(env_value);
}
// disable_environment has priority, i.e. if both enable and disable
// environment variables are set, the layer is disabled. Implicit
// layers
// are required to have a disable_environment variables
- env_value = loader_getenv(prop->disable_env_var.name, inst);
- if (env_value) {
+ env_value = loader_getenv(prop->disable_env_var.name);
+ if (env_value)
enable = false;
- }
- loader_free_getenv(env_value, inst);
+ loader_free_getenv(env_value);
- if (enable) {
+ if (enable)
loader_add_to_layer_list(inst, list, 1, prop);
- }
}
}
}
char *layerEnv;
char *next, *name;
- layerEnv = loader_getenv(env_name, inst);
+ layerEnv = loader_getenv(env_name);
if (layerEnv == NULL) {
return;
}
}
strcpy(name, layerEnv);
- loader_free_getenv(layerEnv, inst);
+ loader_free_getenv(layerEnv);
while (name && *name) {
next = loader_get_next_path(name);
* Terminator functions for the Instance chain
* All named terminator_<Vulakn API name>
*/
-VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(
- const VkInstanceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) {
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkInstance *pInstance) {
struct loader_icd *icd;
VkExtensionProperties *prop;
char **filtered_extension_names = NULL;
for (uint32_t i = 0; i < ptr_instance->icd_libs.count; i++) {
icd = loader_icd_add(ptr_instance, &ptr_instance->icd_libs.list[i]);
- if (NULL == icd) {
- while (NULL != ptr_instance->icds) {
- icd = ptr_instance->icds;
- ptr_instance->icds = icd->next;
- icd->DestroyInstance(icd->instance, pAllocator);
- loader_icd_destroy(ptr_instance, icd, pAllocator);
+ if (icd) {
+ icd_create_info.enabledExtensionCount = 0;
+ 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
+ loader_init_generic_list(ptr_instance,
+ (struct loader_generic_list *)&icd_exts,
+ sizeof(VkExtensionProperties));
+ loader_add_instance_extensions(
+ ptr_instance,
+ icd->this_icd_lib->EnumerateInstanceExtensionProperties,
+ icd->this_icd_lib->lib_name, &icd_exts);
+
+ for (uint32_t j = 0; j < pCreateInfo->enabledExtensionCount; j++) {
+ prop = get_extension_property(
+ pCreateInfo->ppEnabledExtensionNames[j], &icd_exts);
+ if (prop) {
+ filtered_extension_names[icd_create_info
+ .enabledExtensionCount] =
+ (char *)pCreateInfo->ppEnabledExtensionNames[j];
+ icd_create_info.enabledExtensionCount++;
+ }
}
- return VK_ERROR_OUT_OF_HOST_MEMORY;
- }
- icd_create_info.enabledExtensionCount = 0;
- 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
- loader_init_generic_list(ptr_instance,
- (struct loader_generic_list *)&icd_exts,
- sizeof(VkExtensionProperties));
- loader_add_instance_extensions(
- ptr_instance,
- icd->this_icd_lib->EnumerateInstanceExtensionProperties,
- icd->this_icd_lib->lib_name, &icd_exts);
-
- for (uint32_t j = 0; j < pCreateInfo->enabledExtensionCount; j++) {
- prop = get_extension_property(
- pCreateInfo->ppEnabledExtensionNames[j], &icd_exts);
- if (prop) {
- filtered_extension_names[icd_create_info
- .enabledExtensionCount] =
- (char *)pCreateInfo->ppEnabledExtensionNames[j];
- icd_create_info.enabledExtensionCount++;
+ loader_destroy_generic_list(
+ ptr_instance, (struct loader_generic_list *)&icd_exts);
+
+ res = ptr_instance->icd_libs.list[i].CreateInstance(
+ &icd_create_info, pAllocator, &(icd->instance));
+ if (res == VK_SUCCESS)
+ success = loader_icd_init_entrys(
+ icd, icd->instance,
+ ptr_instance->icd_libs.list[i].GetInstanceProcAddr);
+
+ if (res != VK_SUCCESS || !success) {
+ ptr_instance->icds = ptr_instance->icds->next;
+ loader_icd_destroy(ptr_instance, icd);
+ loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
+ "ICD ignored: failed to CreateInstance and find "
+ "entrypoints with ICD");
}
}
-
- loader_destroy_generic_list(ptr_instance,
- (struct loader_generic_list *)&icd_exts);
-
- res = ptr_instance->icd_libs.list[i].CreateInstance(
- &icd_create_info, pAllocator, &(icd->instance));
- if (res == VK_SUCCESS)
- success = loader_icd_init_entrys(
- icd, icd->instance,
- ptr_instance->icd_libs.list[i].GetInstanceProcAddr);
-
- if (res != VK_SUCCESS || !success) {
- ptr_instance->icds = ptr_instance->icds->next;
- loader_icd_destroy(ptr_instance, icd, pAllocator);
- loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "ICD ignored: failed to CreateInstance and find "
- "entrypoints with ICD");
- }
}
/*
return VK_SUCCESS;
}
-VKAPI_ATTR void VKAPI_CALL terminator_DestroyInstance(
- VkInstance instance, const VkAllocationCallbacks *pAllocator) {
+VKAPI_ATTR void VKAPI_CALL
+terminator_DestroyInstance(VkInstance instance,
+ const VkAllocationCallbacks *pAllocator) {
struct loader_instance *ptr_instance = loader_instance(instance);
struct loader_icd *icds = ptr_instance->icds;
struct loader_icd *next_icd;
}
next_icd = icds->next;
icds->instance = VK_NULL_HANDLE;
- loader_icd_destroy(ptr_instance, icds, pAllocator);
+ loader_icd_destroy(ptr_instance, icds);
icds = next_icd;
}
loader_destroy_generic_list(
ptr_instance, (struct loader_generic_list *)&ptr_instance->ext_list);
if (ptr_instance->phys_devs_term)
- loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_term);
+ loader_heap_free(ptr_instance, ptr_instance->phys_devs_term);
loader_free_dev_ext_table(ptr_instance);
}
-VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(
- VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
- VkResult res = VK_SUCCESS;
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_CreateDevice(VkPhysicalDevice physicalDevice,
+ const VkDeviceCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkDevice *pDevice) {
struct loader_physical_device *phys_dev;
phys_dev = (struct loader_physical_device *)physicalDevice;
struct loader_device *dev = (struct loader_device *)*pDevice;
PFN_vkCreateDevice fpCreateDevice = phys_dev->this_icd->CreateDevice;
- struct loader_extension_list icd_exts;
-
- icd_exts.list = NULL;
if (fpCreateDevice == NULL) {
- res = VK_ERROR_INITIALIZATION_FAILED;
- goto out;
+ return VK_ERROR_INITIALIZATION_FAILED;
}
VkDeviceCreateInfo localCreateInfo;
(const char *const *)filtered_extension_names;
/* Get the physical device (ICD) extensions */
+ struct loader_extension_list icd_exts;
+ VkResult res;
if (!loader_init_generic_list(phys_dev->this_icd->this_instance,
(struct loader_generic_list *)&icd_exts,
sizeof(VkExtensionProperties))) {
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
}
res = loader_add_device_extensions(
phys_dev->phys_dev, phys_dev->this_icd->this_icd_lib->lib_name,
&icd_exts);
if (res != VK_SUCCESS) {
- goto out;
+ return res;
}
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
pAllocator, &dev->device);
if (res != VK_SUCCESS) {
- goto out;
+ return res;
}
*pDevice = dev->device;
/* Init dispatch pointer in new device object */
loader_init_dispatch(*pDevice, &dev->loader_dispatch);
-out:
- if (NULL != icd_exts.list) {
- loader_destroy_generic_list(phys_dev->this_icd->this_instance,
- (struct loader_generic_list *)&icd_exts);
- }
-
return res;
}
: *pPhysicalDeviceCount;
if (inst->phys_devs_term)
- loader_instance_heap_free(inst, inst->phys_devs_term);
- inst->phys_devs_term = loader_instance_heap_alloc(
+ loader_heap_free(inst, inst->phys_devs_term);
+ inst->phys_devs_term = loader_heap_alloc(
inst, sizeof(struct loader_physical_device) * copy_count,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (!inst->phys_devs_term)
loader_add_to_ext_list(icd->this_instance, &all_exts, icd_exts.count,
icd_exts.list);
+ loader_init_layer_list(icd->this_instance, &implicit_layer_list);
+
loader_add_layer_implicit(
icd->this_instance, VK_LAYER_TYPE_INSTANCE_IMPLICIT,
&implicit_layer_list, &icd->this_instance->instance_layer_list);
}
loader_destroy_generic_list(icd->this_instance,
(struct loader_generic_list *)&all_exts);
- loader_destroy_generic_list(icd->this_instance,
- (struct loader_generic_list *)&icd_exts);
} else {
/* just return the count; need to add in the count of implicit layer
* extensions
struct loader_extension_list local_ext_list;
struct loader_icd_libs icd_libs;
uint32_t copy_size;
- VkResult res = VK_SUCCESS;
tls_instance = NULL;
memset(&local_ext_list, 0, sizeof(local_ext_list));
VK_STRING_ERROR_NONE) {
assert(VK_FALSE && "vkEnumerateInstanceExtensionProperties: "
"pLayerName is too long or is badly formed");
- res = VK_ERROR_EXTENSION_NOT_PRESENT;
- goto out;
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
}
loader_layer_scan(NULL, &instance_layers);
loader_add_to_ext_list(NULL, &local_ext_list, ext_list->count,
ext_list->list);
}
- loader_destroy_layer_list(NULL, NULL, &local_list);
+ loader_destroy_layer_list(NULL, &local_list);
global_ext_list = &local_ext_list;
} else {
} else {
/* Scan/discover all ICD libraries */
memset(&icd_libs, 0, sizeof(struct loader_icd_libs));
- res = loader_icd_scan(NULL, &icd_libs);
- if (VK_SUCCESS != res) {
- goto out;
- }
+ loader_icd_scan(NULL, &icd_libs);
/* get extensions from all ICD's, merge so no duplicates */
loader_get_icd_loader_instance_extensions(NULL, &icd_libs,
&local_ext_list);
}
if (global_ext_list == NULL) {
- res = VK_ERROR_LAYER_NOT_PRESENT;
- goto out;
+ loader_destroy_layer_list(NULL, &instance_layers);
+ return VK_ERROR_LAYER_NOT_PRESENT;
}
if (pProperties == NULL) {
*pPropertyCount = global_ext_list->count;
- goto out;
+ loader_destroy_layer_list(NULL, &instance_layers);
+ loader_destroy_generic_list(
+ NULL, (struct loader_generic_list *)&local_ext_list);
+ return VK_SUCCESS;
}
copy_size = *pPropertyCount < global_ext_list->count
sizeof(VkExtensionProperties));
}
*pPropertyCount = copy_size;
+ loader_destroy_generic_list(NULL,
+ (struct loader_generic_list *)&local_ext_list);
if (copy_size < global_ext_list->count) {
- res = VK_INCOMPLETE;
- goto out;
+ loader_destroy_layer_list(NULL, &instance_layers);
+ return VK_INCOMPLETE;
}
-out:
- loader_destroy_generic_list(NULL, (struct loader_generic_list *)&local_ext_list);
- loader_destroy_layer_list(NULL, NULL, &instance_layers);
- return res;
+ loader_destroy_layer_list(NULL, &instance_layers);
+ return VK_SUCCESS;
}
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
if (pProperties == NULL) {
*pPropertyCount = instance_layer_list.count;
- loader_destroy_layer_list(NULL, NULL, &instance_layer_list);
+ loader_destroy_layer_list(NULL, &instance_layer_list);
return VK_SUCCESS;
}
}
*pPropertyCount = copy_size;
- loader_destroy_layer_list(NULL, NULL, &instance_layer_list);
+ loader_destroy_layer_list(NULL, &instance_layer_list);
if (copy_size < instance_layer_list.count) {
return VK_INCOMPLETE;
return VK_SUCCESS;
}
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
- const VkInstanceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkInstance *pInstance) {
struct loader_instance *ptr_instance = NULL;
VkInstance created_instance = VK_NULL_HANDLE;
- bool loaderLocked = false;
VkResult res = VK_ERROR_INITIALIZATION_FAILED;
loader_platform_thread_once(&once_init, loader_initialize);
-#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
- {
-#else
- if (pAllocator) {
- ptr_instance = (struct loader_instance *)pAllocator->pfnAllocation(
- pAllocator->pUserData, sizeof(struct loader_instance),
- sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ //TODO start handling the pAllocators again
+#if 0
+ if (pAllocator) {
+ ptr_instance = (struct loader_instance *) pAllocator->pfnAllocation(
+ pAllocator->pUserData,
+ sizeof(struct loader_instance),
+ sizeof(int *),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
} else {
#endif
- ptr_instance =
- (struct loader_instance *)malloc(sizeof(struct loader_instance));
- }
-
- VkInstanceCreateInfo ici = *pCreateInfo;
-
+ ptr_instance =
+ (struct loader_instance *)malloc(sizeof(struct loader_instance));
+ //}
if (ptr_instance == NULL) {
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
}
tls_instance = ptr_instance;
loader_platform_thread_lock_mutex(&loader_lock);
- loaderLocked = true;
memset(ptr_instance, 0, sizeof(struct loader_instance));
+#if 0
if (pAllocator) {
ptr_instance->alloc_callbacks = *pAllocator;
}
+#endif
/*
* Look for one or more debug report create info structures
&ptr_instance->tmp_callbacks)) {
// One or more were found, but allocation failed. Therefore, clean up
// and fail this function:
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ loader_heap_free(ptr_instance, ptr_instance);
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
} else if (ptr_instance->num_tmp_callbacks > 0) {
// Setup the temporary callback(s) here to catch early issues:
if (util_CreateDebugReportCallbacks(ptr_instance, pAllocator,
ptr_instance->tmp_callbacks)) {
// Failure of setting up one or more of the callback. Therefore,
// clean up and fail this function:
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ util_FreeDebugReportCreateInfos(pAllocator,
+ ptr_instance->tmp_dbg_create_infos,
+ ptr_instance->tmp_callbacks);
+ loader_heap_free(ptr_instance, ptr_instance);
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
}
}
pCreateInfo->ppEnabledLayerNames,
&ptr_instance->instance_layer_list);
if (res != VK_SUCCESS) {
- goto out;
+ util_DestroyDebugReportCallbacks(ptr_instance, pAllocator,
+ ptr_instance->num_tmp_callbacks,
+ ptr_instance->tmp_callbacks);
+ util_FreeDebugReportCreateInfos(pAllocator,
+ ptr_instance->tmp_dbg_create_infos,
+ ptr_instance->tmp_callbacks);
+ loader_heap_free(ptr_instance, ptr_instance);
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ return res;
}
}
/* convert any meta layers to the actual layers makes a copy of layer name*/
- VkResult layerErr = loader_expand_layer_names(
+ VkInstanceCreateInfo ici = *pCreateInfo;
+ 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);
- if (VK_SUCCESS != layerErr) {
- res = layerErr;
- goto out;
- }
/* Scan/discover all ICD libraries */
memset(&ptr_instance->icd_libs, 0, sizeof(ptr_instance->icd_libs));
- res = loader_icd_scan(ptr_instance, &ptr_instance->icd_libs);
- if (res != VK_SUCCESS) {
- goto out;
- }
+ loader_icd_scan(ptr_instance, &ptr_instance->icd_libs);
/* get extensions from all ICD's, merge so no duplicates, then validate */
loader_get_icd_loader_instance_extensions(
ptr_instance, &ptr_instance->ext_list,
&ptr_instance->instance_layer_list, &ici);
if (res != VK_SUCCESS) {
- goto out;
+ loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici);
+ 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(
+ ptr_instance,
+ (struct loader_generic_list *)&ptr_instance->ext_list);
+ util_DestroyDebugReportCallbacks(ptr_instance, pAllocator,
+ ptr_instance->num_tmp_callbacks,
+ ptr_instance->tmp_callbacks);
+ util_FreeDebugReportCreateInfos(pAllocator,
+ ptr_instance->tmp_dbg_create_infos,
+ ptr_instance->tmp_callbacks);
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ loader_heap_free(ptr_instance, ptr_instance);
+ return res;
}
- ptr_instance->disp = loader_instance_heap_alloc(
- ptr_instance, sizeof(VkLayerInstanceDispatchTable),
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ ptr_instance->disp =
+ loader_heap_alloc(ptr_instance, sizeof(VkLayerInstanceDispatchTable),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (ptr_instance->disp == NULL) {
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici);
+
+ 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(
+ ptr_instance,
+ (struct loader_generic_list *)&ptr_instance->ext_list);
+ util_DestroyDebugReportCallbacks(ptr_instance, pAllocator,
+ ptr_instance->num_tmp_callbacks,
+ ptr_instance->tmp_callbacks);
+ util_FreeDebugReportCreateInfos(pAllocator,
+ ptr_instance->tmp_dbg_create_infos,
+ ptr_instance->tmp_callbacks);
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ loader_heap_free(ptr_instance, ptr_instance);
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
}
memcpy(ptr_instance->disp, &instance_disp, sizeof(instance_disp));
ptr_instance->next = loader.instances;
res = loader_enable_instance_layers(ptr_instance, &ici,
&ptr_instance->instance_layer_list);
if (res != VK_SUCCESS) {
- goto out;
+ loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici);
+ 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(
+ ptr_instance,
+ (struct loader_generic_list *)&ptr_instance->ext_list);
+ loader.instances = ptr_instance->next;
+ util_DestroyDebugReportCallbacks(ptr_instance, pAllocator,
+ ptr_instance->num_tmp_callbacks,
+ ptr_instance->tmp_callbacks);
+ util_FreeDebugReportCreateInfos(pAllocator,
+ ptr_instance->tmp_dbg_create_infos,
+ ptr_instance->tmp_callbacks);
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ loader_heap_free(ptr_instance, ptr_instance->disp);
+ loader_heap_free(ptr_instance, ptr_instance);
+ return res;
}
created_instance = (VkInstance)ptr_instance;
// TODO: cleanup here.
}
-out:
-
- if (NULL != ptr_instance) {
- if (res != VK_SUCCESS) {
- if (NULL != ptr_instance->next) {
- loader.instances = ptr_instance->next;
- }
- if (NULL != ptr_instance->disp) {
- loader_instance_heap_free(ptr_instance, ptr_instance->disp);
- }
- if (ptr_instance->num_tmp_callbacks > 0) {
- util_DestroyDebugReportCallbacks(
- ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks,
- ptr_instance->tmp_callbacks);
- util_FreeDebugReportCreateInfos(
- pAllocator, ptr_instance->tmp_dbg_create_infos,
- ptr_instance->tmp_callbacks);
- }
-
- loader_deactivate_layers(ptr_instance, NULL,
- &ptr_instance->activated_layer_list);
-
- loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo,
- &ici);
- 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(
- ptr_instance,
- (struct loader_generic_list *)&ptr_instance->ext_list);
-
- loader_instance_heap_free(ptr_instance, ptr_instance);
- } else {
- /* 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);
- }
-
- if (loaderLocked) {
- loader_platform_thread_unlock_mutex(&loader_lock);
- }
- }
-
+ /* 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);
+ loader_platform_thread_unlock_mutex(&loader_lock);
return res;
}
-LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(
- VkInstance instance, const VkAllocationCallbacks *pAllocator) {
+LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
+vkDestroyInstance(VkInstance instance,
+ const VkAllocationCallbacks *pAllocator) {
const VkLayerInstanceDispatchTable *disp;
struct loader_instance *ptr_instance = NULL;
bool callback_setup = false;
ptr_instance = loader_get_instance(instance);
- if (pAllocator) {
- ptr_instance->alloc_callbacks = *pAllocator;
- }
-
if (ptr_instance->num_tmp_callbacks > 0) {
// Setup the temporary callback(s) here to catch cleanup issues:
if (!util_CreateDebugReportCallbacks(ptr_instance, pAllocator,
disp->DestroyInstance(instance, pAllocator);
- loader_deactivate_layers(ptr_instance, NULL,
- &ptr_instance->activated_layer_list);
- if (ptr_instance->phys_devs) {
- loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs);
- }
+ loader_deactivate_layers(ptr_instance, &ptr_instance->activated_layer_list);
+ if (ptr_instance->phys_devs)
+ loader_heap_free(ptr_instance, ptr_instance->phys_devs);
if (callback_setup) {
util_DestroyDebugReportCallbacks(ptr_instance, pAllocator,
ptr_instance->num_tmp_callbacks,
ptr_instance->tmp_dbg_create_infos,
ptr_instance->tmp_callbacks);
}
- loader_instance_heap_free(ptr_instance, ptr_instance->disp);
- loader_instance_heap_free(ptr_instance, ptr_instance);
+ loader_heap_free(ptr_instance, ptr_instance->disp);
+ loader_heap_free(ptr_instance, ptr_instance);
loader_platform_thread_unlock_mutex(&loader_lock);
}
*pPhysicalDeviceCount = count;
if (!inst->phys_devs) {
inst->phys_devs =
- (struct loader_physical_device_tramp *)loader_instance_heap_alloc(
+ (struct loader_physical_device_tramp *)loader_heap_alloc(
inst, inst->total_gpu_count *
sizeof(struct loader_physical_device_tramp),
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
pMemoryProperties);
}
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
- VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateDevice(VkPhysicalDevice physicalDevice,
+ const VkDeviceCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) {
VkResult res;
- struct loader_physical_device_tramp *phys_dev = NULL;
- struct loader_device *dev = NULL;
- struct loader_instance *inst = NULL;
+ struct loader_physical_device_tramp *phys_dev;
+ struct loader_device *dev;
+ struct loader_instance *inst;
assert(pCreateInfo->queueCreateInfoCount >= 1);
/* Get the physical device (ICD) extensions */
struct loader_extension_list icd_exts;
- icd_exts.list = NULL;
if (!loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts,
sizeof(VkExtensionProperties))) {
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
}
res = loader_add_device_extensions(
inst, inst->disp->EnumerateDeviceExtensionProperties,
phys_dev->phys_dev, "Unknown", &icd_exts);
if (res != VK_SUCCESS) {
- goto out;
+ 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, &inst->activated_layer_list, &icd_exts, pCreateInfo);
+ res = loader_validate_device_extensions(phys_dev, &inst->activated_layer_list,
+ &icd_exts, pCreateInfo);
if (res != VK_SUCCESS) {
- goto out;
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ return res;
}
- dev = loader_create_logical_device(inst, pAllocator);
+ dev = loader_create_logical_device(inst);
if (dev == NULL) {
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
}
/* 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_device_heap_alloc(dev, inst->activated_layer_list.capacity,
- VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
+ 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) {
- res = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ 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);
+ sizeof(*dev->activated_layer_list.list) * dev->activated_layer_list.count);
- res = loader_create_device_chain(phys_dev, pCreateInfo, pAllocator, inst,
- dev);
+
+ res = loader_create_device_chain(phys_dev, pCreateInfo, pAllocator, inst, dev);
if (res != VK_SUCCESS) {
- goto out;
+ loader_platform_thread_unlock_mutex(&loader_lock);
+ return res;
}
*pDevice = dev->device;
&dev->loader_dispatch,
dev->loader_dispatch.core_dispatch.GetDeviceProcAddr, *pDevice);
-out:
-
- // Failure cleanup
- if (VK_SUCCESS != res) {
- if (NULL != dev) {
- loader_destroy_logical_device(inst, dev, pAllocator);
- }
- }
-
- if (NULL != icd_exts.list) {
- loader_destroy_generic_list(inst,
- (struct loader_generic_list *)&icd_exts);
- }
loader_platform_thread_unlock_mutex(&loader_lock);
return res;
}
disp->DestroyDevice(device, pAllocator);
dev->device = NULL;
- loader_remove_logical_device(inst, icd, dev, pAllocator);
+ loader_remove_logical_device(inst, icd, dev);
loader_platform_thread_unlock_mutex(&loader_lock);
}
enabled_layers->count = count;
enabled_layers->capacity = enabled_layers->count *
sizeof(struct loader_layer_properties);
- enabled_layers->list = loader_instance_heap_alloc(inst, enabled_layers->capacity,
+ 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;
std_val_count, std_validation_names)) {
struct loader_layer_properties props;
loader_init_std_validation_props(&props);
- VkResult err = loader_copy_layer_properties(inst,
- &enabled_layers->list[j],
- &props);
- if (err != VK_SUCCESS) {
- return err;
- }
+ loader_copy_layer_properties(inst,
+ &enabled_layers->list[j], &props);
i += std_val_count;
}
else {
- VkResult err = loader_copy_layer_properties(inst,
- &enabled_layers->list[j],
- &inst->activated_layer_list.list[i++]);
- if (err != VK_SUCCESS) {
- return err;
- }
+ loader_copy_layer_properties(inst,
+ &enabled_layers->list[j],
+ &inst->activated_layer_list.list[i++]);
}
}
}
}
*pPropertyCount = copy_size;
- if (inst->activated_layers_are_std_val) {
+ 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;
const VkAllocationCallbacks *pAllocator) {
struct loader_instance *ptr_instance = loader_get_instance(instance);
- loader_instance_heap_free(ptr_instance, (void *)surface);
+ loader_heap_free(ptr_instance, (void *)surface);
}
/*
* This is the trampoline entrypoint
* for CreateSwapchainKHR
*/
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
- VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateSwapchainKHR(VkDevice device,
+ const VkSwapchainCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSwapchainKHR *pSwapchain) {
const VkLayerDispatchTable *disp;
disp = loader_get_dispatch(device);
VkResult res =
* This is the trampoline entrypoint
* for CreateWin32SurfaceKHR
*/
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
- VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateWin32SurfaceKHR(VkInstance instance,
+ const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
const VkLayerInstanceDispatchTable *disp;
disp = loader_get_instance_dispatch(instance);
VkResult res;
* This is the instance chain terminator function
* for CreateWin32SurfaceKHR
*/
-VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(
- VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_CreateWin32SurfaceKHR(VkInstance instance,
+ const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
// First, check to ensure the appropriate extension was enabled:
struct loader_instance *ptr_instance = loader_get_instance(instance);
if (!ptr_instance->wsi_win32_surface_enabled) {
// Next, if so, proceed with the implementation of this function:
VkIcdSurfaceWin32 *pIcdSurface = NULL;
- pIcdSurface =
- loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWin32),
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWin32),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (pIcdSurface == NULL) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
* This is the trampoline entrypoint
* for CreateMirSurfaceKHR
*/
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
- VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateMirSurfaceKHR(VkInstance instance,
+ const VkMirSurfaceCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
const VkLayerInstanceDispatchTable *disp;
disp = loader_get_instance_dispatch(instance);
VkResult res;
* This is the instance chain terminator function
* for CreateMirSurfaceKHR
*/
-VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(
- VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_CreateMirSurfaceKHR(VkInstance instance,
+ const VkMirSurfaceCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
// First, check to ensure the appropriate extension was enabled:
struct loader_instance *ptr_instance = loader_get_instance(instance);
if (!ptr_instance->wsi_mir_surface_enabled) {
// Next, if so, proceed with the implementation of this function:
VkIcdSurfaceMir *pIcdSurface = NULL;
- pIcdSurface =
- loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceMir),
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceMir),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (pIcdSurface == NULL) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
* This is the instance chain terminator function
* for CreateWaylandSurfaceKHR
*/
-VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_CreateWaylandSurfaceKHR(
VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
// First, check to ensure the appropriate extension was enabled:
// Next, if so, proceed with the implementation of this function:
VkIcdSurfaceWayland *pIcdSurface = NULL;
- pIcdSurface =
- loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWayland),
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWayland),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (pIcdSurface == NULL) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
* This is the trampoline entrypoint
* for CreateXcbSurfaceKHR
*/
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
- VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateXcbSurfaceKHR(VkInstance instance,
+ const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
const VkLayerInstanceDispatchTable *disp;
disp = loader_get_instance_dispatch(instance);
VkResult res;
* This is the instance chain terminator function
* for CreateXcbSurfaceKHR
*/
-VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(
- VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_CreateXcbSurfaceKHR(VkInstance instance,
+ const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
// First, check to ensure the appropriate extension was enabled:
struct loader_instance *ptr_instance = loader_get_instance(instance);
if (!ptr_instance->wsi_xcb_surface_enabled) {
// Next, if so, proceed with the implementation of this function:
VkIcdSurfaceXcb *pIcdSurface = NULL;
- pIcdSurface =
- loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXcb),
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXcb),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (pIcdSurface == NULL) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
* This is the trampoline entrypoint
* for CreateXlibSurfaceKHR
*/
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
- VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateXlibSurfaceKHR(VkInstance instance,
+ const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
const VkLayerInstanceDispatchTable *disp;
disp = loader_get_instance_dispatch(instance);
VkResult res;
* This is the instance chain terminator function
* for CreateXlibSurfaceKHR
*/
-VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(
- VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_CreateXlibSurfaceKHR(VkInstance instance,
+ const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
// First, check to ensure the appropriate extension was enabled:
struct loader_instance *ptr_instance = loader_get_instance(instance);
if (!ptr_instance->wsi_xlib_surface_enabled) {
// Next, if so, proceed with the implementation of this function:
VkIcdSurfaceXlib *pIcdSurface = NULL;
- pIcdSurface =
- loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXlib),
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXlib),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (pIcdSurface == NULL) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
* This is the trampoline entrypoint
* for CreateAndroidSurfaceKHR
*/
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
- VkInstance instance, ANativeWindow *window,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateAndroidSurfaceKHR(VkInstance instance, ANativeWindow *window,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
const VkLayerInstanceDispatchTable *disp;
disp = loader_get_instance_dispatch(instance);
VkResult res;
* This is the instance chain terminator function
* for CreateAndroidSurfaceKHR
*/
-VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(
- VkInstance instance, Window window, const VkAllocationCallbacks *pAllocator,
- VkSurfaceKHR *pSurface) {
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_CreateAndroidSurfaceKHR(VkInstance instance, Window window,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
// First, check to ensure the appropriate extension was enabled:
struct loader_instance *ptr_instance = loader_get_instance(instance);
if (!ptr_instance->wsi_display_enabled) {
// Next, if so, proceed with the implementation of this function:
VkIcdSurfaceAndroid *pIcdSurface = NULL;
- pIcdSurface =
- loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (pIcdSurface == NULL) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
pPropertyCount, pProperties);
}
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(
- VkPhysicalDevice physicalDevice, VkDisplayKHR display,
- const VkDisplayModeCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
+ const VkDisplayModeCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkDisplayModeKHR *pMode) {
VkPhysicalDevice unwrapped_phys_dev =
loader_unwrap_physical_device(physicalDevice);
const VkLayerInstanceDispatchTable *disp;
return res;
}
-VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(
- VkPhysicalDevice physicalDevice, VkDisplayKHR display,
- const VkDisplayModeCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
+VKAPI_ATTR VkResult VKAPI_CALL
+terminator_CreateDisplayModeKHR(VkPhysicalDevice physicalDevice,
+ VkDisplayKHR display,
+ const VkDisplayModeCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkDisplayModeKHR *pMode) {
// First, check to ensure the appropriate extension was enabled:
struct loader_physical_device *phys_dev =
(struct loader_physical_device *)physicalDevice;
planeIndex, pCapabilities);
}
-LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(
- VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
- const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
+LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
+vkCreateDisplayPlaneSurfaceKHR(VkInstance instance,
+ const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkSurfaceKHR *pSurface) {
const VkLayerInstanceDispatchTable *disp;
disp = loader_get_instance_dispatch(instance);
VkResult res;
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
- pIcdSurface = loader_instance_heap_alloc(
- inst, sizeof(VkIcdSurfaceDisplay), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ pIcdSurface = loader_heap_alloc(inst, sizeof(VkIcdSurfaceDisplay),
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (pIcdSurface == NULL) {
return VK_ERROR_OUT_OF_HOST_MEMORY;
}