* 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;
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"))
// 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);
// 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,
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;
}
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;
}
}
}
-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,