@@ -155,6 +155,15 @@ VkResult FillCountPtr(std::vector<T> const& data_vec, uint32_t* pCount, T* pData
155155 return VK_SUCCESS;
156156}
157157
158+ void check_allocator_handle (const VkAllocationCallbacks* pAllocator) {
159+ if (pAllocator) {
160+ if (nullptr == pAllocator->pfnAllocation || nullptr == pAllocator->pfnFree || nullptr == pAllocator->pfnReallocation ) {
161+ std::cout << " pAllocator functions are NULL!\n " ;
162+ abort ();
163+ }
164+ }
165+ }
166+
158167// // Instance Functions ////
159168
160169// VK_SUCCESS,VK_INCOMPLETE
@@ -182,11 +191,11 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkEnumerateInstanceVersion(uint32_t* pApiVer
182191}
183192
184193VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateInstance (const VkInstanceCreateInfo* pCreateInfo,
185- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
186- VkInstance* pInstance) {
194+ const VkAllocationCallbacks* pAllocator, VkInstance* pInstance) {
187195 if (pCreateInfo == nullptr ) {
188196 return VK_ERROR_OUT_OF_HOST_MEMORY;
189197 }
198+ check_allocator_handle (pAllocator);
190199
191200 uint32_t default_api_version = VK_API_VERSION_1_0;
192201 uint32_t api_version =
@@ -214,9 +223,9 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateInstance(const VkInstanceCreateInfo*
214223 return VK_SUCCESS;
215224}
216225
217- VKAPI_ATTR void VKAPI_CALL test_vkDestroyInstance ([[maybe_unused]] VkInstance instance,
218- [[maybe_unused]] const VkAllocationCallbacks* pAllocator) {
226+ VKAPI_ATTR void VKAPI_CALL test_vkDestroyInstance ([[maybe_unused]] VkInstance instance, const VkAllocationCallbacks* pAllocator) {
219227 icd.enabled_instance_extensions .clear ();
228+ check_allocator_handle (pAllocator);
220229}
221230
222231// VK_SUCCESS,VK_INCOMPLETE
@@ -511,7 +520,8 @@ VKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceQueueFamilyProperties(VkPhysi
511520}
512521
513522VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDevice (VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo,
514- [[maybe_unused]] const VkAllocationCallbacks* pAllocator, VkDevice* pDevice) {
523+ const VkAllocationCallbacks* pAllocator, VkDevice* pDevice) {
524+ check_allocator_handle (pAllocator);
515525 // VK_SUCCESS
516526 auto found = std::find_if (icd.physical_devices .begin (), icd.physical_devices .end (), [physicalDevice](PhysicalDevice& phys_dev) {
517527 return phys_dev.vk_physical_device .handle == physicalDevice;
@@ -529,7 +539,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDevice(VkPhysicalDevice physicalDevi
529539 return VK_SUCCESS;
530540}
531541
532- VKAPI_ATTR void VKAPI_CALL test_vkDestroyDevice (VkDevice device, [[maybe_unused]] const VkAllocationCallbacks* pAllocator) {
542+ VKAPI_ATTR void VKAPI_CALL test_vkDestroyDevice (VkDevice device, const VkAllocationCallbacks* pAllocator) {
543+ check_allocator_handle (pAllocator);
533544 auto found = std::find (icd.device_handles .begin (), icd.device_handles .end (), device);
534545 if (found != icd.device_handles .end ()) icd.device_handles .erase (found);
535546 auto fd = icd.lookup_device (device);
@@ -610,8 +621,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateAndroidSurfaceKHR(VkInstance instanc
610621#if defined(VK_USE_PLATFORM_WIN32_KHR)
611622VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateWin32SurfaceKHR ([[maybe_unused]] VkInstance instance,
612623 [[maybe_unused]] const VkWin32SurfaceCreateInfoKHR* pCreateInfo,
613- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
614- VkSurfaceKHR* pSurface) {
624+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
625+ check_allocator_handle (pAllocator);
615626 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
616627 return VK_SUCCESS;
617628}
@@ -622,8 +633,8 @@ VKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceWin32PresentationSupportK
622633#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
623634VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateWaylandSurfaceKHR ([[maybe_unused]] VkInstance instance,
624635 [[maybe_unused]] const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
625- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
626- VkSurfaceKHR* pSurface) {
636+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
637+ check_allocator_handle (pAllocator);
627638 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
628639 return VK_SUCCESS;
629640}
@@ -636,8 +647,8 @@ VKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceWaylandPresentationSuppor
636647#if defined(VK_USE_PLATFORM_XCB_KHR)
637648VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateXcbSurfaceKHR ([[maybe_unused]] VkInstance instance,
638649 [[maybe_unused]] const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
639- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
640- VkSurfaceKHR* pSurface) {
650+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
651+ check_allocator_handle (pAllocator);
641652 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
642653 return VK_SUCCESS;
643654}
@@ -651,8 +662,8 @@ VKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceXcbPresentationSupportKHR
651662#if defined(VK_USE_PLATFORM_XLIB_KHR)
652663VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateXlibSurfaceKHR ([[maybe_unused]] VkInstance instance,
653664 [[maybe_unused]] const VkXlibSurfaceCreateInfoKHR* pCreateInfo,
654- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
655- VkSurfaceKHR* pSurface) {
665+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
666+ check_allocator_handle (pAllocator);
656667 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
657668 return VK_SUCCESS;
658669}
@@ -665,8 +676,8 @@ VKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceXlibPresentationSupportKH
665676#if defined(VK_USE_PLATFORM_DIRECTFB_EXT)
666677VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDirectFBSurfaceEXT ([[maybe_unused]] VkInstance instance,
667678 [[maybe_unused]] const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo,
668- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
669- VkSurfaceKHR* pSurface) {
679+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
680+ check_allocator_handle (pAllocator);
670681 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
671682 return VK_SUCCESS;
672683}
@@ -680,8 +691,8 @@ VKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceDirectFBPresentationSuppo
680691#if defined(VK_USE_PLATFORM_MACOS_MVK)
681692VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateMacOSSurfaceMVK ([[maybe_unused]] VkInstance instance,
682693 [[maybe_unused]] const VkMacOSSurfaceCreateInfoMVK* pCreateInfo,
683- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
684- VkSurfaceKHR* pSurface) {
694+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
695+ check_allocator_handle (pAllocator);
685696 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
686697 return VK_SUCCESS;
687698}
@@ -690,8 +701,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateMacOSSurfaceMVK([[maybe_unused]] VkI
690701#if defined(VK_USE_PLATFORM_IOS_MVK)
691702VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateIOSSurfaceMVK ([[maybe_unused]] VkInstance instance,
692703 [[maybe_unused]] const VkIOSSurfaceCreateInfoMVK* pCreateInfo,
693- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
694- VkSurfaceKHR* pSurface) {
704+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
705+ check_allocator_handle (pAllocator);
695706 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
696707 return VK_SUCCESS;
697708}
@@ -700,7 +711,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateIOSSurfaceMVK([[maybe_unused]] VkIns
700711#if defined(VK_USE_PLATFORM_GGP)
701712VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateStreamDescriptorSurfaceGGP (
702713 [[maybe_unused]] VkInstance instance, [[maybe_unused]] const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo,
703- [[maybe_unused]] const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
714+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
715+ check_allocator_handle (pAllocator);
704716 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
705717 return VK_SUCCESS;
706718}
@@ -709,8 +721,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateStreamDescriptorSurfaceGGP(
709721#if defined(VK_USE_PLATFORM_METAL_EXT)
710722VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateMetalSurfaceEXT ([[maybe_unused]] VkInstance instance,
711723 [[maybe_unused]] const VkMetalSurfaceCreateInfoEXT* pCreateInfo,
712- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
713- VkSurfaceKHR* pSurface) {
724+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
725+ check_allocator_handle (pAllocator);
714726 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
715727 return VK_SUCCESS;
716728}
@@ -719,8 +731,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateMetalSurfaceEXT([[maybe_unused]] VkI
719731#if defined(VK_USE_PLATFORM_SCREEN_QNX)
720732VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateScreenSurfaceQNX ([[maybe_unused]] VkInstance instance,
721733 [[maybe_unused]] const VkScreenSurfaceCreateInfoQNX* pCreateInfo,
722- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
723- VkSurfaceKHR* pSurface) {
734+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
735+ check_allocator_handle (pAllocator);
724736 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
725737 return VK_SUCCESS;
726738}
@@ -733,14 +745,14 @@ VKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceScreenPresentationSupport
733745
734746VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateHeadlessSurfaceEXT ([[maybe_unused]] VkInstance instance,
735747 [[maybe_unused]] const VkHeadlessSurfaceCreateInfoEXT* pCreateInfo,
736- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
737- VkSurfaceKHR* pSurface) {
748+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
749+ check_allocator_handle (pAllocator);
738750 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
739751 return VK_SUCCESS;
740752}
741753
742754VKAPI_ATTR void VKAPI_CALL test_vkDestroySurfaceKHR ([[maybe_unused]] VkInstance instance, VkSurfaceKHR surface,
743- [[maybe_unused]] const VkAllocationCallbacks* pAllocator) {
755+ const VkAllocationCallbacks* pAllocator) {
744756 if (surface != VK_NULL_HANDLE) {
745757 uint64_t fake_surf_handle = from_nondispatch_handle (surface);
746758 auto found_iter = std::find (icd.surface_handles .begin (), icd.surface_handles .end (), fake_surf_handle);
@@ -755,8 +767,8 @@ VKAPI_ATTR void VKAPI_CALL test_vkDestroySurfaceKHR([[maybe_unused]] VkInstance
755767// VK_KHR_swapchain
756768VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateSwapchainKHR ([[maybe_unused]] VkDevice device,
757769 [[maybe_unused]] const VkSwapchainCreateInfoKHR* pCreateInfo,
758- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
759- VkSwapchainKHR* pSwapchain) {
770+ const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain) {
771+ check_allocator_handle (pAllocator);
760772 common_nondispatch_handle_creation (icd.swapchain_handles , pSwapchain);
761773 return VK_SUCCESS;
762774}
@@ -777,7 +789,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkGetSwapchainImagesKHR([[maybe_unused]] VkD
777789}
778790
779791VKAPI_ATTR void VKAPI_CALL test_vkDestroySwapchainKHR ([[maybe_unused]] VkDevice device, VkSwapchainKHR swapchain,
780- [[maybe_unused]] const VkAllocationCallbacks* pAllocator) {
792+ const VkAllocationCallbacks* pAllocator) {
793+ check_allocator_handle (pAllocator);
781794 if (swapchain != VK_NULL_HANDLE) {
782795 uint64_t fake_swapchain_handle = from_nondispatch_handle (swapchain);
783796 auto found_iter = icd.swapchain_handles .erase (
@@ -917,8 +930,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkGetDisplayModePropertiesKHR(VkPhysicalDevi
917930}
918931VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDisplayModeKHR (VkPhysicalDevice physicalDevice, [[maybe_unused]] VkDisplayKHR display,
919932 [[maybe_unused]] const VkDisplayModeCreateInfoKHR* pCreateInfo,
920- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
921- VkDisplayModeKHR* pMode) {
933+ const VkAllocationCallbacks* pAllocator, VkDisplayModeKHR* pMode) {
934+ check_allocator_handle (pAllocator);
922935 if (nullptr != pMode) {
923936 *pMode = icd.GetPhysDevice (physicalDevice).display_mode ;
924937 }
@@ -935,7 +948,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalD
935948}
936949VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDisplayPlaneSurfaceKHR (
937950 [[maybe_unused]] VkInstance instance, [[maybe_unused]] const VkDisplaySurfaceCreateInfoKHR* pCreateInfo,
938- [[maybe_unused]] const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
951+ const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
952+ check_allocator_handle (pAllocator);
939953 common_nondispatch_handle_creation (icd.surface_handles , pSurface);
940954 return VK_SUCCESS;
941955}
@@ -1026,8 +1040,9 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhys
10261040// VK_KHR_display_swapchain
10271041VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateSharedSwapchainsKHR ([[maybe_unused]] VkDevice device, uint32_t swapchainCount,
10281042 const VkSwapchainCreateInfoKHR* pCreateInfos,
1029- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
1043+ const VkAllocationCallbacks* pAllocator,
10301044 VkSwapchainKHR* pSwapchains) {
1045+ check_allocator_handle (pAllocator);
10311046 for (uint32_t i = 0 ; i < swapchainCount; i++) {
10321047 uint64_t surface_integer_value = from_nondispatch_handle (pCreateInfos[i].surface );
10331048 auto found_iter = std::find (icd.surface_handles .begin (), icd.surface_handles .end (), surface_integer_value);
@@ -1042,8 +1057,8 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateSharedSwapchainsKHR([[maybe_unused]]
10421057// // misc
10431058VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateCommandPool ([[maybe_unused]] VkDevice device,
10441059 [[maybe_unused]] const VkCommandPoolCreateInfo* pCreateInfo,
1045- [[maybe_unused]] const VkAllocationCallbacks* pAllocator,
1046- VkCommandPool* pCommandPool) {
1060+ const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool) {
1061+ check_allocator_handle (pAllocator);
10471062 if (pCommandPool != nullptr ) {
10481063 pCommandPool = reinterpret_cast <VkCommandPool*>(0xdeadbeefdeadbeef );
10491064 }
0 commit comments