diff options
| author | Mark Young <marky@lunarg.com> | 2016-06-28 10:52:43 -0600 |
|---|---|---|
| committer | Mark Young <marky@lunarg.com> | 2016-09-19 14:52:50 -0600 |
| commit | ddca7b207067f44df0990a697b9471efdef8b066 (patch) | |
| tree | ed9a206caedb824d2ae585cf058a5e49e0a17143 /loader/loader.c | |
| parent | 93340a0ede3a328b990653cbd332c9cb2632340a (diff) | |
| download | usermoji-ddca7b207067f44df0990a697b9471efdef8b066.tar.xz | |
loader: gh181 use ICD for SurfaceKHR
Use the ICD to create and destroy VkSurfaceKHR objects instead
of just performing the work in the ICD. This only occurs if the ICD
exports the appropriate entry-points, and exposes version 3 of the
loader/icd interface.
Change-Id: I5e7bf9506318823c57ad75cf19d3f53fdfa6451e
Diffstat (limited to 'loader/loader.c')
| -rw-r--r-- | loader/loader.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/loader/loader.c b/loader/loader.c index 9323cff7..6abd4327 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -412,7 +412,7 @@ vkSetInstanceDispatch(VkInstance instance, void *object) { VKAPI_ATTR VkResult VKAPI_CALL vkSetDeviceDispatch(VkDevice device, void *object) { struct loader_device *dev; - struct loader_icd *icd = loader_get_icd_and_device(device, &dev); + struct loader_icd *icd = loader_get_icd_and_device(device, &dev, NULL); if (!icd) { return VK_ERROR_INITIALIZATION_FAILED; @@ -1243,8 +1243,10 @@ out: } struct loader_icd *loader_get_icd_and_device(const VkDevice device, - struct loader_device **found_dev) { + struct loader_device **found_dev, + uint32_t *icd_index) { *found_dev = NULL; + uint32_t index = 0; for (struct loader_instance *inst = loader.instances; inst; inst = inst->next) { for (struct loader_icd *icd = inst->icds; icd; icd = icd->next) { @@ -1255,8 +1257,12 @@ struct loader_icd *loader_get_icd_and_device(const VkDevice device, if (loader_get_dispatch(dev->device) == loader_get_dispatch(device)) { *found_dev = dev; + if (NULL != icd_index) { + *icd_index = index; + } return icd; } + index++; } } return NULL; @@ -1634,16 +1640,21 @@ static bool loader_icd_init_entrys(struct loader_icd *icd, VkInstance inst, LOOKUP_GIPA(CreateDisplayModeKHR, false); LOOKUP_GIPA(GetDisplayPlaneCapabilitiesKHR, false); LOOKUP_GIPA(DestroySurfaceKHR, false); + LOOKUP_GIPA(CreateSwapchainKHR, false); #ifdef VK_USE_PLATFORM_WIN32_KHR + LOOKUP_GIPA(CreateWin32SurfaceKHR, false); LOOKUP_GIPA(GetPhysicalDeviceWin32PresentationSupportKHR, false); #endif #ifdef VK_USE_PLATFORM_XCB_KHR + LOOKUP_GIPA(CreateXcbSurfaceKHR, false); LOOKUP_GIPA(GetPhysicalDeviceXcbPresentationSupportKHR, false); #endif #ifdef VK_USE_PLATFORM_XLIB_KHR + LOOKUP_GIPA(CreateXlibSurfaceKHR, false); LOOKUP_GIPA(GetPhysicalDeviceXlibPresentationSupportKHR, false); #endif #ifdef VK_USE_PLATFORM_WAYLAND_KHR + LOOKUP_GIPA(CreateWaylandSurfaceKHR, false); LOOKUP_GIPA(GetPhysicalDeviceWaylandPresentationSupportKHR, false); #endif LOOKUP_GIPA(GetPhysicalDeviceExternalImageFormatPropertiesNV, false); @@ -3232,10 +3243,20 @@ loader_gpa_instance_internal(VkInstance inst, const char *pName) { return NULL; } + static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpa_device_internal(VkDevice device, const char *pName) { struct loader_device *dev; - struct loader_icd *icd = loader_get_icd_and_device(device, &dev); + struct loader_icd *icd = loader_get_icd_and_device(device, &dev, NULL); + + // Certain device entry-points still need to go through a terminator before + // hitting the ICD. This could be for several reasons, but the main one + // is currently unwrapping an object before passing the appropriate info + // along to the ICD. + if (!strcmp(pName, "vkCreateSwapchainKHR")) { + return (PFN_vkVoidFunction)terminator_vkCreateSwapchainKHR; + } + return icd->GetDeviceProcAddr(device, pName); } @@ -4429,6 +4450,7 @@ terminator_EnumeratePhysicalDevices(VkInstance instance, for (j = 0; j < phys_devs[i].count && idx < copy_count; j++) { loader_set_dispatch((void *)&inst->phys_devs_term[idx], inst->disp); inst->phys_devs_term[idx].this_icd = phys_devs[i].this_icd; + inst->phys_devs_term[idx].icd_index = i; inst->phys_devs_term[idx].phys_dev = phys_devs[i].phys_devs[j]; pPhysicalDevices[idx] = (VkPhysicalDevice)&inst->phys_devs_term[idx]; |
