Update tests function loading implementation
authorCharles Giessen <charles@lunarg.com>
Sat, 12 Feb 2022 19:35:30 +0000 (12:35 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Tue, 15 Feb 2022 17:48:53 +0000 (10:48 -0700)
Remove the need for macros and use well crafted helper loading functions which
can figure out the type to convert to based on the type being assigned.

tests/framework/icd/test_icd.cpp
tests/framework/layer/test_layer.cpp
tests/framework/shim/windows_shim.cpp
tests/framework/test_environment.cpp
tests/framework/test_util.cpp
tests/framework/test_util.h
tests/loader_phys_dev_inst_ext_tests.cpp

index 622acfb6405a81b34b623edd18b50cc65f8119c3..94bc7157dcd5b1aa15203593dc3a329372fbd229 100644 (file)
@@ -726,7 +726,7 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhys
 VKAPI_ATTR VkResult VKAPI_CALL test_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo,
                                                         const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool) {
     if (pCommandPool != nullptr) {
-        pCommandPool = reinterpret_cast<VkCommandPool*>(0xdeadbeef);
+        pCommandPool = reinterpret_cast<VkCommandPool*>(0xdeadbeefdeadbeef);
     }
     return VK_SUCCESS;
 }
@@ -948,12 +948,10 @@ VKAPI_ATTR VkResult VKAPI_CALL test_vkGetCalibratedTimestampsEXT(VkDevice device
 
 //// trampolines
 
-#define TO_VOID_PFN(func) reinterpret_cast<PFN_vkVoidFunction>(func)
-
 PFN_vkVoidFunction get_instance_func_ver_1_1(VkInstance instance, const char* pName) {
     if (icd.icd_api_version >= VK_API_VERSION_1_1) {
         if (string_eq(pName, "test_vkEnumerateInstanceVersion")) {
-            return TO_VOID_PFN(test_vkEnumerateInstanceVersion);
+            return to_vkVoidFunction(test_vkEnumerateInstanceVersion);
         }
     }
     return nullptr;
@@ -967,34 +965,36 @@ PFN_vkVoidFunction get_instance_func_ver_1_2(VkInstance instance, const char* pN
 
 PFN_vkVoidFunction get_physical_device_func_wsi(VkInstance instance, const char* pName) {
     if (IsInstanceExtensionEnabled("VK_KHR_surface")) {
-        if (string_eq(pName, "vkGetPhysicalDeviceSurfaceSupportKHR")) return TO_VOID_PFN(test_vkGetPhysicalDeviceSurfaceSupportKHR);
+        if (string_eq(pName, "vkGetPhysicalDeviceSurfaceSupportKHR"))
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceSupportKHR);
         if (string_eq(pName, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceSurfaceCapabilitiesKHR);
-        if (string_eq(pName, "vkGetPhysicalDeviceSurfaceFormatsKHR")) return TO_VOID_PFN(test_vkGetPhysicalDeviceSurfaceFormatsKHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceCapabilitiesKHR);
+        if (string_eq(pName, "vkGetPhysicalDeviceSurfaceFormatsKHR"))
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceFormatsKHR);
         if (string_eq(pName, "vkGetPhysicalDeviceSurfacePresentModesKHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceSurfacePresentModesKHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfacePresentModesKHR);
     }
     if (IsInstanceExtensionEnabled("VK_KHR_get_surface_capabilities2")) {
         if (string_eq(pName, "vkGetPhysicalDeviceSurfaceCapabilities2KHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceSurfaceCapabilities2KHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceCapabilities2KHR);
         if (string_eq(pName, "vkGetPhysicalDeviceSurfaceFormats2KHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceSurfaceFormats2KHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceFormats2KHR);
     }
     if (IsInstanceExtensionEnabled("VK_KHR_display")) {
         if (string_eq(pName, "vkGetPhysicalDeviceDisplayPropertiesKHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceDisplayPropertiesKHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceDisplayPropertiesKHR);
         if (string_eq(pName, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceDisplayPlanePropertiesKHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceDisplayPlanePropertiesKHR);
         if (string_eq(pName, "vkGetDisplayPlaneSupportedDisplaysKHR"))
-            return TO_VOID_PFN(test_vkGetDisplayPlaneSupportedDisplaysKHR);
-        if (string_eq(pName, "vkGetDisplayModePropertiesKHR")) return TO_VOID_PFN(test_vkGetDisplayModePropertiesKHR);
-        if (string_eq(pName, "vkCreateDisplayModeKHR")) return TO_VOID_PFN(test_vkCreateDisplayModeKHR);
-        if (string_eq(pName, "vkGetDisplayPlaneCapabilitiesKHR")) return TO_VOID_PFN(test_vkGetDisplayPlaneCapabilitiesKHR);
-        if (string_eq(pName, "vkCreateDisplayPlaneSurfaceKHR")) return TO_VOID_PFN(test_vkCreateDisplayPlaneSurfaceKHR);
+            return to_vkVoidFunction(test_vkGetDisplayPlaneSupportedDisplaysKHR);
+        if (string_eq(pName, "vkGetDisplayModePropertiesKHR")) return to_vkVoidFunction(test_vkGetDisplayModePropertiesKHR);
+        if (string_eq(pName, "vkCreateDisplayModeKHR")) return to_vkVoidFunction(test_vkCreateDisplayModeKHR);
+        if (string_eq(pName, "vkGetDisplayPlaneCapabilitiesKHR")) return to_vkVoidFunction(test_vkGetDisplayPlaneCapabilitiesKHR);
+        if (string_eq(pName, "vkCreateDisplayPlaneSurfaceKHR")) return to_vkVoidFunction(test_vkCreateDisplayPlaneSurfaceKHR);
     }
     if (IsInstanceExtensionEnabled("VK_EXT_acquire_drm_display")) {
-        if (string_eq(pName, "vkAcquireDrmDisplayEXT")) return TO_VOID_PFN(test_vkAcquireDrmDisplayEXT);
-        if (string_eq(pName, "vkGetDrmDisplayEXT")) return TO_VOID_PFN(test_vkGetDrmDisplayEXT);
+        if (string_eq(pName, "vkAcquireDrmDisplayEXT")) return to_vkVoidFunction(test_vkAcquireDrmDisplayEXT);
+        if (string_eq(pName, "vkGetDrmDisplayEXT")) return to_vkVoidFunction(test_vkGetDrmDisplayEXT);
     }
     return nullptr;
 }
@@ -1004,93 +1004,93 @@ PFN_vkVoidFunction get_instance_func_wsi(VkInstance instance, const char* pName)
 #ifdef VK_USE_PLATFORM_ANDROID_KHR
         if (string_eq(pName, "vkCreateAndroidSurfaceKHR")) {
             icd.is_using_icd_wsi = UsingICDProvidedWSI::is_using;
-            return TO_VOID_PFN(test_vkCreateAndroidSurfaceKHR);
+            return to_vkVoidFunction(test_vkCreateAndroidSurfaceKHR);
         }
 #endif
 #ifdef VK_USE_PLATFORM_METAL_EXT
         if (string_eq(pName, "vkCreateMetalSurfaceEXT")) {
-            return TO_VOID_PFN(test_vkCreateMetalSurfaceEXT);
+            return to_vkVoidFunction(test_vkCreateMetalSurfaceEXT);
         }
 #endif
 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
         if (string_eq(pName, "vkCreateWaylandSurfaceKHR")) {
-            return TO_VOID_PFN(test_vkCreateWaylandSurfaceKHR);
+            return to_vkVoidFunction(test_vkCreateWaylandSurfaceKHR);
         }
         if (string_eq(pName, "vkGetPhysicalDeviceWaylandPresentationSupportKHR")) {
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceWaylandPresentationSupportKHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceWaylandPresentationSupportKHR);
         }
 #endif
 #ifdef VK_USE_PLATFORM_XCB_KHR
         if (string_eq(pName, "vkCreateXcbSurfaceKHR")) {
-            return TO_VOID_PFN(test_vkCreateXcbSurfaceKHR);
+            return to_vkVoidFunction(test_vkCreateXcbSurfaceKHR);
         }
         if (string_eq(pName, "vkGetPhysicalDeviceXcbPresentationSupportKHR")) {
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceXcbPresentationSupportKHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceXcbPresentationSupportKHR);
         }
 #endif
 #ifdef VK_USE_PLATFORM_XLIB_KHR
         if (string_eq(pName, "vkCreateXlibSurfaceKHR")) {
-            return TO_VOID_PFN(test_vkCreateXlibSurfaceKHR);
+            return to_vkVoidFunction(test_vkCreateXlibSurfaceKHR);
         }
         if (string_eq(pName, "vkGetPhysicalDeviceXlibPresentationSupportKHR")) {
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceXlibPresentationSupportKHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceXlibPresentationSupportKHR);
         }
 #endif
 #ifdef VK_USE_PLATFORM_WIN32_KHR
         if (string_eq(pName, "vkCreateWin32SurfaceKHR")) {
-            return TO_VOID_PFN(test_vkCreateWin32SurfaceKHR);
+            return to_vkVoidFunction(test_vkCreateWin32SurfaceKHR);
         }
         if (string_eq(pName, "vkGetPhysicalDeviceWin32PresentationSupportKHR")) {
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceWin32PresentationSupportKHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceWin32PresentationSupportKHR);
         }
 #endif
 #ifdef VK_USE_PLATFORM_DIRECTFB_EXT
         if (string_eq(pName, "vkCreateDirectFBSurfaceEXT")) {
-            return TO_VOID_PFN(test_vkCreateDirectFBSurfaceEXT);
+            return to_vkVoidFunction(test_vkCreateDirectFBSurfaceEXT);
         }
         if (string_eq(pName, "vkGetPhysicalDeviceDirectFBPresentationSupportEXT")) {
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceDirectFBPresentationSupportEXT);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceDirectFBPresentationSupportEXT);
         }
 #endif  // VK_USE_PLATFORM_DIRECTFB_EXT
 
 #ifdef VK_USE_PLATFORM_MACOS_MVK
         if (string_eq(pName, "vkCreateMacOSSurfaceMVK")) {
-            return TO_VOID_PFN(test_vkCreateMacOSSurfaceMVK);
+            return to_vkVoidFunction(test_vkCreateMacOSSurfaceMVK);
         }
 #endif  // VK_USE_PLATFORM_MACOS_MVK
 
 #ifdef VK_USE_PLATFORM_IOS_MVK
         if (string_eq(pName, "vkCreateIOSSurfaceMVK")) {
-            return TO_VOID_PFN(test_vkCreateIOSSurfaceMVK);
+            return to_vkVoidFunction(test_vkCreateIOSSurfaceMVK);
         }
 #endif  // VK_USE_PLATFORM_IOS_MVK
 
 #ifdef VK_USE_PLATFORM_GGP
         if (string_eq(pName, "vkCreateStreamDescriptorSurfaceGGP")) {
-            return TO_VOID_PFN(test_vkCreateStreamDescriptorSurfaceGGP);
+            return to_vkVoidFunction(test_vkCreateStreamDescriptorSurfaceGGP);
         }
 #endif  // VK_USE_PLATFORM_GGP
 
 #ifdef VK_USE_PLATFORM_SCREEN_QNX
         if (string_eq(pName, "vkCreateScreenSurfaceQNX")) {
-            return TO_VOID_PFN(test_vkCreateScreenSurfaceQNX);
+            return to_vkVoidFunction(test_vkCreateScreenSurfaceQNX);
         }
         if (string_eq(pName, "vkGetPhysicalDeviceScreenPresentationSupportQNX")) {
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceScreenPresentationSupportQNX);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceScreenPresentationSupportQNX);
         }
 #endif  // VK_USE_PLATFORM_SCREEN_QNX
 
         if (string_eq(pName, "vkDestroySurfaceKHR")) {
             icd.is_using_icd_wsi = UsingICDProvidedWSI::is_using;
-            return TO_VOID_PFN(test_vkDestroySurfaceKHR);
+            return to_vkVoidFunction(test_vkDestroySurfaceKHR);
         }
     }
     if (IsInstanceExtensionEnabled(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)) {
         if (string_eq(pName, "vkCreateDebugUtilsMessengerEXT")) {
-            return TO_VOID_PFN(test_vkCreateDebugUtilsMessengerEXT);
+            return to_vkVoidFunction(test_vkCreateDebugUtilsMessengerEXT);
         }
         if (string_eq(pName, "vkDestroyDebugUtilsMessengerEXT")) {
-            return TO_VOID_PFN(test_vkDestroyDebugUtilsMessengerEXT);
+            return to_vkVoidFunction(test_vkDestroyDebugUtilsMessengerEXT);
         }
     }
 
@@ -1099,120 +1099,125 @@ PFN_vkVoidFunction get_instance_func_wsi(VkInstance instance, const char* pName)
     return nullptr;
 }
 PFN_vkVoidFunction get_physical_device_func(VkInstance instance, const char* pName) {
-    if (string_eq(pName, "vkEnumerateDeviceLayerProperties")) return TO_VOID_PFN(test_vkEnumerateDeviceLayerProperties);
-    if (string_eq(pName, "vkEnumerateDeviceExtensionProperties")) return TO_VOID_PFN(test_vkEnumerateDeviceExtensionProperties);
+    if (string_eq(pName, "vkEnumerateDeviceLayerProperties")) return to_vkVoidFunction(test_vkEnumerateDeviceLayerProperties);
+    if (string_eq(pName, "vkEnumerateDeviceExtensionProperties"))
+        return to_vkVoidFunction(test_vkEnumerateDeviceExtensionProperties);
     if (string_eq(pName, "vkGetPhysicalDeviceQueueFamilyProperties"))
-        return TO_VOID_PFN(test_vkGetPhysicalDeviceQueueFamilyProperties);
-    if (string_eq(pName, "vkCreateDevice")) return TO_VOID_PFN(test_vkCreateDevice);
+        return to_vkVoidFunction(test_vkGetPhysicalDeviceQueueFamilyProperties);
+    if (string_eq(pName, "vkCreateDevice")) return to_vkVoidFunction(test_vkCreateDevice);
 
-    if (string_eq(pName, "vkGetPhysicalDeviceFeatures")) return TO_VOID_PFN(test_vkGetPhysicalDeviceFeatures);
-    if (string_eq(pName, "vkGetPhysicalDeviceProperties")) return TO_VOID_PFN(test_vkGetPhysicalDeviceProperties);
-    if (string_eq(pName, "vkGetPhysicalDeviceMemoryProperties")) return TO_VOID_PFN(test_vkGetPhysicalDeviceMemoryProperties);
+    if (string_eq(pName, "vkGetPhysicalDeviceFeatures")) return to_vkVoidFunction(test_vkGetPhysicalDeviceFeatures);
+    if (string_eq(pName, "vkGetPhysicalDeviceProperties")) return to_vkVoidFunction(test_vkGetPhysicalDeviceProperties);
+    if (string_eq(pName, "vkGetPhysicalDeviceMemoryProperties")) return to_vkVoidFunction(test_vkGetPhysicalDeviceMemoryProperties);
     if (string_eq(pName, "vkGetPhysicalDeviceSparseImageFormatProperties"))
-        return TO_VOID_PFN(test_vkGetPhysicalDeviceSparseImageFormatProperties);
-    if (string_eq(pName, "vkGetPhysicalDeviceFormatProperties")) return TO_VOID_PFN(test_vkGetPhysicalDeviceFormatProperties);
+        return to_vkVoidFunction(test_vkGetPhysicalDeviceSparseImageFormatProperties);
+    if (string_eq(pName, "vkGetPhysicalDeviceFormatProperties")) return to_vkVoidFunction(test_vkGetPhysicalDeviceFormatProperties);
     if (string_eq(pName, "vkGetPhysicalDeviceImageFormatProperties"))
-        return TO_VOID_PFN(test_vkGetPhysicalDeviceImageFormatProperties);
+        return to_vkVoidFunction(test_vkGetPhysicalDeviceImageFormatProperties);
 
     if (IsInstanceExtensionEnabled(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) {
-        if (string_eq(pName, "vkGetPhysicalDeviceFeatures2KHR")) return TO_VOID_PFN(test_vkGetPhysicalDeviceFeatures2);
-        if (string_eq(pName, "vkGetPhysicalDeviceProperties2KHR")) return TO_VOID_PFN(test_vkGetPhysicalDeviceProperties2);
+        if (string_eq(pName, "vkGetPhysicalDeviceFeatures2KHR")) return to_vkVoidFunction(test_vkGetPhysicalDeviceFeatures2);
+        if (string_eq(pName, "vkGetPhysicalDeviceProperties2KHR")) return to_vkVoidFunction(test_vkGetPhysicalDeviceProperties2);
         if (string_eq(pName, "vkGetPhysicalDeviceFormatProperties2KHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceFormatProperties2);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceFormatProperties2);
         if (string_eq(pName, "vkGetPhysicalDeviceMemoryProperties2KHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceMemoryProperties2);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceMemoryProperties2);
 
         if (string_eq(pName, "vkGetPhysicalDeviceQueueFamilyProperties2KHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceQueueFamilyProperties2);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceQueueFamilyProperties2);
 
         if (string_eq(pName, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceSparseImageFormatProperties2);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceSparseImageFormatProperties2);
 
         if (string_eq(pName, "vkGetPhysicalDeviceImageFormatProperties2KHR")) {
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceImageFormatProperties2);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceImageFormatProperties2);
         }
     }
     if (IsInstanceExtensionEnabled(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME)) {
         if (string_eq(pName, "vkGetPhysicalDeviceExternalBufferPropertiesKHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceExternalBufferProperties);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalBufferProperties);
     }
     if (IsInstanceExtensionEnabled(VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME)) {
         if (string_eq(pName, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceExternalSemaphoreProperties);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalSemaphoreProperties);
     }
     if (IsInstanceExtensionEnabled(VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME)) {
         if (string_eq(pName, "vkGetPhysicalDeviceExternalFencePropertiesKHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceExternalFenceProperties);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalFenceProperties);
     }
 
     // The following physical device extensions only need 1 device to support them for the ICD to export
     // them
     if (IsPhysicalDeviceExtensionAvailable(VK_KHR_PERFORMANCE_QUERY_EXTENSION_NAME)) {
         if (string_eq(pName, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR"))
-            return TO_VOID_PFN(test_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR);
+            return to_vkVoidFunction(test_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR);
         if (string_eq(pName, "vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR);
-        if (string_eq(pName, "vkAcquireProfilingLockKHR")) return TO_VOID_PFN(test_vkAcquireProfilingLockKHR);
-        if (string_eq(pName, "vkReleaseProfilingLockKHR")) return TO_VOID_PFN(test_vkReleaseProfilingLockKHR);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR);
+        if (string_eq(pName, "vkAcquireProfilingLockKHR")) return to_vkVoidFunction(test_vkAcquireProfilingLockKHR);
+        if (string_eq(pName, "vkReleaseProfilingLockKHR")) return to_vkVoidFunction(test_vkReleaseProfilingLockKHR);
     }
     if (IsPhysicalDeviceExtensionAvailable(VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME)) {
-        if (string_eq(pName, "vkCmdSetSampleLocationsEXT")) return TO_VOID_PFN(test_vkCmdSetSampleLocationsEXT);
+        if (string_eq(pName, "vkCmdSetSampleLocationsEXT")) return to_vkVoidFunction(test_vkCmdSetSampleLocationsEXT);
         if (string_eq(pName, "vkGetPhysicalDeviceMultisamplePropertiesEXT"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceMultisamplePropertiesEXT);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceMultisamplePropertiesEXT);
     }
     if (IsPhysicalDeviceExtensionAvailable(VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME)) {
         if (string_eq(pName, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT);
-        if (string_eq(pName, "vkGetCalibratedTimestampsEXT")) return TO_VOID_PFN(test_vkGetCalibratedTimestampsEXT);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT);
+        if (string_eq(pName, "vkGetCalibratedTimestampsEXT")) return to_vkVoidFunction(test_vkGetCalibratedTimestampsEXT);
     }
 
     if (icd.icd_api_version >= VK_MAKE_API_VERSION(0, 1, 1, 0)) {
-        if (string_eq(pName, "vkGetPhysicalDeviceFeatures2")) return TO_VOID_PFN(test_vkGetPhysicalDeviceFeatures2);
-        if (string_eq(pName, "vkGetPhysicalDeviceProperties2")) return TO_VOID_PFN(test_vkGetPhysicalDeviceProperties2);
-        if (string_eq(pName, "vkGetPhysicalDeviceFormatProperties2")) return TO_VOID_PFN(test_vkGetPhysicalDeviceFormatProperties2);
-        if (string_eq(pName, "vkGetPhysicalDeviceMemoryProperties2")) return TO_VOID_PFN(test_vkGetPhysicalDeviceMemoryProperties2);
+        if (string_eq(pName, "vkGetPhysicalDeviceFeatures2")) return to_vkVoidFunction(test_vkGetPhysicalDeviceFeatures2);
+        if (string_eq(pName, "vkGetPhysicalDeviceProperties2")) return to_vkVoidFunction(test_vkGetPhysicalDeviceProperties2);
+        if (string_eq(pName, "vkGetPhysicalDeviceFormatProperties2"))
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceFormatProperties2);
+        if (string_eq(pName, "vkGetPhysicalDeviceMemoryProperties2"))
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceMemoryProperties2);
 
         if (string_eq(pName, "vkGetPhysicalDeviceQueueFamilyProperties2"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceQueueFamilyProperties2);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceQueueFamilyProperties2);
 
         if (string_eq(pName, "vkGetPhysicalDeviceSparseImageFormatProperties2"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceSparseImageFormatProperties2);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceSparseImageFormatProperties2);
 
         if (string_eq(pName, "vkGetPhysicalDeviceImageFormatProperties2")) {
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceImageFormatProperties2);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceImageFormatProperties2);
         }
 
         if (string_eq(pName, "vkGetPhysicalDeviceExternalBufferProperties"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceExternalBufferProperties);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalBufferProperties);
         if (string_eq(pName, "vkGetPhysicalDeviceExternalSemaphoreProperties"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceExternalSemaphoreProperties);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalSemaphoreProperties);
         if (string_eq(pName, "vkGetPhysicalDeviceExternalFenceProperties"))
-            return TO_VOID_PFN(test_vkGetPhysicalDeviceExternalFenceProperties);
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalFenceProperties);
     }
 
     if (icd.supports_tooling_info_core) {
-        if (string_eq(pName, "vkGetPhysicalDeviceToolProperties")) return TO_VOID_PFN(test_vkGetPhysicalDeviceToolProperties);
+        if (string_eq(pName, "vkGetPhysicalDeviceToolProperties")) return to_vkVoidFunction(test_vkGetPhysicalDeviceToolProperties);
     }
     if (icd.supports_tooling_info_ext) {
-        if (string_eq(pName, "vkGetPhysicalDeviceToolPropertiesEXT")) return TO_VOID_PFN(test_vkGetPhysicalDeviceToolPropertiesEXT);
+        if (string_eq(pName, "vkGetPhysicalDeviceToolPropertiesEXT"))
+            return to_vkVoidFunction(test_vkGetPhysicalDeviceToolPropertiesEXT);
     }
 
     for (auto& func : icd.custom_physical_device_functions) {
         if (func.name == pName) {
-            return TO_VOID_PFN(func.function);
+            return to_vkVoidFunction(func.function);
         }
     }
     return nullptr;
 }
 
 PFN_vkVoidFunction get_instance_func(VkInstance instance, const char* pName) {
-    if (string_eq(pName, "vkEnumerateInstanceExtensionProperties")) return TO_VOID_PFN(test_vkEnumerateInstanceExtensionProperties);
-    if (string_eq(pName, "vkEnumerateInstanceLayerProperties")) return TO_VOID_PFN(test_vkEnumerateInstanceLayerProperties);
-    if (string_eq(pName, "vkCreateInstance")) return TO_VOID_PFN(test_vkCreateInstance);
-    if (string_eq(pName, "vkDestroyInstance")) return TO_VOID_PFN(test_vkDestroyInstance);
-    if (string_eq(pName, "vkEnumeratePhysicalDevices")) return TO_VOID_PFN(test_vkEnumeratePhysicalDevices);
+    if (string_eq(pName, "vkEnumerateInstanceExtensionProperties"))
+        return to_vkVoidFunction(test_vkEnumerateInstanceExtensionProperties);
+    if (string_eq(pName, "vkEnumerateInstanceLayerProperties")) return to_vkVoidFunction(test_vkEnumerateInstanceLayerProperties);
+    if (string_eq(pName, "vkCreateInstance")) return to_vkVoidFunction(test_vkCreateInstance);
+    if (string_eq(pName, "vkDestroyInstance")) return to_vkVoidFunction(test_vkDestroyInstance);
+    if (string_eq(pName, "vkEnumeratePhysicalDevices")) return to_vkVoidFunction(test_vkEnumeratePhysicalDevices);
     if (string_eq(pName, "vkEnumeratePhysicalDeviceGroups") || string_eq(pName, "vkEnumeratePhysicalDeviceGroupsKHR"))
-        return TO_VOID_PFN(test_vkEnumeratePhysicalDeviceGroups);
+        return to_vkVoidFunction(test_vkEnumeratePhysicalDeviceGroups);
 
     PFN_vkVoidFunction ret_phys_dev = get_physical_device_func(instance, pName);
     if (ret_phys_dev != nullptr) return ret_phys_dev;
@@ -1228,7 +1233,7 @@ PFN_vkVoidFunction get_instance_func(VkInstance instance, const char* pName) {
 
     for (auto& func : icd.custom_instance_functions) {
         if (func.name == pName) {
-            return TO_VOID_PFN(func.function);
+            return to_vkVoidFunction(func.function);
         }
     }
 
@@ -1247,16 +1252,19 @@ PFN_vkVoidFunction get_device_func(VkDevice device, const char* pName) {
             }
         }
     }
-    if (!found) return nullptr;
-    if (string_eq(pName, "vkDestroyDevice")) return TO_VOID_PFN(test_vkDestroyDevice);
-    if (string_eq(pName, "vkCreateSwapchainKHR")) return TO_VOID_PFN(test_vkCreateSwapchainKHR);
-    if (string_eq(pName, "vkDestroySwapchainKHR")) return TO_VOID_PFN(test_vkDestroySwapchainKHR);
-    if (string_eq(pName, "vkCreateCommandPool")) return TO_VOID_PFN(test_vkCreateCommandPool);
-    if (string_eq(pName, "vkAllocateCommandBuffers")) return TO_VOID_PFN(test_vkAllocateCommandBuffers);
-    if (string_eq(pName, "vkDestroyCommandPool")) return TO_VOID_PFN(test_vkDestroyCommandPool);
-    for (auto& function : found_phys_dev->known_device_functions) {
-        if (string_eq(pName, function.name)) {
-            return reinterpret_cast<PFN_vkVoidFunction>(function.function);
+    if (string_eq(pName, "vkDestroyDevice")) return to_vkVoidFunction(test_vkDestroyDevice);
+    if (string_eq(pName, "vkCreateSwapchainKHR")) return to_vkVoidFunction(test_vkCreateSwapchainKHR);
+    if (string_eq(pName, "vkDestroySwapchainKHR")) return to_vkVoidFunction(test_vkDestroySwapchainKHR);
+    if (string_eq(pName, "vkCreateCommandPool")) return to_vkVoidFunction(test_vkCreateCommandPool);
+    if (string_eq(pName, "vkAllocateCommandBuffers")) return to_vkVoidFunction(test_vkAllocateCommandBuffers);
+    if (string_eq(pName, "vkDestroyCommandPool")) return to_vkVoidFunction(test_vkDestroyCommandPool);
+    if (string_eq(pName, "vkGetDeviceQueue")) return to_vkVoidFunction(test_vkGetDeviceQueue);
+    // look for device functions setup from a test
+    for (const auto& phys_dev : icd.physical_devices) {
+        for (const auto& function : phys_dev.known_device_functions) {
+            if (function.name == pName) {
+                return to_vkVoidFunction(function.function);
+            }
         }
     }
     return nullptr;
@@ -1273,13 +1281,14 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL test_vkGetDeviceProcAddr(VkDevice devic
 PFN_vkVoidFunction base_get_instance_proc_addr(VkInstance instance, const char* pName) {
     if (pName == nullptr) return nullptr;
     if (instance == NULL) {
-        if (string_eq(pName, "vkGetInstanceProcAddr")) return TO_VOID_PFN(test_vkGetInstanceProcAddr);
+        if (string_eq(pName, "vkGetInstanceProcAddr")) return to_vkVoidFunction(test_vkGetInstanceProcAddr);
         if (string_eq(pName, "vkEnumerateInstanceExtensionProperties"))
-            return TO_VOID_PFN(test_vkEnumerateInstanceExtensionProperties);
-        if (string_eq(pName, "vkEnumerateInstanceLayerProperties")) return TO_VOID_PFN(test_vkEnumerateInstanceLayerProperties);
-        if (string_eq(pName, "vkEnumerateInstanceVersion")) return TO_VOID_PFN(test_vkEnumerateInstanceVersion);
+            return to_vkVoidFunction(test_vkEnumerateInstanceExtensionProperties);
+        if (string_eq(pName, "vkEnumerateInstanceLayerProperties"))
+            return to_vkVoidFunction(test_vkEnumerateInstanceLayerProperties);
+        if (string_eq(pName, "vkEnumerateInstanceVersion")) return to_vkVoidFunction(test_vkEnumerateInstanceVersion);
     }
-    if (string_eq(pName, "vkGetDeviceProcAddr")) return TO_VOID_PFN(test_vkGetDeviceProcAddr);
+    if (string_eq(pName, "vkGetDeviceProcAddr")) return to_vkVoidFunction(test_vkGetDeviceProcAddr);
 
     auto instance_func_return = get_instance_func(instance, pName);
     if (instance_func_return != nullptr) return instance_func_return;
index be0c4e0686f06c5d7bf4333dc21f2185a38e404d..c3944e03fab24f006935026b4f15deb84076f7d4 100644 (file)
@@ -222,27 +222,27 @@ VKAPI_ATTR void VKAPI_CALL test_vkDestroyDevice(VkDevice device, const VkAllocat
 
 // trampolines
 
-#define TO_VOID_PFN(func) reinterpret_cast<PFN_vkVoidFunction>(func)
-
 VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL get_device_func(VkDevice device, const char* pName) {
-    if (string_eq(pName, "vkDestroyDevice")) return TO_VOID_PFN(test_vkDestroyDevice);
+    if (string_eq(pName, "vkDestroyDevice")) return to_vkVoidFunction(test_vkDestroyDevice);
 
     return layer.next_vkGetDeviceProcAddr(device, pName);
 }
 
 VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL get_instance_func(VkInstance instance, const char* pName) {
     if (pName == nullptr) return nullptr;
-    if (string_eq(pName, "vkGetInstanceProcAddr")) return TO_VOID_PFN(get_instance_func);
-    if (string_eq(pName, "vkEnumerateInstanceLayerProperties")) return TO_VOID_PFN(test_vkEnumerateInstanceLayerProperties);
-    if (string_eq(pName, "vkEnumerateInstanceExtensionProperties")) return TO_VOID_PFN(test_vkEnumerateInstanceExtensionProperties);
-    if (string_eq(pName, "vkEnumerateInstanceVersion")) return TO_VOID_PFN(test_vkEnumerateInstanceVersion);
-
-    if (string_eq(pName, "vkEnumerateDeviceLayerProperties")) return TO_VOID_PFN(test_vkEnumerateDeviceLayerProperties);
-    if (string_eq(pName, "vkEnumerateDeviceExtensionProperties")) return TO_VOID_PFN(test_vkEnumerateDeviceExtensionProperties);
-    if (string_eq(pName, "vkCreateInstance")) return TO_VOID_PFN(test_vkCreateInstance);
-    if (string_eq(pName, "vkDestroyInstance")) return TO_VOID_PFN(test_vkDestroyInstance);
-    if (string_eq(pName, "vkCreateDevice")) return TO_VOID_PFN(test_vkCreateDevice);
-    if (string_eq(pName, "vkGetDeviceProcAddr")) return TO_VOID_PFN(get_device_func);
+    if (string_eq(pName, "vkGetInstanceProcAddr")) return to_vkVoidFunction(get_instance_func);
+    if (string_eq(pName, "vkEnumerateInstanceLayerProperties")) return to_vkVoidFunction(test_vkEnumerateInstanceLayerProperties);
+    if (string_eq(pName, "vkEnumerateInstanceExtensionProperties"))
+        return to_vkVoidFunction(test_vkEnumerateInstanceExtensionProperties);
+    if (string_eq(pName, "vkEnumerateInstanceVersion")) return to_vkVoidFunction(test_vkEnumerateInstanceVersion);
+
+    if (string_eq(pName, "vkEnumerateDeviceLayerProperties")) return to_vkVoidFunction(test_vkEnumerateDeviceLayerProperties);
+    if (string_eq(pName, "vkEnumerateDeviceExtensionProperties"))
+        return to_vkVoidFunction(test_vkEnumerateDeviceExtensionProperties);
+    if (string_eq(pName, "vkCreateInstance")) return to_vkVoidFunction(test_vkCreateInstance);
+    if (string_eq(pName, "vkDestroyInstance")) return to_vkVoidFunction(test_vkDestroyInstance);
+    if (string_eq(pName, "vkCreateDevice")) return to_vkVoidFunction(test_vkCreateDevice);
+    if (string_eq(pName, "vkGetDeviceProcAddr")) return to_vkVoidFunction(get_device_func);
 
     return layer.next_vkGetInstanceProcAddr(instance, pName);
 }
index 1b065f4e48ba0bda36abf3c422aee219ea32713d..b7ef30441eaa2deb515e8a4a1abfb2db95706181 100644 (file)
@@ -279,12 +279,12 @@ HRESULT __stdcall ShimCreateDXGIFactory1(REFIID riid, void **ppFactory) {
 void WINAPI DetourFunctions() {
     if (!gdi32_dll) {
         gdi32_dll = LibraryWrapper("gdi32.dll");
-        fpEnumAdapters2 = gdi32_dll.get_symbol<PFN_LoaderEnumAdapters2>("D3DKMTEnumAdapters2");
+        fpEnumAdapters2 = gdi32_dll.get_symbol("D3DKMTEnumAdapters2");
         if (fpEnumAdapters2 == nullptr) {
             std::cerr << "Failed to load D3DKMTEnumAdapters2\n";
             return;
         }
-        fpQueryAdapterInfo = gdi32_dll.get_symbol<PFN_LoaderQueryAdapterInfo>("D3DKMTQueryAdapterInfo");
+        fpQueryAdapterInfo = gdi32_dll.get_symbol("D3DKMTQueryAdapterInfo");
         if (fpQueryAdapterInfo == nullptr) {
             std::cerr << "Failed to load D3DKMTQueryAdapterInfo\n";
             return;
@@ -295,7 +295,7 @@ void WINAPI DetourFunctions() {
         GetSystemDirectory(systemPath, MAX_PATH);
         StringCchCat(systemPath, MAX_PATH, TEXT("\\dxgi.dll"));
         dxgi_module = LibraryWrapper(systemPath);
-        RealCreateDXGIFactory1 = dxgi_module.get_symbol<PFN_CreateDXGIFactory1>("CreateDXGIFactory1");
+        RealCreateDXGIFactory1 = dxgi_module.get_symbol("CreateDXGIFactory1");
         if (RealCreateDXGIFactory1 == nullptr) {
             std::cerr << "Failed to load CreateDXGIFactory1\n";
         }
index f60948f196923d0491f6ef3a023dc16895bf1802..48ea2764271343bfda42c46c2babc18a2247dc76 100644 (file)
@@ -117,7 +117,7 @@ void FillDebugUtilsCreateDetails(InstanceCreateInfo& create_info, DebugUtilsWrap
 PlatformShimWrapper::PlatformShimWrapper(DebugMode debug_mode) noexcept : debug_mode(debug_mode) {
 #if defined(WIN32) || defined(__APPLE__)
     shim_library = LibraryWrapper(SHIM_LIBRARY_NAME);
-    auto get_platform_shim_func = shim_library.get_symbol<PFN_get_platform_shim>(GET_PLATFORM_SHIM_STR);
+    PFN_get_platform_shim get_platform_shim_func = shim_library.get_symbol(GET_PLATFORM_SHIM_STR);
     assert(get_platform_shim_func != NULL && "Must be able to get \"platform_shim\"");
     platform_shim = get_platform_shim_func();
 #elif defined(__linux__) || defined(__FreeBSD__)
@@ -132,8 +132,8 @@ PlatformShimWrapper::~PlatformShimWrapper() noexcept { platform_shim->reset(debu
 
 TestICDHandle::TestICDHandle() noexcept {}
 TestICDHandle::TestICDHandle(fs::path const& icd_path) noexcept : icd_library(icd_path) {
-    proc_addr_get_test_icd = icd_library.get_symbol<GetNewTestICDFunc>(GET_TEST_ICD_FUNC_STR);
-    proc_addr_reset_icd = icd_library.get_symbol<GetNewTestICDFunc>(RESET_ICD_FUNC_STR);
+    proc_addr_get_test_icd = icd_library.get_symbol(GET_TEST_ICD_FUNC_STR);
+    proc_addr_reset_icd = icd_library.get_symbol(RESET_ICD_FUNC_STR);
 }
 TestICD& TestICDHandle::get_test_icd() noexcept {
     assert(proc_addr_get_test_icd != NULL && "symbol must be loaded before use");
@@ -147,8 +147,8 @@ fs::path TestICDHandle::get_icd_full_path() noexcept { return icd_library.lib_pa
 
 TestLayerHandle::TestLayerHandle() noexcept {}
 TestLayerHandle::TestLayerHandle(fs::path const& layer_path) noexcept : layer_library(layer_path) {
-    proc_addr_get_test_layer = layer_library.get_symbol<GetNewTestLayerFunc>(GET_TEST_LAYER_FUNC_STR);
-    proc_addr_reset_layer = layer_library.get_symbol<GetNewTestLayerFunc>(RESET_LAYER_FUNC_STR);
+    proc_addr_get_test_layer = layer_library.get_symbol(GET_TEST_LAYER_FUNC_STR);
+    proc_addr_reset_layer = layer_library.get_symbol(RESET_LAYER_FUNC_STR);
 }
 TestLayer& TestLayerHandle::get_test_layer() noexcept {
     assert(proc_addr_get_test_layer != NULL && "symbol must be loaded before use");
index 56c9a01dd9b9ef05fedb5786b10eafb58719d9a8..e92136f6977294784e08be8dd045763b10e61b54 100644 (file)
@@ -506,107 +506,118 @@ fs::path get_loader_path() {
 
 VulkanFunctions::VulkanFunctions() : loader(get_loader_path()) {
     // clang-format off
-    vkGetInstanceProcAddr = loader.get_symbol<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
-    vkEnumerateInstanceExtensionProperties = loader.get_symbol<PFN_vkEnumerateInstanceExtensionProperties>("vkEnumerateInstanceExtensionProperties");
-    vkEnumerateInstanceLayerProperties = loader.get_symbol<PFN_vkEnumerateInstanceLayerProperties>("vkEnumerateInstanceLayerProperties");
-    vkEnumerateInstanceVersion = loader.get_symbol<PFN_vkEnumerateInstanceVersion>("vkEnumerateInstanceVersion");
-    vkCreateInstance = loader.get_symbol<PFN_vkCreateInstance>("vkCreateInstance");
-    vkDestroyInstance = loader.get_symbol<PFN_vkDestroyInstance>("vkDestroyInstance");
-    vkEnumeratePhysicalDevices = loader.get_symbol<PFN_vkEnumeratePhysicalDevices>("vkEnumeratePhysicalDevices");
-    vkEnumeratePhysicalDeviceGroups = loader.get_symbol<PFN_vkEnumeratePhysicalDeviceGroups>("vkEnumeratePhysicalDeviceGroups");
-    vkGetPhysicalDeviceFeatures = loader.get_symbol<PFN_vkGetPhysicalDeviceFeatures>("vkGetPhysicalDeviceFeatures");
-    vkGetPhysicalDeviceFeatures2 = loader.get_symbol<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2");
-    vkGetPhysicalDeviceFormatProperties = loader.get_symbol<PFN_vkGetPhysicalDeviceFormatProperties>("vkGetPhysicalDeviceFormatProperties");
-    vkGetPhysicalDeviceFormatProperties2 = loader.get_symbol<PFN_vkGetPhysicalDeviceFormatProperties2>("vkGetPhysicalDeviceFormatProperties2");
-    vkGetPhysicalDeviceImageFormatProperties = loader.get_symbol<PFN_vkGetPhysicalDeviceImageFormatProperties>("vkGetPhysicalDeviceImageFormatProperties");
-    vkGetPhysicalDeviceImageFormatProperties2 = loader.get_symbol<PFN_vkGetPhysicalDeviceImageFormatProperties2>("vkGetPhysicalDeviceImageFormatProperties2");
-    vkGetPhysicalDeviceSparseImageFormatProperties = loader.get_symbol<PFN_vkGetPhysicalDeviceSparseImageFormatProperties>("vkGetPhysicalDeviceSparseImageFormatProperties");
-    vkGetPhysicalDeviceSparseImageFormatProperties2 = loader.get_symbol<PFN_vkGetPhysicalDeviceSparseImageFormatProperties2>("vkGetPhysicalDeviceSparseImageFormatProperties2");
-    vkGetPhysicalDeviceProperties = loader.get_symbol<PFN_vkGetPhysicalDeviceProperties>("vkGetPhysicalDeviceProperties");
-    vkGetPhysicalDeviceProperties2 = loader.get_symbol<PFN_vkGetPhysicalDeviceProperties2>("vkGetPhysicalDeviceProperties2");
-    vkGetPhysicalDeviceQueueFamilyProperties = loader.get_symbol<PFN_vkGetPhysicalDeviceQueueFamilyProperties>("vkGetPhysicalDeviceQueueFamilyProperties");
-    vkGetPhysicalDeviceQueueFamilyProperties2 = loader.get_symbol<PFN_vkGetPhysicalDeviceQueueFamilyProperties2>("vkGetPhysicalDeviceQueueFamilyProperties2");
-    vkGetPhysicalDeviceMemoryProperties = loader.get_symbol<PFN_vkGetPhysicalDeviceMemoryProperties>("vkGetPhysicalDeviceMemoryProperties");
-    vkGetPhysicalDeviceMemoryProperties2 = loader.get_symbol<PFN_vkGetPhysicalDeviceMemoryProperties2>("vkGetPhysicalDeviceMemoryProperties2");
-    vkGetPhysicalDeviceSurfaceSupportKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceSurfaceSupportKHR>("vkGetPhysicalDeviceSurfaceSupportKHR");
-    vkGetPhysicalDeviceSurfaceFormatsKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR>("vkGetPhysicalDeviceSurfaceFormatsKHR");
-    vkGetPhysicalDeviceSurfacePresentModesKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR>("vkGetPhysicalDeviceSurfacePresentModesKHR");
-    vkGetPhysicalDeviceSurfaceCapabilitiesKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR>("vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
-    vkEnumerateDeviceExtensionProperties = loader.get_symbol<PFN_vkEnumerateDeviceExtensionProperties>("vkEnumerateDeviceExtensionProperties");
-    vkEnumerateDeviceLayerProperties = loader.get_symbol<PFN_vkEnumerateDeviceLayerProperties>("vkEnumerateDeviceLayerProperties");
-    vkGetPhysicalDeviceExternalBufferProperties = loader.get_symbol<PFN_vkGetPhysicalDeviceExternalBufferProperties>("vkGetPhysicalDeviceExternalBufferProperties");
-    vkGetPhysicalDeviceExternalFenceProperties = loader.get_symbol<PFN_vkGetPhysicalDeviceExternalFenceProperties>("vkGetPhysicalDeviceExternalFenceProperties");
-    vkGetPhysicalDeviceExternalSemaphoreProperties = loader.get_symbol<PFN_vkGetPhysicalDeviceExternalSemaphoreProperties>("vkGetPhysicalDeviceExternalSemaphoreProperties");
-
-    vkDestroySurfaceKHR = loader.get_symbol<PFN_vkDestroySurfaceKHR>("vkDestroySurfaceKHR");
-    vkGetDeviceProcAddr = loader.get_symbol<PFN_vkGetDeviceProcAddr>("vkGetDeviceProcAddr");
-    vkCreateDevice = loader.get_symbol<PFN_vkCreateDevice>("vkCreateDevice");
-
-    vkCreateHeadlessSurfaceEXT = loader.get_symbol<PFN_vkCreateHeadlessSurfaceEXT>("vkCreateHeadlessSurfaceEXT");
-    vkCreateDisplayPlaneSurfaceKHR = loader.get_symbol<PFN_vkCreateDisplayPlaneSurfaceKHR>("vkCreateDisplayPlaneSurfaceKHR");
-    vkGetPhysicalDeviceDisplayPropertiesKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceDisplayPropertiesKHR>("vkGetPhysicalDeviceDisplayPropertiesKHR");
-    vkGetPhysicalDeviceDisplayPlanePropertiesKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR>("vkGetPhysicalDeviceDisplayPlanePropertiesKHR");
-    vkGetDisplayPlaneSupportedDisplaysKHR = loader.get_symbol<PFN_vkGetDisplayPlaneSupportedDisplaysKHR>("vkGetDisplayPlaneSupportedDisplaysKHR");
-    vkGetDisplayModePropertiesKHR = loader.get_symbol<PFN_vkGetDisplayModePropertiesKHR>("vkGetDisplayModePropertiesKHR");
-    vkCreateDisplayModeKHR = loader.get_symbol<PFN_vkCreateDisplayModeKHR>("vkCreateDisplayModeKHR");
-    vkGetDisplayPlaneCapabilitiesKHR = loader.get_symbol<PFN_vkGetDisplayPlaneCapabilitiesKHR>("vkGetDisplayPlaneCapabilitiesKHR");
-    vkGetPhysicalDevicePresentRectanglesKHR = loader.get_symbol<PFN_vkGetPhysicalDevicePresentRectanglesKHR>("vkGetPhysicalDevicePresentRectanglesKHR");
-    vkGetPhysicalDeviceDisplayProperties2KHR = loader.get_symbol<PFN_vkGetPhysicalDeviceDisplayProperties2KHR>("vkGetPhysicalDeviceDisplayProperties2KHR");
-    vkGetPhysicalDeviceDisplayPlaneProperties2KHR = loader.get_symbol<PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR>("vkGetPhysicalDeviceDisplayPlaneProperties2KHR");
-    vkGetDisplayModeProperties2KHR = loader.get_symbol<PFN_vkGetDisplayModeProperties2KHR>("vkGetDisplayModeProperties2KHR");
-    vkGetDisplayPlaneCapabilities2KHR = loader.get_symbol<PFN_vkGetDisplayPlaneCapabilities2KHR>("vkGetDisplayPlaneCapabilities2KHR");
-    vkGetPhysicalDeviceSurfaceCapabilities2KHR = loader.get_symbol<PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR>("vkGetPhysicalDeviceSurfaceCapabilities2KHR");
-    vkGetPhysicalDeviceSurfaceFormats2KHR = loader.get_symbol<PFN_vkGetPhysicalDeviceSurfaceFormats2KHR>("vkGetPhysicalDeviceSurfaceFormats2KHR");
+    vkGetInstanceProcAddr = loader.get_symbol("vkGetInstanceProcAddr");
+    vkEnumerateInstanceExtensionProperties = loader.get_symbol("vkEnumerateInstanceExtensionProperties");
+    vkEnumerateInstanceLayerProperties = loader.get_symbol("vkEnumerateInstanceLayerProperties");
+    vkEnumerateInstanceVersion = loader.get_symbol("vkEnumerateInstanceVersion");
+    vkCreateInstance = loader.get_symbol("vkCreateInstance");
+    vkDestroyInstance = loader.get_symbol("vkDestroyInstance");
+    vkEnumeratePhysicalDevices = loader.get_symbol("vkEnumeratePhysicalDevices");
+    vkEnumeratePhysicalDeviceGroups = loader.get_symbol("vkEnumeratePhysicalDeviceGroups");
+    vkGetPhysicalDeviceFeatures = loader.get_symbol("vkGetPhysicalDeviceFeatures");
+    vkGetPhysicalDeviceFeatures2 = loader.get_symbol("vkGetPhysicalDeviceFeatures2");
+    vkGetPhysicalDeviceFormatProperties = loader.get_symbol("vkGetPhysicalDeviceFormatProperties");
+    vkGetPhysicalDeviceFormatProperties2 = loader.get_symbol("vkGetPhysicalDeviceFormatProperties2");
+    vkGetPhysicalDeviceImageFormatProperties = loader.get_symbol("vkGetPhysicalDeviceImageFormatProperties");
+    vkGetPhysicalDeviceImageFormatProperties2 = loader.get_symbol("vkGetPhysicalDeviceImageFormatProperties2");
+    vkGetPhysicalDeviceSparseImageFormatProperties = loader.get_symbol("vkGetPhysicalDeviceSparseImageFormatProperties");
+    vkGetPhysicalDeviceSparseImageFormatProperties2 = loader.get_symbol("vkGetPhysicalDeviceSparseImageFormatProperties2");
+    vkGetPhysicalDeviceProperties = loader.get_symbol("vkGetPhysicalDeviceProperties");
+    vkGetPhysicalDeviceProperties2 = loader.get_symbol("vkGetPhysicalDeviceProperties2");
+    vkGetPhysicalDeviceQueueFamilyProperties = loader.get_symbol("vkGetPhysicalDeviceQueueFamilyProperties");
+    vkGetPhysicalDeviceQueueFamilyProperties2 = loader.get_symbol("vkGetPhysicalDeviceQueueFamilyProperties2");
+    vkGetPhysicalDeviceMemoryProperties = loader.get_symbol("vkGetPhysicalDeviceMemoryProperties");
+    vkGetPhysicalDeviceMemoryProperties2 = loader.get_symbol("vkGetPhysicalDeviceMemoryProperties2");
+    vkGetPhysicalDeviceSurfaceSupportKHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceSupportKHR");
+    vkGetPhysicalDeviceSurfaceFormatsKHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceFormatsKHR");
+    vkGetPhysicalDeviceSurfacePresentModesKHR = loader.get_symbol("vkGetPhysicalDeviceSurfacePresentModesKHR");
+    vkGetPhysicalDeviceSurfaceCapabilitiesKHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
+    vkEnumerateDeviceExtensionProperties = loader.get_symbol("vkEnumerateDeviceExtensionProperties");
+    vkEnumerateDeviceLayerProperties = loader.get_symbol("vkEnumerateDeviceLayerProperties");
+    vkGetPhysicalDeviceExternalBufferProperties = loader.get_symbol("vkGetPhysicalDeviceExternalBufferProperties");
+    vkGetPhysicalDeviceExternalFenceProperties = loader.get_symbol("vkGetPhysicalDeviceExternalFenceProperties");
+    vkGetPhysicalDeviceExternalSemaphoreProperties = loader.get_symbol("vkGetPhysicalDeviceExternalSemaphoreProperties");
+
+    vkDestroySurfaceKHR = loader.get_symbol("vkDestroySurfaceKHR");
+    vkGetDeviceProcAddr = loader.get_symbol("vkGetDeviceProcAddr");
+    vkCreateDevice = loader.get_symbol("vkCreateDevice");
+
+    vkCreateHeadlessSurfaceEXT = loader.get_symbol("vkCreateHeadlessSurfaceEXT");
+    vkCreateDisplayPlaneSurfaceKHR = loader.get_symbol("vkCreateDisplayPlaneSurfaceKHR");
+    vkGetPhysicalDeviceDisplayPropertiesKHR = loader.get_symbol("vkGetPhysicalDeviceDisplayPropertiesKHR");
+    vkGetPhysicalDeviceDisplayPlanePropertiesKHR = loader.get_symbol("vkGetPhysicalDeviceDisplayPlanePropertiesKHR");
+    vkGetDisplayPlaneSupportedDisplaysKHR = loader.get_symbol("vkGetDisplayPlaneSupportedDisplaysKHR");
+    vkGetDisplayModePropertiesKHR = loader.get_symbol("vkGetDisplayModePropertiesKHR");
+    vkCreateDisplayModeKHR = loader.get_symbol("vkCreateDisplayModeKHR");
+    vkGetDisplayPlaneCapabilitiesKHR = loader.get_symbol("vkGetDisplayPlaneCapabilitiesKHR");
+    vkGetPhysicalDevicePresentRectanglesKHR = loader.get_symbol("vkGetPhysicalDevicePresentRectanglesKHR");
+    vkGetPhysicalDeviceDisplayProperties2KHR = loader.get_symbol("vkGetPhysicalDeviceDisplayProperties2KHR");
+    vkGetPhysicalDeviceDisplayPlaneProperties2KHR = loader.get_symbol("vkGetPhysicalDeviceDisplayPlaneProperties2KHR");
+    vkGetDisplayModeProperties2KHR = loader.get_symbol("vkGetDisplayModeProperties2KHR");
+    vkGetDisplayPlaneCapabilities2KHR = loader.get_symbol("vkGetDisplayPlaneCapabilities2KHR");
+    vkGetPhysicalDeviceSurfaceCapabilities2KHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceCapabilities2KHR");
+    vkGetPhysicalDeviceSurfaceFormats2KHR = loader.get_symbol("vkGetPhysicalDeviceSurfaceFormats2KHR");
 
 #ifdef VK_USE_PLATFORM_ANDROID_KHR
-    vkCreateAndroidSurfaceKHR = loader.get_symbol<PFN_vkCreateAndroidSurfaceKHR>("vkCreateAndroidSurfaceKHR");
+    vkCreateAndroidSurfaceKHR = loader.get_symbol("vkCreateAndroidSurfaceKHR");
 #endif  // VK_USE_PLATFORM_ANDROID_KHR
 #ifdef VK_USE_PLATFORM_DIRECTFB_EXT
-    vkCreateDirectFBSurfaceEXT = loader.get_symbol<PFN_vkCreateDirectFBSurfaceEXT>("vkCreateDirectFBSurfaceEXT");
-    vkGetPhysicalDeviceDirectFBPresentationSupportEXT = loader.get_symbol<PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT>("vkGetPhysicalDeviceDirectFBPresentationSupportEXT");
+    vkCreateDirectFBSurfaceEXT = loader.get_symbol("vkCreateDirectFBSurfaceEXT");
+    vkGetPhysicalDeviceDirectFBPresentationSupportEXT = loader.get_symbol("vkGetPhysicalDeviceDirectFBPresentationSupportEXT");
 #endif  // VK_USE_PLATFORM_DIRECTFB_EXT
 #ifdef VK_USE_PLATFORM_FUCHSIA
-    vkCreateImagePipeSurfaceFUCHSIA = loader.get_symbol<PFN_vkCreateImagePipeSurfaceFUCHSIA>("vkCreateImagePipeSurfaceFUCHSIA");
+    vkCreateImagePipeSurfaceFUCHSIA = loader.get_symbol("vkCreateImagePipeSurfaceFUCHSIA");
 #endif  // VK_USE_PLATFORM_FUCHSIA
 #ifdef VK_USE_PLATFORM_GGP
-    vkCreateStreamDescriptorSurfaceGGP = loader.get_symbol<PFN_vkCreateStreamDescriptorSurfaceGGP>("vkCreateStreamDescriptorSurfaceGGP");
+    vkCreateStreamDescriptorSurfaceGGP = loader.get_symbol("vkCreateStreamDescriptorSurfaceGGP");
 #endif  // VK_USE_PLATFORM_GGP
 #ifdef VK_USE_PLATFORM_IOS_MVK
-    vkCreateIOSSurfaceMVK = loader.get_symbol<PFN_vkCreateIOSSurfaceMVK>("vkCreateIOSSurfaceMVK");
+    vkCreateIOSSurfaceMVK = loader.get_symbol("vkCreateIOSSurfaceMVK");
 #endif  // VK_USE_PLATFORM_IOS_MVK
 #ifdef VK_USE_PLATFORM_MACOS_MVK
-    vkCreateMacOSSurfaceMVK = loader.get_symbol<PFN_vkCreateMacOSSurfaceMVK>("vkCreateMacOSSurfaceMVK");
+    vkCreateMacOSSurfaceMVK = loader.get_symbol("vkCreateMacOSSurfaceMVK");
 #endif  // VK_USE_PLATFORM_MACOS_MVK
 #ifdef VK_USE_PLATFORM_METAL_EXT
-    vkCreateMetalSurfaceEXT = loader.get_symbol<PFN_vkCreateMetalSurfaceEXT>("vkCreateMetalSurfaceEXT");
+    vkCreateMetalSurfaceEXT = loader.get_symbol("vkCreateMetalSurfaceEXT");
 #endif  // VK_USE_PLATFORM_METAL_EXT
 #ifdef VK_USE_PLATFORM_SCREEN_QNX
-    vkCreateScreenSurfaceQNX = loader.get_symbol<PFN_vkCreateScreenSurfaceQNX>("vkCreateScreenSurfaceQNX");
-    vkGetPhysicalDeviceScreenPresentationSupportQNX = loader.get_symbol<PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX>("vkGetPhysicalDeviceScreenPresentationSupportQNX");
+    vkCreateScreenSurfaceQNX = loader.get_symbol("vkCreateScreenSurfaceQNX");
+    vkGetPhysicalDeviceScreenPresentationSupportQNX = loader.get_symbol("vkGetPhysicalDeviceScreenPresentationSupportQNX");
 #endif  // VK_USE_PLATFORM_SCREEN_QNX
 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
-    vkCreateWaylandSurfaceKHR = loader.get_symbol<PFN_vkCreateWaylandSurfaceKHR>("vkCreateWaylandSurfaceKHR");
-    vkGetPhysicalDeviceWaylandPresentationSupportKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR>("vkGetPhysicalDeviceWaylandPresentationSupportKHR");
+    vkCreateWaylandSurfaceKHR = loader.get_symbol("vkCreateWaylandSurfaceKHR");
+    vkGetPhysicalDeviceWaylandPresentationSupportKHR = loader.get_symbol("vkGetPhysicalDeviceWaylandPresentationSupportKHR");
 #endif  // VK_USE_PLATFORM_WAYLAND_KHR
 #ifdef VK_USE_PLATFORM_XCB_KHR
-    vkCreateXcbSurfaceKHR = loader.get_symbol<PFN_vkCreateXcbSurfaceKHR>("vkCreateXcbSurfaceKHR");
-    vkGetPhysicalDeviceXcbPresentationSupportKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR>("vkGetPhysicalDeviceXcbPresentationSupportKHR");
+    vkCreateXcbSurfaceKHR = loader.get_symbol("vkCreateXcbSurfaceKHR");
+    vkGetPhysicalDeviceXcbPresentationSupportKHR = loader.get_symbol("vkGetPhysicalDeviceXcbPresentationSupportKHR");
 #endif  // VK_USE_PLATFORM_XCB_KHR
 #ifdef VK_USE_PLATFORM_XLIB_KHR
-    vkCreateXlibSurfaceKHR = loader.get_symbol<PFN_vkCreateXlibSurfaceKHR>("vkCreateXlibSurfaceKHR");
-    vkGetPhysicalDeviceXlibPresentationSupportKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR>("vkGetPhysicalDeviceXlibPresentationSupportKHR");
+    vkCreateXlibSurfaceKHR = loader.get_symbol("vkCreateXlibSurfaceKHR");
+    vkGetPhysicalDeviceXlibPresentationSupportKHR = loader.get_symbol("vkGetPhysicalDeviceXlibPresentationSupportKHR");
 #endif  // VK_USE_PLATFORM_XLIB_KHR
 #ifdef VK_USE_PLATFORM_WIN32_KHR
-    vkCreateWin32SurfaceKHR = loader.get_symbol<PFN_vkCreateWin32SurfaceKHR>("vkCreateWin32SurfaceKHR");
-    vkGetPhysicalDeviceWin32PresentationSupportKHR = loader.get_symbol<PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR>("vkGetPhysicalDeviceWin32PresentationSupportKHR");
+    vkCreateWin32SurfaceKHR = loader.get_symbol("vkCreateWin32SurfaceKHR");
+    vkGetPhysicalDeviceWin32PresentationSupportKHR = loader.get_symbol("vkGetPhysicalDeviceWin32PresentationSupportKHR");
 #endif  // VK_USE_PLATFORM_WIN32_KHR
 
-    vkDestroyDevice = loader.get_symbol<PFN_vkDestroyDevice>("vkDestroyDevice");
-    vkGetDeviceQueue = loader.get_symbol<PFN_vkGetDeviceQueue>("vkGetDeviceQueue");
+    vkDestroyDevice = loader.get_symbol("vkDestroyDevice");
+    vkGetDeviceQueue = loader.get_symbol("vkGetDeviceQueue");
 
     // clang-format on
 }
 
+DeviceFunctions::DeviceFunctions(const VulkanFunctions& vulkan_functions, VkDevice device) {
+    vkGetDeviceProcAddr = vulkan_functions.vkGetDeviceProcAddr;
+    vkDestroyDevice = load(device, "vkDestroyDevice");
+    vkGetDeviceQueue = load(device, "vkGetDeviceQueue");
+    vkCreateCommandPool = load(device, "vkCreateCommandPool");
+    vkAllocateCommandBuffers = load(device, "vkAllocateCommandBuffers");
+    vkDestroyCommandPool = load(device, "vkDestroyCommandPool");
+    vkCreateSwapchainKHR = load(device, "vkCreateSwapchainKHR");
+    vkDestroySwapchainKHR = load(device, "vkDestroySwapchainKHR");
+}
+
 InstanceCreateInfo::InstanceCreateInfo() {
     instance_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
     application_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
index 6994883176b54c27024db08dba753d33ba5bbea1..4dc0d9f106b63e4909182b9584ffb1ebe0031680 100644 (file)
@@ -297,6 +297,20 @@ inline void* loader_platform_get_proc_address(loader_platform_dl_handle library,
 inline const char* loader_platform_get_proc_address_error(const char* name) { return dlerror(); }
 #endif
 
+class FromVoidStarFunc {
+   private:
+    void* function;
+
+   public:
+    FromVoidStarFunc(void* function) : function(function) {}
+    FromVoidStarFunc(PFN_vkVoidFunction function) : function(reinterpret_cast<void*>(function)) {}
+
+    template <typename T>
+    operator T() {
+        return reinterpret_cast<T>(function);
+    }
+};
+
 struct LibraryWrapper {
     explicit LibraryWrapper() noexcept {}
     explicit LibraryWrapper(fs::path const& lib_path) noexcept : lib_path(lib_path) {
@@ -329,15 +343,14 @@ struct LibraryWrapper {
         }
         return *this;
     }
-    template <typename T>
-    T get_symbol(const char* symbol_name) const {
-        assert(lib_handle != NULL && "Cannot get symbol with null library handle");
-        T symbol = reinterpret_cast<T>(loader_platform_get_proc_address(lib_handle, symbol_name));
-        if (symbol == NULL) {
+    FromVoidStarFunc get_symbol(const char* symbol_name) const {
+        assert(lib_handle != nullptr && "Cannot get symbol with null library handle");
+        void* symbol = loader_platform_get_proc_address(lib_handle, symbol_name);
+        if (symbol == nullptr) {
             fprintf(stderr, "Unable to open symbol %s: %s\n", symbol_name, loader_platform_get_proc_address_error(symbol_name));
-            assert(symbol != NULL && "Must be able to get symbol");
+            assert(symbol != nullptr && "Must be able to get symbol");
         }
-        return symbol;
+        return FromVoidStarFunc(symbol);
     }
 
     explicit operator bool() const noexcept { return lib_handle != nullptr; }
@@ -346,6 +359,10 @@ struct LibraryWrapper {
     fs::path lib_path;
 };
 
+template <typename T>
+PFN_vkVoidFunction to_vkVoidFunction(T func) {
+    return reinterpret_cast<PFN_vkVoidFunction>(func);
+}
 template <typename T>
 struct FRAMEWORK_EXPORT DispatchableHandle {
     DispatchableHandle() {
@@ -713,6 +730,32 @@ struct VulkanFunctions {
     PFN_vkGetDeviceQueue vkGetDeviceQueue = nullptr;
 
     VulkanFunctions();
+
+    FromVoidStarFunc load(VkInstance inst, const char* func_name) {
+        return FromVoidStarFunc(vkGetInstanceProcAddr(inst, func_name));
+    }
+
+    FromVoidStarFunc load(VkDevice device, const char* func_name) {
+        return FromVoidStarFunc(vkGetDeviceProcAddr(device, func_name));
+    }
+};
+
+struct DeviceFunctions {
+    PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr = nullptr;
+    PFN_vkDestroyDevice vkDestroyDevice = nullptr;
+    PFN_vkGetDeviceQueue vkGetDeviceQueue = nullptr;
+    PFN_vkCreateCommandPool vkCreateCommandPool = nullptr;
+    PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers = nullptr;
+    PFN_vkDestroyCommandPool vkDestroyCommandPool = nullptr;
+    PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR = nullptr;
+    PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR = nullptr;
+
+    DeviceFunctions() = default;
+    DeviceFunctions(const VulkanFunctions& vulkan_functions, VkDevice device);
+
+    FromVoidStarFunc load(VkDevice device, const char* func_name) const {
+        return FromVoidStarFunc(vkGetDeviceProcAddr(device, func_name));
+    }
 };
 
 struct InstanceCreateInfo {
index 346f2591a3fc4561e89def13e76563eaac85560c..4e836de410817e0b01e0ec3273bb8bf2fd4c88b0 100644 (file)
@@ -1427,7 +1427,7 @@ static uint32_t FillInRandomQueueFamilyData(std::vector<MockQueueFamilyPropertie
         props[i].properties.minImageTransferGranularity.depth = (rand() % 30) + 1;
         props[i].support_present = (rand() % 2);
     }
-    return props.size();
+    return static_cast<uint32_t>(props.size());
 }
 
 // Compare the queue family structs
@@ -5346,7 +5346,7 @@ TEST(LoaderInstPhysDevExts, DifferentPhysicalDeviceExtensions) {
         bool supports_timestamps = false;
         ASSERT_EQ(VK_SUCCESS,
                   inst->vkEnumerateDeviceExtensionProperties(physical_devices[dev], nullptr, &extension_count, nullptr));
-        ASSERT_GT(extension_count, 0);
+        ASSERT_GT(extension_count, 0U);
         device_extensions.resize(extension_count);
         ASSERT_EQ(VK_SUCCESS, inst->vkEnumerateDeviceExtensionProperties(physical_devices[dev], nullptr, &extension_count,
                                                                          device_extensions.data()));