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

Method createVulkanSurface

src/SFML/Window/Unix/VulkanImplX11.cpp:185–213  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

183
184////////////////////////////////////////////////////////////
185bool VulkanImpl::createVulkanSurface(const VkInstance& instance,
186 WindowHandle windowHandle,
187 VkSurfaceKHR& surface,
188 const VkAllocationCallbacks* allocator)
189{
190 if (!isAvailable())
191 return false;
192
193 // Make a copy of the instance handle since we get it passed as a reference
194 VkInstance inst = instance;
195
196 auto vkCreateXlibSurfaceKHR = reinterpret_cast<PFN_vkCreateXlibSurfaceKHR>(
197 wrapper.vkGetInstanceProcAddr(inst, "vkCreateXlibSurfaceKHR"));
198
199 if (!vkCreateXlibSurfaceKHR)
200 return false;
201
202 // Since the surface is basically attached to the window, the connection
203 // to the X display will stay open even after we open and close it here
204 const auto display = openDisplay();
205 VkXlibSurfaceCreateInfoKHR surfaceCreateInfo = VkXlibSurfaceCreateInfoKHR();
206 surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
207 surfaceCreateInfo.dpy = display.get();
208 surfaceCreateInfo.window = windowHandle;
209
210 const bool result = (vkCreateXlibSurfaceKHR(instance, &surfaceCreateInfo, allocator, &surface) == VK_SUCCESS);
211
212 return result;
213}
214
215} // namespace sf::priv

Callers

nothing calls this directly

Calls 4

openDisplayFunction · 0.85
getMethod · 0.80
isAvailableFunction · 0.50

Tested by

no test coverage detected