MCPcopy Create free account
hub / github.com/SFML/SFML / isAvailable

Method isAvailable

src/SFML/Window/Win32/VulkanImplWin32.cpp:108–162  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

loadLibraryMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected