diff options
| author | Courtney Goeltzenleuchter <courtneygo@google.com> | 2016-01-08 12:18:43 -0700 |
|---|---|---|
| committer | Jon Ashburn <jon@lunarg.com> | 2016-01-20 18:04:55 -0700 |
| commit | a1de4b2dffb98222ca59f4a70c301d22bb4c089e (patch) | |
| tree | b5d9e5235b444d8995f2c122637280b8e32ef72d /layers/multi.cpp | |
| parent | e974568a65f7243dbc1eeb69d94174d0563c9d65 (diff) | |
| download | usermoji-a1de4b2dffb98222ca59f4a70c301d22bb4c089e.tar.xz | |
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
Diffstat (limited to 'layers/multi.cpp')
| -rw-r--r-- | layers/multi.cpp | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/layers/multi.cpp b/layers/multi.cpp index c5d9d1b5..3bbea8c5 100644 --- a/layers/multi.cpp +++ b/layers/multi.cpp @@ -80,28 +80,22 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL multi1CreateGraphicsPipelines( VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL multi1GetDeviceProcAddr(VkDevice device, const char* pName) { - - if (device == NULL) - return NULL; - - /* loader uses this to force layer initialization; device object is wrapped */ - if (!strcmp(pName, "multi1GetDeviceProcAddr") || !strcmp(pName, "vkGetDeviceProcAddr")) { - initDeviceTable(multi1_device_table_map, (const VkBaseLayerObject *) device); + if (!strcmp(pName, "multi1GetDeviceProcAddr") || !strcmp(pName, "vkGetDeviceProcAddr")) return (PFN_vkVoidFunction) multi1GetDeviceProcAddr; - } - if (!strcmp("vkDestroyDevice", pName)) return (PFN_vkVoidFunction) multi1DestroyDevice; if (!strcmp("vkCreateSampler", pName)) return (PFN_vkVoidFunction) multi1CreateSampler; if (!strcmp("vkCreateGraphicsPipelines", pName)) return (PFN_vkVoidFunction) multi1CreateGraphicsPipelines; - else { - VkLayerDispatchTable *pTable = get_dispatch_table(multi1_device_table_map, device); - if (pTable->GetDeviceProcAddr == NULL) - return NULL; - return pTable->GetDeviceProcAddr(device, pName); - } + + if (device == NULL) + return NULL; + + VkLayerDispatchTable *pTable = get_dispatch_table(multi1_device_table_map, device); + if (pTable->GetDeviceProcAddr == NULL) + return NULL; + return pTable->GetDeviceProcAddr(device, pName); } @@ -154,15 +148,8 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL multi2DestroyInstance(VkInstance inst VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL multi2GetInstanceProcAddr(VkInstance inst, const char* pName) { - if (inst == NULL) - return NULL; - - /* loader uses this to force layer initialization; device object is wrapped */ - if (!strcmp(pName, "multi2GetInstanceProcAddr") || !strcmp(pName, "vkGetInstanceProcAddr")) { - initInstanceTable(multi2_instance_table_map, (const VkBaseLayerObject *) inst); + if (!strcmp(pName, "multi2GetInstanceProcAddr") || !strcmp(pName, "vkGetInstanceProcAddr")) return (PFN_vkVoidFunction) multi2GetInstanceProcAddr; - } - if (!strcmp("vkEnumeratePhysicalDevices", pName)) return (PFN_vkVoidFunction) multi2EnumeratePhysicalDevices; if (!strcmp("GetPhysicalDeviceProperties", pName)) @@ -171,12 +158,14 @@ VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL multi2GetInstanceProcAd return (PFN_vkVoidFunction) multi2GetPhysicalDeviceFeatures; if (!strcmp("vkDestroyInstance", pName)) return (PFN_vkVoidFunction) multi2DestroyInstance; - else { - VkLayerInstanceDispatchTable *pTable = get_dispatch_table(multi2_instance_table_map, inst); - if (pTable->GetInstanceProcAddr == NULL) - return NULL; - return pTable->GetInstanceProcAddr(inst, pName); - } + + if (inst == NULL) + return NULL; + + VkLayerInstanceDispatchTable *pTable = get_dispatch_table(multi2_instance_table_map, inst); + if (pTable->GetInstanceProcAddr == NULL) + return NULL; + return pTable->GetInstanceProcAddr(inst, pName); } #ifdef __cplusplus |
