aboutsummaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorJon Ashburn <jon@lunarg.com>2015-05-28 16:25:02 -0600
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-06-17 20:56:36 -0600
commit0d67c29d5d2a2f3383e11279a091a1f164f8eb95 (patch)
treee3e1ccc09ecdb9eba13aff5c12ca748787742e84 /loader
parent813d8d2445d30223a6f46ccf4806f9e41754b333 (diff)
downloadusermoji-0d67c29d5d2a2f3383e11279a091a1f164f8eb95.tar.xz
loader: Support layers that don't have an extension entrypoint
Change all layers and loader interface to init dispatch tables on GPA("GetXXXProcAddr"). After that initialization rest of dispatch tables are inited via unwrapped object using the GPA in the dispatch table. This also allows App generated GPA calls that the loader can't resolve to function correctly.
Diffstat (limited to 'loader')
-rw-r--r--loader/loader.c15
-rw-r--r--loader/loader.h7
-rw-r--r--loader/table_ops.h23
3 files changed, 19 insertions, 26 deletions
diff --git a/loader/loader.c b/loader/loader.c
index 064b3dca..fd234657 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -820,14 +820,12 @@ static void* VKAPI loader_gpa_instance_internal(VkInstance inst, const char * pN
VkLayerInstanceDispatchTable* disp_table = * (VkLayerInstanceDispatchTable **) inst;
void *addr;
+ if (!strcmp(pName, "vkGetInstanceProcAddr"))
+ return (void *) loader_gpa_instance_internal;
+
if (disp_table == NULL)
return NULL;
-// addr = debug_report_instance_gpa((struct loader_instance *) inst, pName);
-// if (addr) {
-// return addr;
-// }
-
addr = loader_lookup_instance_dispatch_table(disp_table, pName);
if (addr) {
return addr;
@@ -1138,7 +1136,7 @@ uint32_t loader_activate_instance_layers(struct loader_instance *inst)
layer_idx--;
}
- loader_init_instance_core_dispatch_table(inst->disp, nextGPA, (VkInstance) nextObj);
+ loader_init_instance_core_dispatch_table(inst->disp, nextGPA, (VkInstance) nextObj, (VkInstance) baseObj);
return inst->layer_count;
}
@@ -1225,7 +1223,8 @@ extern uint32_t loader_activate_device_layers(
layer_idx--;
}
- loader_init_device_dispatch_table(icd->loader_dispatch + gpu_index, nextGPA, (VkPhysicalDevice) nextObj);
+ loader_init_device_dispatch_table(icd->loader_dispatch + gpu_index, nextGPA,
+ (VkPhysicalDevice) nextObj, (VkPhysicalDevice) baseObj);
} else {
// TODO: Check that active layers match requested?
}
@@ -1370,7 +1369,7 @@ VkResult loader_EnumeratePhysicalDevices(
(wrapped_gpus + i)->nextObject = gpus[i];
memcpy(pPhysicalDevices + count, gpus, sizeof(*pPhysicalDevices));
loader_init_device_dispatch_table(icd->loader_dispatch + i,
- get_proc_addr, gpus[i]);
+ get_proc_addr, gpus[i], gpus[i]);
loader_init_dispatch(gpus[i], ptr_instance->disp);
}
diff --git a/loader/loader.h b/loader/loader.h
index 73b780fd..8b427b5f 100644
--- a/loader/loader.h
+++ b/loader/loader.h
@@ -321,13 +321,6 @@ VkResult loader_GetPhysicalDeviceExtensionInfo(
size_t* pDataSize,
void* pData);
-VkResult loader_EnumerateLayers(
- VkPhysicalDevice gpu,
- size_t maxStringSize,
- size_t* pLayerCount,
- char* const* pOutLayers,
- void* pReserved);
-
VkResult loader_GetMultiDeviceCompatibility(
VkPhysicalDevice gpu0,
VkPhysicalDevice gpu1,
diff --git a/loader/table_ops.h b/loader/table_ops.h
index 1fb624bc..93131b18 100644
--- a/loader/table_ops.h
+++ b/loader/table_ops.h
@@ -30,9 +30,13 @@
static inline void loader_init_device_dispatch_table(VkLayerDispatchTable *table,
PFN_vkGetDeviceProcAddr gpa,
+ VkDevice dev_next,
VkDevice dev)
{
- table->GetDeviceProcAddr = gpa;
+ // 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->DestroyDevice = (PFN_vkDestroyDevice) gpa(dev, "vkDestroyDevice");
table->GetDeviceQueue = (PFN_vkGetDeviceQueue) gpa(dev, "vkGetDeviceQueue");
table->QueueSubmit = (PFN_vkQueueSubmit) gpa(dev, "vkQueueSubmit");
@@ -137,6 +141,8 @@ static inline void loader_init_device_dispatch_table(VkLayerDispatchTable *table
table->CmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) gpa(dev, "vkCmdBeginRenderPass");
table->CmdEndRenderPass = (PFN_vkCmdEndRenderPass) gpa(dev, "vkCmdEndRenderPass");
//TODO move into it's own table
+//TODO also consider dropping trampoline code for these device level extensions entirely
+// then don't need loader to know about these at all but then not queryable via GIPA
table->CreateSwapChainWSI = (PFN_vkCreateSwapChainWSI) gpa(dev, "vkCreateSwapChainWSI");
table->DestroySwapChainWSI = (PFN_vkDestroySwapChainWSI) gpa(dev, "vkDestroySwapChainWSI");
table->GetSwapChainInfoWSI = (PFN_vkGetSwapChainInfoWSI) gpa(dev, "vkGetSwapChainInfoWSI");
@@ -359,28 +365,23 @@ static inline void *loader_lookup_device_dispatch_table(
return (void *) table->CmdBeginRenderPass;
if (!strcmp(name, "CmdEndRenderPass"))
return (void *) table->CmdEndRenderPass;
-//TODO put in it's own table
- if (!strcmp(name, "CreateSwapChainWSI"))
- return (void *) table->CreateSwapChainWSI;
- if (!strcmp(name, "DestroySwapChainWSI"))
- return (void *) table->DestroySwapChainWSI;
- if (!strcmp(name, "GetSwapChainInfoWSI"))
- return (void *) table->GetSwapChainInfoWSI;
- if (!strcmp(name, "QueuePresentWSI"))
- return (void *) table->QueuePresentWSI;
return NULL;
}
static inline void loader_init_instance_core_dispatch_table(VkLayerInstanceDispatchTable *table,
PFN_vkGetInstanceProcAddr gpa,
+ VkInstance inst_next,
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->CreateInstance = (PFN_vkCreateInstance) gpa(inst, "vkCreateInstance");
table->DestroyInstance = (PFN_vkDestroyInstance) gpa(inst, "vkDestroyInstance");
table->EnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) gpa(inst, "vkEnumeratePhysicalDevices");
table->GetPhysicalDeviceInfo = (PFN_vkGetPhysicalDeviceInfo) gpa(inst, "vkGetPhysicalDeviceInfo");
- table->GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) gpa(inst, "vkGetInstanceProcAddr");
table->CreateDevice = (PFN_vkCreateDevice) gpa(inst, "vkCreateDevice");
table->GetGlobalExtensionInfo = (PFN_vkGetGlobalExtensionInfo) gpa(inst,"vkGetGlobalExtensionInfo");
table->GetPhysicalDeviceExtensionInfo = (PFN_vkGetPhysicalDeviceExtensionInfo) gpa(inst, "vkGetPhysicalDeviceExtensionInfo");