@@ -366,15 +366,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(VkP
366366 return VK_SUCCESS ;
367367 }
368368
369- VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )surface ;
370- if (NULL != phys_dev_term -> this_icd_term -> surface_list .list &&
371- phys_dev_term -> this_icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
372- phys_dev_term -> this_icd_term -> surface_list .list [icd_surface -> surface_index ]) {
373- return icd_term -> dispatch .GetPhysicalDeviceSurfaceFormatsKHR (
374- phys_dev_term -> phys_dev , phys_dev_term -> this_icd_term -> surface_list .list [icd_surface -> surface_index ],
375- pSurfaceFormatCount , pSurfaceFormats );
369+ if (VK_NULL_HANDLE != surface ) {
370+ VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )surface ;
371+ if (NULL != phys_dev_term -> this_icd_term -> surface_list .list &&
372+ phys_dev_term -> this_icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
373+ phys_dev_term -> this_icd_term -> surface_list .list [icd_surface -> surface_index ]) {
374+ return icd_term -> dispatch .GetPhysicalDeviceSurfaceFormatsKHR (
375+ phys_dev_term -> phys_dev , phys_dev_term -> this_icd_term -> surface_list .list [icd_surface -> surface_index ],
376+ pSurfaceFormatCount , pSurfaceFormats );
377+ }
376378 }
377-
378379 return icd_term -> dispatch .GetPhysicalDeviceSurfaceFormatsKHR (phys_dev_term -> phys_dev , surface , pSurfaceFormatCount ,
379380 pSurfaceFormats );
380381}
@@ -424,16 +425,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModesKH
424425 "ICD for selected physical device does not export vkGetPhysicalDeviceSurfacePresentModesKHR!" );
425426 return VK_SUCCESS ;
426427 }
428+ if (VK_NULL_HANDLE != surface ) {
429+ VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )surface ;
427430
428- VkIcdSurface * icd_surface = ( VkIcdSurface * )( uintptr_t ) surface ;
429- if ( NULL != phys_dev_term -> this_icd_term -> surface_list .list &&
430- phys_dev_term -> this_icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof ( VkSurfaceKHR ) &&
431- phys_dev_term -> this_icd_term -> surface_list . list [ icd_surface -> surface_index ]) {
432- return icd_term -> dispatch . GetPhysicalDeviceSurfacePresentModesKHR (
433- phys_dev_term -> phys_dev , phys_dev_term -> this_icd_term -> surface_list . list [ icd_surface -> surface_index ], pPresentModeCount ,
434- pPresentModes );
431+ if ( icd_surface != NULL && NULL != phys_dev_term -> this_icd_term -> surface_list . list &&
432+ phys_dev_term -> this_icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof ( VkSurfaceKHR ) &&
433+ phys_dev_term -> this_icd_term -> surface_list .list [ icd_surface -> surface_index ]) {
434+ return icd_term -> dispatch . GetPhysicalDeviceSurfacePresentModesKHR (
435+ phys_dev_term -> phys_dev , phys_dev_term -> this_icd_term -> surface_list . list [ icd_surface -> surface_index ],
436+ pPresentModeCount , pPresentModes );
437+ }
435438 }
436-
437439 return icd_term -> dispatch .GetPhysicalDeviceSurfacePresentModesKHR (phys_dev_term -> phys_dev , surface , pPresentModeCount ,
438440 pPresentModes );
439441}
@@ -2497,7 +2499,10 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2K
24972499 struct loader_physical_device_term * phys_dev_term = (struct loader_physical_device_term * )physicalDevice ;
24982500 struct loader_icd_term * icd_term = phys_dev_term -> this_icd_term ;
24992501 struct loader_instance * loader_inst = (struct loader_instance * )icd_term -> this_instance ;
2500- VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )pSurfaceInfo -> surface ;
2502+ VkIcdSurface * icd_surface = NULL ;
2503+ if (pSurfaceInfo -> surface ) {
2504+ icd_surface = (VkIcdSurface * )(uintptr_t )pSurfaceInfo -> surface ;
2505+ }
25012506
25022507 if (!loader_inst -> wsi_surface_enabled ) {
25032508 loader_log (loader_inst , VULKAN_LOADER_ERROR_BIT , 0 ,
@@ -2522,7 +2527,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2K
25222527 VkResult res = VK_SUCCESS ;
25232528
25242529 // Pass the call to the driver, possibly unwrapping the ICD surface
2525- if (NULL != icd_term -> surface_list .list &&
2530+ if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
25262531 icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
25272532 icd_term -> surface_list .list [icd_surface -> surface_index ]) {
25282533 VkPhysicalDeviceSurfaceInfo2KHR info_copy = * pSurfaceInfo ;
@@ -2549,8 +2554,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2K
25492554 icd_term -> scanned_icd -> lib_name );
25502555
25512556 // Write to the VkSurfaceCapabilities2KHR struct
2552- VkSurfaceKHR surface = pSurfaceInfo -> surface ;
2553- if (NULL != icd_term -> surface_list .list &&
2557+ VkSurfaceKHR surface = VK_NULL_HANDLE ;
2558+ if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
25542559 icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
25552560 icd_term -> surface_list .list [icd_surface -> surface_index ]) {
25562561 surface = icd_term -> surface_list .list [icd_surface -> surface_index ];
@@ -2600,11 +2605,14 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(Vk
26002605 return VK_SUCCESS ;
26012606 }
26022607
2603- VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )(pSurfaceInfo -> surface );
2608+ VkIcdSurface * icd_surface = NULL ;
2609+ if (VK_NULL_HANDLE != pSurfaceInfo -> surface ) {
2610+ icd_surface = (VkIcdSurface * )(uintptr_t )(pSurfaceInfo -> surface );
2611+ }
26042612
26052613 if (icd_term -> dispatch .GetPhysicalDeviceSurfaceFormats2KHR != NULL ) {
26062614 // Pass the call to the driver, possibly unwrapping the ICD surface
2607- if (NULL != icd_term -> surface_list .list &&
2615+ if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
26082616 icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
26092617 icd_term -> surface_list .list [icd_surface -> surface_index ]) {
26102618 VkPhysicalDeviceSurfaceInfo2KHR info_copy = * pSurfaceInfo ;
@@ -2628,7 +2636,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(Vk
26282636 }
26292637
26302638 VkSurfaceKHR surface = pSurfaceInfo -> surface ;
2631- if (NULL != icd_term -> surface_list .list &&
2639+ if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
26322640 icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
26332641 icd_term -> surface_list .list [icd_surface -> surface_index ]) {
26342642 surface = icd_term -> surface_list .list [icd_surface -> surface_index ];
0 commit comments