@@ -105,20 +105,14 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2E
105105 struct loader_physical_device_term * phys_dev_term = (struct loader_physical_device_term * )physicalDevice ;
106106 struct loader_icd_term * icd_term = phys_dev_term -> this_icd_term ;
107107
108- VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )(surface );
109-
110- // Unwrap the surface if needed
111- VkSurfaceKHR unwrapped_surface = surface ;
112- if (NULL != phys_dev_term -> this_icd_term -> surface_list .list &&
113- phys_dev_term -> this_icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
114- phys_dev_term -> this_icd_term -> surface_list .list [icd_surface -> surface_index ]) {
115- unwrapped_surface = phys_dev_term -> this_icd_term -> surface_list .list [icd_surface -> surface_index ];
108+ VkResult res = wsi_unwrap_icd_surface (icd_term , & surface );
109+ if (res != VK_SUCCESS ) {
110+ return res ;
116111 }
117112
118113 if (NULL != icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilities2EXT ) {
119114 // Pass the call to the driver
120- return icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilities2EXT (phys_dev_term -> phys_dev , unwrapped_surface ,
121- pSurfaceCapabilities );
115+ return icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilities2EXT (phys_dev_term -> phys_dev , surface , pSurfaceCapabilities );
122116 } else {
123117 // Emulate the call
124118 loader_log (icd_term -> this_instance , VULKAN_LOADER_INFO_BIT , 0 ,
@@ -127,8 +121,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2E
127121 icd_term -> scanned_icd -> lib_name );
128122
129123 VkSurfaceCapabilitiesKHR surface_caps ;
130- VkResult res =
131- icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilitiesKHR (phys_dev_term -> phys_dev , unwrapped_surface , & surface_caps );
124+ res = icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilitiesKHR (phys_dev_term -> phys_dev , surface , & surface_caps );
132125 pSurfaceCapabilities -> minImageCount = surface_caps .minImageCount ;
133126 pSurfaceCapabilities -> maxImageCount = surface_caps .maxImageCount ;
134127 pSurfaceCapabilities -> currentExtent = surface_caps .currentExtent ;
@@ -274,21 +267,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModes2E
274267 "ICD associated with VkPhysicalDevice does not support GetPhysicalDeviceSurfacePresentModes2EXT" );
275268 abort ();
276269 }
270+
271+ VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy = * pSurfaceInfo ;
277272 if (VK_NULL_HANDLE != pSurfaceInfo -> surface ) {
278- VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )(pSurfaceInfo -> surface );
279- if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
280- icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
281- icd_term -> surface_list .list [icd_surface -> surface_index ]) {
282- VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy ;
283- surface_info_copy .sType = pSurfaceInfo -> sType ;
284- surface_info_copy .pNext = pSurfaceInfo -> pNext ;
285- surface_info_copy .surface = icd_term -> surface_list .list [icd_surface -> surface_index ];
286- return icd_term -> dispatch .GetPhysicalDeviceSurfacePresentModes2EXT (phys_dev_term -> phys_dev , & surface_info_copy ,
287- pPresentModeCount , pPresentModes );
273+ VkResult res = wsi_unwrap_icd_surface (icd_term , & surface_info_copy .surface );
274+ if (res != VK_SUCCESS ) {
275+ return res ;
288276 }
289277 }
290- return icd_term -> dispatch .GetPhysicalDeviceSurfacePresentModes2EXT (phys_dev_term -> phys_dev , pSurfaceInfo , pPresentModeCount ,
291- pPresentModes );
278+
279+ return icd_term -> dispatch .GetPhysicalDeviceSurfacePresentModes2EXT (phys_dev_term -> phys_dev , & surface_info_copy ,
280+ pPresentModeCount , pPresentModes );
292281}
293282
294283VKAPI_ATTR VkResult VKAPI_CALL GetDeviceGroupSurfacePresentModes2EXT (VkDevice device ,
@@ -323,20 +312,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModes2EXT(
323312 "[VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter]" );
324313 abort (); /* Intentionally fail so user can correct issue. */
325314 }
315+
316+ VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy = * pSurfaceInfo ;
326317 if (VK_NULL_HANDLE != pSurfaceInfo -> surface ) {
327- VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )(pSurfaceInfo -> surface );
328- if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
329- icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
330- icd_term -> surface_list .list [icd_surface -> surface_index ]) {
331- VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy ;
332- surface_info_copy .sType = pSurfaceInfo -> sType ;
333- surface_info_copy .pNext = pSurfaceInfo -> pNext ;
334- surface_info_copy .surface = icd_term -> surface_list .list [icd_surface -> surface_index ];
335- return dev -> loader_dispatch .extension_terminator_dispatch .GetDeviceGroupSurfacePresentModes2EXT (
336- device , & surface_info_copy , pModes );
318+ VkResult res = wsi_unwrap_icd_surface (icd_term , & surface_info_copy .surface );
319+ if (res != VK_SUCCESS ) {
320+ return res ;
337321 }
338322 }
339- return dev -> loader_dispatch .extension_terminator_dispatch .GetDeviceGroupSurfacePresentModes2EXT (device , pSurfaceInfo , pModes );
323+
324+ return dev -> loader_dispatch .extension_terminator_dispatch .GetDeviceGroupSurfacePresentModes2EXT (device , & surface_info_copy ,
325+ pModes );
340326}
341327
342328#endif // VK_USE_PLATFORM_WIN32_KHR
0 commit comments