aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLenny Komow <lenny@lunarg.com>2017-10-11 15:39:38 -0600
committerMike Schuchardt <mikes@lunarg.com>2018-03-09 13:54:31 -0700
commit53fdfb2aef1d0f93fcd7c5d449b713c112503170 (patch)
tree24e4189397bbc799bf8ed3606a04f450eae7063b
parent91f1ab0bd1e329f6a648cfbe5a270b648f59a579 (diff)
downloadusermoji-53fdfb2aef1d0f93fcd7c5d449b713c112503170.tar.xz
loader: Fix crash in VK_KHR_surface
The VkSurfaceKHR object in vkGetDeviceGroupSurfacePresentModesKHR was not getting properly unwrapped. As a result, an invalid surface handle was being passed to the drivers (usually resulting in a crash).
-rw-r--r--loader/wsi.c17
-rw-r--r--loader/wsi.h5
2 files changed, 22 insertions, 0 deletions
diff --git a/loader/wsi.c b/loader/wsi.c
index 44ddfc24..e822fe7a 100644
--- a/loader/wsi.c
+++ b/loader/wsi.c
@@ -1540,6 +1540,23 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes
return disp->GetDeviceGroupSurfacePresentModesKHR(device, surface, pModes);
}
+VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModesKHR(
+ VkDevice device,
+ VkSurfaceKHR surface,
+ VkDeviceGroupPresentModeFlagsKHR* pModes) {
+ uint32_t icd_index = 0;
+ struct loader_device *dev;
+ struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index);
+ if (NULL != icd_term && NULL != icd_term->dispatch.GetDeviceGroupSurfacePresentModesKHR) {
+ VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface;
+ if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) {
+ return icd_term->dispatch.GetDeviceGroupSurfacePresentModesKHR(device, icd_surface->real_icd_surfaces[icd_index], pModes);
+ }
+ return icd_term->dispatch.GetDeviceGroupSurfacePresentModesKHR(device, surface, pModes);
+ }
+ return VK_SUCCESS;
+}
+
LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR(
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
diff --git a/loader/wsi.h b/loader/wsi.h
index edfe03a1..cc8abed6 100644
--- a/loader/wsi.h
+++ b/loader/wsi.h
@@ -81,6 +81,11 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModesKH
VkSurfaceKHR surface, uint32_t *pPresentModeCount,
VkPresentModeKHR *pPresentModes);
+VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModesKHR(
+ VkDevice device,
+ VkSurfaceKHR surface,
+ VkDeviceGroupPresentModeFlagsKHR* pModes);
+
#ifdef VK_USE_PLATFORM_WIN32_KHR
VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);