diff options
| author | Jon Ashburn <jon@lunarg.com> | 2015-09-28 16:15:00 -0600 |
|---|---|---|
| committer | Jon Ashburn <jon@lunarg.com> | 2015-09-30 13:03:32 -0600 |
| commit | 438c6fbadfb72d35a29467a24ca6a93fef06f1c6 (patch) | |
| tree | 8cd1d2cc9dd5f5ff8dbb443681dd4f45aa1c3717 /loader | |
| parent | b43e1d25fb482b70df79bf56589a3f7e05e1a9f3 (diff) | |
| download | usermoji-438c6fbadfb72d35a29467a24ca6a93fef06f1c6.tar.xz | |
loader: Change GetXXProcAddr to support NULL dispatchable object
Also change GetInstanceProcAddr to return the first entry down the chain rather
than global (trampoline entrys) all the time when a non-null instance is passed.
Diffstat (limited to 'loader')
| -rw-r--r-- | loader/gpa_helper.h | 38 | ||||
| -rw-r--r-- | loader/loader.c | 75 | ||||
| -rw-r--r-- | loader/loader.h | 2 |
3 files changed, 65 insertions, 50 deletions
diff --git a/loader/gpa_helper.h b/loader/gpa_helper.h index bc5c7b60..328459d9 100644 --- a/loader/gpa_helper.h +++ b/loader/gpa_helper.h @@ -326,7 +326,7 @@ static inline void* globalGetProcAddr(const char *name) * They are not just generic trampoline code entrypoints. * Thus GPA must return loader entrypoint for these instead of first function * in the chain. */ -static inline void *loader_non_passthrough_gpa(const char *name) +static inline void *loader_non_passthrough_gipa(const char *name) { if (!name || name[0] != 'v' || name[1] != 'k') return NULL; @@ -336,32 +336,32 @@ static inline void *loader_non_passthrough_gpa(const char *name) return (void*) vkCreateInstance; if (!strcmp(name, "DestroyInstance")) return (void*) vkDestroyInstance; + // remove once no longer locks if (!strcmp(name, "EnumeratePhysicalDevices")) return (void*) vkEnumeratePhysicalDevices; - if (!strcmp(name, "GetPhysicalDeviceFeatures")) - return (void*) vkGetPhysicalDeviceFeatures; - if (!strcmp(name, "GetPhysicalDeviceFormatProperties")) - return (void*) vkGetPhysicalDeviceFormatProperties; - if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties")) - return (void*) vkGetPhysicalDeviceImageFormatProperties; - if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties")) - return (void*) vkGetPhysicalDeviceQueueFamilyProperties; - if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) - return (void*) vkGetPhysicalDeviceMemoryProperties; - if (!strcmp(name, "GetPhysicalDeviceProperties")) - return (void*) vkGetPhysicalDeviceProperties; - if (!strcmp(name, "GetPhysicalDeviceSparseImageFormatProperties")) - return (void*) vkGetPhysicalDeviceSparseImageFormatProperties; + if (!strcmp(name, "EnumerateDeviceExtensionProperties")) + return (void*) vkEnumerateDeviceExtensionProperties; + if (!strcmp(name, "EnumerateDeviceLayerProperties")) + return (void*) vkEnumerateDeviceLayerProperties; if (!strcmp(name, "GetInstanceProcAddr")) return (void*) vkGetInstanceProcAddr; + + return NULL; +} + +static inline void *loader_non_passthrough_gdpa(const char *name) +{ + if (!name || name[0] != 'v' || name[1] != 'k') + return NULL; + + name += 2; + if (!strcmp(name, "GetDeviceProcAddr")) return (void*) vkGetDeviceProcAddr; if (!strcmp(name, "CreateDevice")) return (void*) vkCreateDevice; - if (!strcmp(name, "EnumerateDeviceExtensionProperties")) - return (void*) vkEnumerateDeviceExtensionProperties; - if (!strcmp(name, "EnumerateDeviceLayerProperties")) - return (void*) vkEnumerateDeviceLayerProperties; + if (!strcmp(name, "DestroyDevice")) + return (void*) vkDestroyDevice; if (!strcmp(name, "GetDeviceQueue")) return (void*) vkGetDeviceQueue; if (!strcmp(name, "CreateCommandBuffer")) diff --git a/loader/loader.c b/loader/loader.c index 56b64968..6cee2a69 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -61,9 +61,6 @@ struct loader_struct loader = {0}; // TLS for instance for alloc/free callbacks THREAD_LOCAL_DECL struct loader_instance *tls_instance; -static PFN_vkVoidFunction VKAPI loader_GetInstanceProcAddr( - VkInstance instance, - const char * pName); static bool loader_init_ext_list( const struct loader_instance *inst, struct loader_extension_list *ext_info); @@ -89,7 +86,7 @@ loader_platform_thread_mutex loader_json_lock; // default functions if no instance layers are activated. This contains // pointers to "terminator functions". const VkLayerInstanceDispatchTable instance_disp = { - .GetInstanceProcAddr = loader_GetInstanceProcAddr, + .GetInstanceProcAddr = vkGetInstanceProcAddr, .CreateInstance = loader_CreateInstance, .DestroyInstance = loader_DestroyInstance, .EnumeratePhysicalDevices = loader_EnumeratePhysicalDevices, @@ -3006,26 +3003,41 @@ VkResult VKAPI loader_CreateDevice( return res; } -static PFN_vkVoidFunction VKAPI loader_GetInstanceProcAddr(VkInstance instance, const char * pName) +/** + * Get an instance level or global level entry point address. + * @param instance + * @param pName + * @return + * If instance == NULL returns a global level entrypoint for all core entry points + * If instance is valid returns a instance relative entry point for instance level + * entry points both core and extensions. + * Instance relative means call down the instance chain. Global means trampoline entry points. + */ +LOADER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr(VkInstance instance, const char * pName) { - if (instance == VK_NULL_HANDLE) - return NULL; void *addr; - /* get entrypoint addresses that are global (in the loader)*/ - addr = globalGetProcAddr(pName); - if (addr) - return addr; - struct loader_instance *ptr_instance = (struct loader_instance *) instance; + if (instance == VK_NULL_HANDLE) { + struct loader_instance *ptr_instance = (struct loader_instance *) instance; + /* get entrypoint addresses that are global (in the loader)*/ + addr = globalGetProcAddr(pName); + if (addr) + return addr; + + /* return any extension global entrypoints */ + addr = debug_report_instance_gpa(ptr_instance, pName); + if (addr) { + return addr; + } + + addr = wsi_swapchain_GetInstanceProcAddr(ptr_instance, pName); - /* return any extension global entrypoints */ - addr = debug_report_instance_gpa(ptr_instance, pName); - if (addr) { return addr; } - addr = wsi_swapchain_GetInstanceProcAddr(ptr_instance, pName); + /* return any instance entrypoints that must resolve to loader code */ + addr = loader_non_passthrough_gipa(pName); if (addr) { return addr; } @@ -3039,25 +3051,35 @@ static PFN_vkVoidFunction VKAPI loader_GetInstanceProcAddr(VkInstance instance, if (addr) return addr; + // NOTE: any instance extensions must be known to loader and resolved + // in the above call to loader_lookup_instance_dispatch_table()) return NULL; } -LOADER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr(VkInstance instance, const char * pName) +/** + * Get a device level or global level entry point address. + * @param device + * @param pName + * @return + * If device == NULL, returns a global level entrypoint for all core entry points + * 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. Global means trampoline entry points. + */ +LOADER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice device, const char * pName) { - return loader_GetInstanceProcAddr(instance, pName); -} + void *addr; -static PFN_vkVoidFunction VKAPI loader_GetDeviceProcAddr(VkDevice device, const char * pName) -{ if (device == VK_NULL_HANDLE) { - return NULL; + /* get entrypoint addresses that are global (in the loader)*/ + addr = globalGetProcAddr(pName); + return addr; } - void *addr; /* for entrypoints that loader must handle (ie non-dispatchable or create object) make sure the loader entrypoint is returned */ - addr = loader_non_passthrough_gpa(pName); + addr = loader_non_passthrough_gdpa(pName); if (addr) { return addr; } @@ -3077,11 +3099,6 @@ static PFN_vkVoidFunction VKAPI loader_GetDeviceProcAddr(VkDevice device, const } } -LOADER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice device, const char * pName) -{ - return loader_GetDeviceProcAddr(device, pName); -} - LOADER_EXPORT VkResult VKAPI vkEnumerateInstanceExtensionProperties( const char* pLayerName, uint32_t* pCount, diff --git a/loader/loader.h b/loader/loader.h index fff4205e..cd795c50 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -195,8 +195,6 @@ struct loader_struct { unsigned int loaded_layer_lib_capacity; struct loader_lib_info *loaded_layer_lib_list; // TODO add ref counting of ICD libraries - char *layer_dirs; - // TODO use this struct loader_layer_library_list scanned_layer_libraries; // TODO add list of icd libraries for ref counting them for closure }; |
