@@ -104,21 +104,14 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2E
104104 VkPhysicalDevice physicalDevice , VkSurfaceKHR surface , VkSurfaceCapabilities2EXT * pSurfaceCapabilities ) {
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 ;
107-
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 ];
107+ VkResult res = wsi_unwrap_icd_surface (icd_term , & surface );
108+ if (res != VK_SUCCESS ) {
109+ return res ;
116110 }
117111
118112 if (NULL != icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilities2EXT ) {
119113 // Pass the call to the driver
120- return icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilities2EXT (phys_dev_term -> phys_dev , unwrapped_surface ,
121- pSurfaceCapabilities );
114+ return icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilities2EXT (phys_dev_term -> phys_dev , surface , pSurfaceCapabilities );
122115 } else {
123116 // Emulate the call
124117 loader_log (icd_term -> this_instance , VULKAN_LOADER_INFO_BIT , 0 ,
@@ -127,8 +120,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2E
127120 icd_term -> scanned_icd -> lib_name );
128121
129122 VkSurfaceCapabilitiesKHR surface_caps ;
130- VkResult res =
131- icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilitiesKHR (phys_dev_term -> phys_dev , unwrapped_surface , & surface_caps );
123+ res = icd_term -> dispatch .GetPhysicalDeviceSurfaceCapabilitiesKHR (phys_dev_term -> phys_dev , surface , & surface_caps );
132124 pSurfaceCapabilities -> minImageCount = surface_caps .minImageCount ;
133125 pSurfaceCapabilities -> maxImageCount = surface_caps .maxImageCount ;
134126 pSurfaceCapabilities -> currentExtent = surface_caps .currentExtent ;
@@ -274,21 +266,15 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModes2E
274266 "ICD associated with VkPhysicalDevice does not support GetPhysicalDeviceSurfacePresentModes2EXT" );
275267 abort ();
276268 }
277- 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 );
288- }
269+
270+ VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy = * pSurfaceInfo ;
271+ VkResult res = wsi_unwrap_icd_surface (icd_term , & surface_info_copy .surface );
272+ if (res != VK_SUCCESS ) {
273+ return res ;
289274 }
290- return icd_term -> dispatch .GetPhysicalDeviceSurfacePresentModes2EXT (phys_dev_term -> phys_dev , pSurfaceInfo , pPresentModeCount ,
291- pPresentModes );
275+
276+ return icd_term -> dispatch .GetPhysicalDeviceSurfacePresentModes2EXT (phys_dev_term -> phys_dev , & surface_info_copy ,
277+ pPresentModeCount , pPresentModes );
292278}
293279
294280VKAPI_ATTR VkResult VKAPI_CALL GetDeviceGroupSurfacePresentModes2EXT (VkDevice device ,
@@ -323,20 +309,15 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModes2EXT(
323309 "[VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter]" );
324310 abort (); /* Intentionally fail so user can correct issue. */
325311 }
326- 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 );
337- }
312+
313+ VkPhysicalDeviceSurfaceInfo2KHR surface_info_copy = * pSurfaceInfo ;
314+ VkResult res = wsi_unwrap_icd_surface (icd_term , & surface_info_copy .surface );
315+ if (res != VK_SUCCESS ) {
316+ return res ;
338317 }
339- return dev -> loader_dispatch .extension_terminator_dispatch .GetDeviceGroupSurfacePresentModes2EXT (device , pSurfaceInfo , pModes );
318+
319+ return dev -> loader_dispatch .extension_terminator_dispatch .GetDeviceGroupSurfacePresentModes2EXT (device , & surface_info_copy ,
320+ pModes );
340321}
341322
342323#endif // VK_USE_PLATFORM_WIN32_KHR
0 commit comments