aboutsummaryrefslogtreecommitdiff
path: root/loader/trampoline.c
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2017-02-28 09:58:04 -0700
committerMark Young <marky@lunarg.com>2017-03-01 08:20:22 -0700
commite2ebfd58c6cfbafbee172093b22e06867e1c3fe6 (patch)
tree7617f642ef2cee90b334b8e58455296c0f47df59 /loader/trampoline.c
parent9172c7bf11a3dbb663e170f57692e68891e891c9 (diff)
downloadusermoji-e2ebfd58c6cfbafbee172093b22e06867e1c3fe6.tar.xz
vulkan: update to header 1.0.42
Updated all necessary files to 1.0.42. This includes the various headers as well as the loader, and the parameter validation, object tracking, and threading layers. Additionally, bump all layer JSON files to 1.0.42. Also, in this change: - Enable loader extension automation so that the loader now generates all extension entry-points automatically during build to reduce likelihood of missing a critical piece on header update. - Enable layer dispatch table extension automation for the same reason. - Fixes from Mark Lobodzinski and Tony Barbour to resolve crash in loader when working with Intel's Windows driver due to GetInstanceProcAddr getting called on inappropriate command names. Change-Id: Ic18d3fac2e145c386c0192031deb5089c91a00d8
Diffstat (limited to 'loader/trampoline.c')
-rw-r--r--loader/trampoline.c133
1 files changed, 60 insertions, 73 deletions
diff --git a/loader/trampoline.c b/loader/trampoline.c
index 23a1b702..2550cbf5 100644
--- a/loader/trampoline.c
+++ b/loader/trampoline.c
@@ -30,70 +30,62 @@
#include "loader.h"
#include "debug_report.h"
#include "wsi.h"
-#include "extensions.h"
+#include "vk_loader_extensions.h"
#include "gpa_helper.h"
-#include "table_ops.h"
-
-/* Trampoline entrypoints are in this file for core Vulkan commands */
-/**
- * Get an instance level or global level entry point address.
- * @param instance
- * @param pName
- * @return
- * If instance == NULL returns a global level functions only
- * If instance is valid returns a trampoline entry point for all dispatchable
- * Vulkan
- * functions both core and extensions.
- */
+
+// Trampoline entrypoints are in this file for core Vulkan commands
+
+// Get an instance level or global level entry point address.
+// @param instance
+// @param pName
+// @return
+// If instance == NULL returns a global level functions only
+// If instance is valid returns a trampoline entry point for all dispatchable Vulkan
+// functions both core and extensions.
LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName) {
void *addr;
addr = globalGetProcAddr(pName);
if (instance == VK_NULL_HANDLE) {
- // get entrypoint addresses that are global (no dispatchable object)
+ // Get entrypoint addresses that are global (no dispatchable object)
return addr;
} else {
- // if a global entrypoint return NULL
+ // If a global entrypoint return NULL
if (addr) return NULL;
}
struct loader_instance *ptr_instance = loader_get_instance(instance);
if (ptr_instance == NULL) return NULL;
- // Return trampoline code for non-global entrypoints including any
- // extensions.
+ // Return trampoline code for non-global entrypoints including any extensions.
// Device extensions are returned if a layer or ICD supports the extension.
// Instance extensions are returned if the extension is enabled and the
// loader or someone else supports the extension
return trampolineGetProcAddr(ptr_instance, pName);
}
-/**
- * Get a device level or global level entry point address.
- * @param device
- * @param pName
- * @return
- * If device is valid, returns a device relative entry point for device level
- * entry points both core and extensions.
- * Device relative means call down the device chain.
- */
+// Get a device level or global level entry point address.
+// @param device
+// @param pName
+// @return
+// If device is valid, returns a device relative entry point for device level
+// entry points both core and extensions.
+// Device relative means call down the device chain.
LOADER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *pName) {
void *addr;
- /* for entrypoints that loader must handle (ie non-dispatchable or create
- object)
- make sure the loader entrypoint is returned */
+ // For entrypoints that loader must handle (ie non-dispatchable or create object)
+ // make sure the loader entrypoint is returned
addr = loader_non_passthrough_gdpa(pName);
if (addr) {
return addr;
}
- /* Although CreateDevice is on device chain it's dispatchable object isn't
- * a VkDevice or child of VkDevice so return NULL.
- */
+ // Although CreateDevice is on device chain it's dispatchable object isn't
+ // a VkDevice or child of VkDevice so return NULL.
if (!strcmp(pName, "CreateDevice")) return NULL;
- /* return the dispatch table entrypoint for the fastest case */
+ // Return the dispatch table entrypoint for the fastest case
const VkLayerDispatchTable *disp_table = *(VkLayerDispatchTable **)device;
if (disp_table == NULL) return NULL;
@@ -119,7 +111,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionPropert
memset(&instance_layers, 0, sizeof(instance_layers));
loader_platform_thread_once(&once_init, loader_initialize);
- /* get layer libraries if needed */
+ // Get layer libraries if needed
if (pLayerName && strlen(pLayerName) != 0) {
if (vk_string_validate(MaxLoaderStringLength, pLayerName) != VK_STRING_ERROR_NONE) {
assert(VK_FALSE &&
@@ -154,13 +146,13 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionPropert
}
}
} else {
- /* Scan/discover all ICD libraries */
+ // Scan/discover all ICD libraries
memset(&icd_tramp_list, 0, sizeof(struct loader_icd_tramp_list));
res = loader_icd_scan(NULL, &icd_tramp_list);
if (VK_SUCCESS != res) {
goto out;
}
- /* get extensions from all ICD's, merge so no duplicates */
+ // Get extensions from all ICD's, merge so no duplicates
res = loader_get_icd_loader_instance_extensions(NULL, &icd_tramp_list, &local_ext_list);
if (VK_SUCCESS != res) {
goto out;
@@ -214,7 +206,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(
uint32_t copy_size;
- /* get layer libraries */
+ // Get layer libraries
memset(&instance_layer_list, 0, sizeof(instance_layer_list));
loader_layer_scan(NULL, &instance_layer_list);
@@ -276,10 +268,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
ptr_instance->alloc_callbacks = *pAllocator;
}
- /*
- * Look for one or more debug report create info structures
- * and setup a callback(s) for each one found.
- */
+ // Look for one or more debug report create info structures
+ // and setup a callback(s) for each one found.
ptr_instance->num_tmp_callbacks = 0;
ptr_instance->tmp_dbg_create_infos = NULL;
ptr_instance->tmp_callbacks = NULL;
@@ -300,13 +290,13 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
}
}
- /* Due to implicit layers need to get layer list even if
- * enabledLayerCount == 0 and VK_INSTANCE_LAYERS is unset. For now always
- * get layer list via loader_layer_scan(). */
+ // Due to implicit layers need to get layer list even if
+ // enabledLayerCount == 0 and VK_INSTANCE_LAYERS is unset. For now always
+ // get layer list via loader_layer_scan().
memset(&ptr_instance->instance_layer_list, 0, sizeof(ptr_instance->instance_layer_list));
loader_layer_scan(ptr_instance, &ptr_instance->instance_layer_list);
- /* validate the app requested layers to be enabled */
+ // Validate the app requested layers to be enabled
if (pCreateInfo->enabledLayerCount > 0) {
res = loader_validate_layers(ptr_instance, pCreateInfo->enabledLayerCount, pCreateInfo->ppEnabledLayerNames,
&ptr_instance->instance_layer_list);
@@ -315,7 +305,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
}
}
- /* convert any meta layers to the actual layers makes a copy of layer name*/
+ // Convert any meta layers to the actual layers makes a copy of layer name
VkResult layerErr =
loader_expand_layer_names(ptr_instance, std_validation_str, sizeof(std_validation_names) / sizeof(std_validation_names[0]),
std_validation_names, &ici.enabledLayerCount, &ici.ppEnabledLayerNames);
@@ -324,14 +314,14 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
goto out;
}
- /* Scan/discover all ICD libraries */
+ // Scan/discover all ICD libraries
memset(&ptr_instance->icd_tramp_list, 0, sizeof(ptr_instance->icd_tramp_list));
res = loader_icd_scan(ptr_instance, &ptr_instance->icd_tramp_list);
if (res != VK_SUCCESS) {
goto out;
}
- /* get extensions from all ICD's, merge so no duplicates, then validate */
+ // Get extensions from all ICD's, merge so no duplicates, then validate
res = loader_get_icd_loader_instance_extensions(ptr_instance, &ptr_instance->icd_tramp_list, &ptr_instance->ext_list);
if (res != VK_SUCCESS) {
goto out;
@@ -354,7 +344,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
ptr_instance->next = loader.instances;
loader.instances = ptr_instance;
- /* activate any layers on instance chain */
+ // Activate any layers on instance chain
res = loader_enable_instance_layers(ptr_instance, &ici, &ptr_instance->instance_layer_list);
if (res != VK_SUCCESS) {
goto out;
@@ -372,12 +362,10 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCr
*pInstance = created_instance;
- /*
- * Finally have the layers in place and everyone has seen
- * the CreateInstance command go by. This allows the layer's
- * GetInstanceProcAddr functions to return valid extension functions
- * if enabled.
- */
+ // Finally have the layers in place and everyone has seen
+ // the CreateInstance command go by. This allows the layer's
+ // GetInstanceProcAddr functions to return valid extension functions
+ // if enabled.
loader_activate_instance_layer_extensions(ptr_instance, *pInstance);
}
@@ -406,7 +394,7 @@ out:
loader_instance_heap_free(ptr_instance, ptr_instance);
} else {
- /* Remove temporary debug_report callback */
+ // Remove temporary debug_report callback
util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks,
ptr_instance->tmp_callbacks);
loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici);
@@ -484,8 +472,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstan
}
if (NULL == pPhysicalDevices || 0 == inst->total_gpu_count) {
- // Call down. At the lower levels, this will setup the terminator
- // structures in the loader.
+ // Call down. At the lower levels, this will setup the terminator structures in the loader.
res = disp->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
if (VK_SUCCESS != res) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
@@ -506,15 +493,15 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstan
}
// Wrap the PhysDev object for loader usage, return wrapped objects
- if (inst->total_gpu_count > *pPhysicalDeviceCount) {
+ if (inst->phys_dev_count_tramp > *pPhysicalDeviceCount) {
loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
"vkEnumeratePhysicalDevices: Trimming device count down"
" by application request from %d to %d physical devices",
- inst->total_gpu_count, *pPhysicalDeviceCount);
+ inst->phys_dev_count_tramp, *pPhysicalDeviceCount);
count = *pPhysicalDeviceCount;
res = VK_INCOMPLETE;
} else {
- count = inst->total_gpu_count;
+ count = inst->phys_dev_count_tramp;
*pPhysicalDeviceCount = count;
}
@@ -593,7 +580,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice phy
phys_dev = (struct loader_physical_device_tramp *)physicalDevice;
inst = (struct loader_instance *)phys_dev->this_instance;
- /* Get the physical device (ICD) extensions */
+ // Get the physical device (ICD) extensions
struct loader_extension_list icd_exts;
icd_exts.list = NULL;
res = loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts, sizeof(VkExtensionProperties));
@@ -609,7 +596,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice phy
goto out;
}
- /* make sure requested extensions to be enabled are supported */
+ // Make sure requested extensions to be enabled are supported
res = loader_validate_device_extensions(phys_dev, &inst->activated_layer_list, &icd_exts, pCreateInfo);
if (res != VK_SUCCESS) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkCreateDevice: Failed to validate extensions in list");
@@ -622,7 +609,7 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice phy
goto out;
}
- /* copy the instance layer list into the device */
+ // Copy the instance layer list into the device
dev->activated_layer_list.capacity = inst->activated_layer_list.capacity;
dev->activated_layer_list.count = inst->activated_layer_list.count;
dev->activated_layer_list.list =
@@ -701,10 +688,10 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionPropertie
loader_platform_thread_lock_mutex(&loader_lock);
- /* If pLayerName == NULL, then querying ICD extensions, pass this call
- down the instance chain which will terminate in the ICD. This allows
- layers to filter the extensions coming back up the chain.
- If pLayerName != NULL then get layer extensions from manifest file. */
+ // If pLayerName == NULL, then querying ICD extensions, pass this call
+ // down the instance chain which will terminate in the ICD. This allows
+ // layers to filter the extensions coming back up the chain.
+ // If pLayerName != NULL then get layer extensions from manifest file.
if (pLayerName == NULL || strlen(pLayerName) == 0) {
const VkLayerInstanceDispatchTable *disp;
@@ -784,8 +771,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(Vk
memset(&layers_list, 0, sizeof(layers_list));
loader_platform_thread_lock_mutex(&loader_lock);
- /* Don't dispatch this call down the instance chain, want all device layers
- enumerated and instance chain may not contain all device layers */
+ // Don't dispatch this call down the instance chain, want all device layers
+ // enumerated and instance chain may not contain all device layers
// TODO re-evaluate the above statement we maybe able to start calling
// down the chain
@@ -799,8 +786,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(Vk
loader_platform_thread_unlock_mutex(&loader_lock);
return VK_SUCCESS;
}
- /* make sure to enumerate standard_validation if that is what was used
- at the instance layer enablement */
+ // Make sure to enumerate standard_validation if that is what was used
+ // at the instance layer enablement
if (inst->activated_layers_are_std_val) {
enabled_layers = &layers_list;
enabled_layers->count = count;