Vulkan Surface

Being platform agnostic, Vulkan interfaces with the WSI via the VK_KHR_surface extension. A Surface enables displaying images on the window through the presentation engine.

Add another helper function in window.hpp/cpp:

auto glfw::create_surface(GLFWwindow* window, vk::Instance const instance) -> vk::UniqueSurfaceKHR { VkSurfaceKHR ret{}; auto const result = glfwCreateWindowSurface(instance, window, nullptr, &ret); if (result != VK_SUCCESS || ret == VkSurfaceKHR{}) { throw std::runtime_error{"Failed to create Vulkan Surface"}; } return vk::UniqueSurfaceKHR{ret, instance}; }

Add a vk::UniqueSurfaceKHR member to App after m_instance, and create the surface:

void App::create_surface() { m_surface = glfw::create_surface(m_window.get(), *m_instance); }