From a1de4b2dffb98222ca59f4a70c301d22bb4c089e Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Fri, 8 Jan 2016 12:18:43 -0700 Subject: loader: implement new layer init method New layer init method requires the construction of Link information for CreateInstance and CreateDevice that is accessible to layers via the CreateInfo.pNext pointer. The layer can then use the Get*ProcAddr from the Link structure to initialize their dispatch table if the call down the chain returns successfully. This removes the need to do special initialization work at Get*ProcAddr time. Layer Get*ProcAddr now return their internal function pointers regardless of the value of instance or device. Only need to have valid instance & device when looking up extensions or when passing the request down the chain. This mechanism allows us to remove object wrapping used by the loader previously. Also simplifies the dispatch table setup. Conflicts: layers/device_limits.cpp layers/draw_state.cpp loader/loader.c loader/trampoline.c --- loader/table_ops.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'loader/table_ops.h') diff --git a/loader/table_ops.h b/loader/table_ops.h index 1577409c..1ddef206 100644 --- a/loader/table_ops.h +++ b/loader/table_ops.h @@ -38,17 +38,14 @@ static VkResult vkDevExtError(VkDevice dev) static inline void loader_init_device_dispatch_table(struct loader_dev_dispatch_table *dev_table, PFN_vkGetDeviceProcAddr gpa, - VkDevice dev_next, VkDevice dev) { VkLayerDispatchTable *table = &dev_table->core_dispatch; for (uint32_t i = 0; i < MAX_NUM_DEV_EXTS; i++) dev_table->ext_dispatch.DevExt[i] = (PFN_vkDevExt) vkDevExtError; - // If layer is next, this will trigger layers to initialize their dispatch tables - //then use the gpa in their dispatch for subsequent layers in the chain - table->GetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) gpa(dev_next, "vkGetDeviceProcAddr"); - table->CreateDevice = (PFN_vkCreateDevice) gpa(dev, "vkCreateDevice"); + table->GetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) gpa(dev, "vkGetDeviceProcAddr"); +// table->CreateDevice = (PFN_vkCreateDevice) gpa(dev, "vkCreateDevice"); table->DestroyDevice = (PFN_vkDestroyDevice) gpa(dev, "vkDestroyDevice"); table->GetDeviceQueue = (PFN_vkGetDeviceQueue) gpa(dev, "vkGetDeviceQueue"); table->QueueSubmit = (PFN_vkQueueSubmit) gpa(dev, "vkQueueSubmit"); @@ -194,8 +191,8 @@ static inline void *loader_lookup_device_dispatch_table( name += 2; if (!strcmp(name, "GetDeviceProcAddr")) return (void *) table->GetDeviceProcAddr; - if (!strcmp(name, "CreateDevice")) - return (void *) table->CreateDevice; +// if (!strcmp(name, "CreateDevice")) +// return (void *) table->CreateDevice; if (!strcmp(name, "DestroyDevice")) return (void *) table->DestroyDevice; if (!strcmp(name, "GetDeviceQueue")) @@ -440,17 +437,15 @@ static inline void *loader_lookup_device_dispatch_table( return NULL; } -static inline void loader_init_instance_core_dispatch_table(VkLayerInstanceDispatchTable *table, - PFN_vkGetInstanceProcAddr gpa, - VkInstance inst_next, - VkInstance inst) +static inline void loader_init_instance_core_dispatch_table( + VkLayerInstanceDispatchTable *table, + PFN_vkGetInstanceProcAddr gpa, + VkInstance inst) { - // If layer is next, this will trigger layers to initialize their dispatch tables - //then use the gpa in their dispatch for subsequent layers in the chain - table->GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) gpa(inst_next, "vkGetInstanceProcAddr"); - + table->GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) gpa(inst, "vkGetInstanceProcAddr"); table->CreateInstance = (PFN_vkCreateInstance) gpa(inst, "vkCreateInstance"); table->DestroyInstance = (PFN_vkDestroyInstance) gpa(inst, "vkDestroyInstance"); + table->CreateDevice = (PFN_vkCreateDevice) gpa(inst, "vkCreateDevice"); table->EnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) gpa(inst, "vkEnumeratePhysicalDevices"); table->GetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) gpa(inst, "vkGetPhysicalDeviceFeatures"); table->GetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties) gpa(inst, "vkGetPhysicalDeviceImageFormatProperties"); @@ -510,6 +505,8 @@ static inline void *loader_lookup_instance_dispatch_table( return (void *) table->CreateInstance; if (!strcmp(name, "DestroyInstance")) return (void *) table->DestroyInstance; + if (!strcmp(name, "CreateDevice")) + return (void *) table->CreateDevice; if (!strcmp(name, "EnumeratePhysicalDevices")) return (void *) table->EnumeratePhysicalDevices; if (!strcmp(name, "GetPhysicalDeviceFeatures")) -- cgit v1.2.3