@@ -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}
@@ -2501,7 +2503,10 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2K
25012503 struct loader_physical_device_term * phys_dev_term = (struct loader_physical_device_term * )physicalDevice ;
25022504 struct loader_icd_term * icd_term = phys_dev_term -> this_icd_term ;
25032505 struct loader_instance * loader_inst = (struct loader_instance * )icd_term -> this_instance ;
2504- VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )pSurfaceInfo -> surface ;
2506+ VkIcdSurface * icd_surface = NULL ;
2507+ if (pSurfaceInfo -> surface ) {
2508+ icd_surface = (VkIcdSurface * )(uintptr_t )pSurfaceInfo -> surface ;
2509+ }
25052510
25062511 if (!loader_inst -> wsi_surface_enabled ) {
25072512 loader_log (loader_inst , VULKAN_LOADER_ERROR_BIT , 0 ,
@@ -2526,7 +2531,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2K
25262531 VkResult res = VK_SUCCESS ;
25272532
25282533 // Pass the call to the driver, possibly unwrapping the ICD surface
2529- if (NULL != icd_term -> surface_list .list &&
2534+ if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
25302535 icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
25312536 icd_term -> surface_list .list [icd_surface -> surface_index ]) {
25322537 VkPhysicalDeviceSurfaceInfo2KHR info_copy = * pSurfaceInfo ;
@@ -2553,8 +2558,8 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2K
25532558 icd_term -> scanned_icd -> lib_name );
25542559
25552560 // Write to the VkSurfaceCapabilities2KHR struct
2556- VkSurfaceKHR surface = pSurfaceInfo -> surface ;
2557- if (NULL != icd_term -> surface_list .list &&
2561+ VkSurfaceKHR surface = VK_NULL_HANDLE ;
2562+ if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
25582563 icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
25592564 icd_term -> surface_list .list [icd_surface -> surface_index ]) {
25602565 surface = icd_term -> surface_list .list [icd_surface -> surface_index ];
@@ -2604,11 +2609,14 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(Vk
26042609 return VK_SUCCESS ;
26052610 }
26062611
2607- VkIcdSurface * icd_surface = (VkIcdSurface * )(uintptr_t )(pSurfaceInfo -> surface );
2612+ VkIcdSurface * icd_surface = NULL ;
2613+ if (VK_NULL_HANDLE != pSurfaceInfo -> surface ) {
2614+ icd_surface = (VkIcdSurface * )(uintptr_t )(pSurfaceInfo -> surface );
2615+ }
26082616
26092617 if (icd_term -> dispatch .GetPhysicalDeviceSurfaceFormats2KHR != NULL ) {
26102618 // Pass the call to the driver, possibly unwrapping the ICD surface
2611- if (NULL != icd_term -> surface_list .list &&
2619+ if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
26122620 icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
26132621 icd_term -> surface_list .list [icd_surface -> surface_index ]) {
26142622 VkPhysicalDeviceSurfaceInfo2KHR info_copy = * pSurfaceInfo ;
@@ -2632,7 +2640,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(Vk
26322640 }
26332641
26342642 VkSurfaceKHR surface = pSurfaceInfo -> surface ;
2635- if (NULL != icd_term -> surface_list .list &&
2643+ if (NULL != icd_surface && NULL != icd_term -> surface_list .list &&
26362644 icd_term -> surface_list .capacity > icd_surface -> surface_index * sizeof (VkSurfaceKHR ) &&
26372645 icd_term -> surface_list .list [icd_surface -> surface_index ]) {
26382646 surface = icd_term -> surface_list .list [icd_surface -> surface_index ];
0 commit comments