///////////////////////////////////////////////////////
| 107 | { |
| 108 | //////////////////////////////////////////////////////////// |
| 109 | bool VulkanImpl::isAvailable(bool requireGraphics) |
| 110 | { |
| 111 | static bool checked = false; |
| 112 | static bool computeAvailable = false; |
| 113 | static bool graphicsAvailable = false; |
| 114 | |
| 115 | if (!checked) |
| 116 | { |
| 117 | checked = true; |
| 118 | |
| 119 | // Check if the library is available |
| 120 | computeAvailable = wrapper.loadLibrary(); |
| 121 | |
| 122 | // To check for instance extensions we don't need to differentiate between graphics and compute |
| 123 | graphicsAvailable = computeAvailable; |
| 124 | |
| 125 | if (graphicsAvailable) |
| 126 | { |
| 127 | // Retrieve the available instance extensions |
| 128 | std::vector<VkExtensionProperties> extensionProperties; |
| 129 | |
| 130 | std::uint32_t extensionCount = 0; |
| 131 | |
| 132 | wrapper.vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr); |
| 133 | |
| 134 | extensionProperties.resize(extensionCount); |
| 135 | |
| 136 | wrapper.vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensionProperties.data()); |
| 137 | |
| 138 | // Check if the necessary extensions are available |
| 139 | bool hasVkKhrSurface = false; |
| 140 | bool hasVkKhrPlatformSurface = false; |
| 141 | |
| 142 | for (const VkExtensionProperties& properties : extensionProperties) |
| 143 | { |
| 144 | if (std::string_view(properties.extensionName) == VK_KHR_SURFACE_EXTENSION_NAME) |
| 145 | { |
| 146 | hasVkKhrSurface = true; |
| 147 | } |
| 148 | else if (std::string_view(properties.extensionName) == VK_KHR_XLIB_SURFACE_EXTENSION_NAME) |
| 149 | { |
| 150 | hasVkKhrPlatformSurface = true; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | if (!hasVkKhrSurface || !hasVkKhrPlatformSurface) |
| 155 | graphicsAvailable = false; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | if (requireGraphics) |
| 160 | return graphicsAvailable; |
| 161 | |
| 162 | return computeAvailable; |
| 163 | } |
| 164 | |
| 165 | |
| 166 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected