diff --git a/include/vkcv/Swapchain.hpp b/include/vkcv/Swapchain.hpp index c7741c652926fad5d581ecf7465ed74af9e2db37..f1a29faa7534b89a17d7b1a0dcc4d58a05967bbf 100644 --- a/include/vkcv/Swapchain.hpp +++ b/include/vkcv/Swapchain.hpp @@ -65,8 +65,8 @@ namespace vkcv /** * recreates the swapchain - * context - * window + * @param context that holds the device to recreate the swapchain + * @param window that the new swapchain gets bound to */ void updateSwapchain(const Context &context, const Window &window); diff --git a/src/vkcv/Swapchain.cpp b/src/vkcv/Swapchain.cpp index 483732927bc2cc507f0868226b65bf4d49e27048..79289110307712a1d6a27ecd1b1eb7df71492522 100644 --- a/src/vkcv/Swapchain.cpp +++ b/src/vkcv/Swapchain.cpp @@ -133,7 +133,7 @@ namespace vkcv } /** - * returns the minImageCount +1 for at least doublebuffering, if it's greater than maxImageCount return maxImageCount + * returns the minImageCount +1 for at least double buffering, if it's greater than maxImageCount return maxImageCount * @param physicalDevice Vulkan-PhysicalDevice * @param surface of the swapchain * @return available ImageCount @@ -151,12 +151,7 @@ namespace vkcv return imageCount; } - /** - * creates and returns a swapchain with default specs - * @param window of the current application - * @param context that keeps instance, physicalDevice and a device. - * @return swapchain - */ + Swapchain Swapchain::create(const Window &window, const Context &context) { const vk::Instance& instance = context.getInstance(); const vk::PhysicalDevice& physicalDevice = context.getPhysicalDevice(); @@ -175,22 +170,22 @@ namespace vkcv uint32_t chosenImageCount = chooseImageCount(physicalDevice, surface.handle); vk::SwapchainCreateInfoKHR swapchainCreateInfo( - vk::SwapchainCreateFlagsKHR(), //flags - surface.handle, // surface - chosenImageCount, // minImageCount TODO: how many do we need for our application?? "must be less than or equal to the value returned in maxImageCount" -> 3 for Triple Buffering, else 2 for Double Buffering (should be the standard) - chosenSurfaceFormat.format, // imageFormat - chosenSurfaceFormat.colorSpace, // imageColorSpace - chosenExtent, // imageExtent - 1, // imageArrayLayers TODO: should we only allow non-stereoscopic applications? yes -> 1, no -> ? "must be greater than 0, less or equal to maxImageArrayLayers" - vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eStorage, // imageUsage TODO: what attachments? only color? depth? - vk::SharingMode::eExclusive, // imageSharingMode TODO: which sharing mode? "VK_SHARING_MODE_EXCLUSIV access exclusive to a single queue family, better performance", "VK_SHARING_MODE_CONCURRENT access from multiple queues" - 0, // queueFamilyIndexCount, the number of queue families having access to the image(s) of the swapchain when imageSharingMode is VK_SHARING_MODE_CONCURRENT - nullptr, // pQueueFamilyIndices, the pointer to an array of queue family indices having access to the images(s) of the swapchain when imageSharingMode is VK_SHARING_MODE_CONCURRENT - vk::SurfaceTransformFlagBitsKHR::eIdentity, // preTransform, transformations applied onto the image before display - vk::CompositeAlphaFlagBitsKHR::eOpaque, // compositeAlpha, TODO: how to handle transparent pixels? do we need transparency? If no -> opaque - chosenPresentMode, // presentMode - true, // clipped - nullptr // oldSwapchain + vk::SwapchainCreateFlagsKHR(), + surface.handle, + chosenImageCount, + chosenSurfaceFormat.format, + chosenSurfaceFormat.colorSpace, + chosenExtent, + 1, + vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eStorage, + vk::SharingMode::eExclusive, + 0, + nullptr, + vk::SurfaceTransformFlagBitsKHR::eIdentity, + vk::CompositeAlphaFlagBitsKHR::eOpaque, + chosenPresentMode, + true, + nullptr ); vk::SwapchainKHR swapchain = device.createSwapchainKHR(swapchainCreateInfo); diff --git a/src/vkcv/SwapchainManager.hpp b/src/vkcv/SwapchainManager.hpp index 58478ef09af1734bef7df217550d43af74fd8424..39fe8cf68254683fc6fdf53cf4cb181839538d7b 100644 --- a/src/vkcv/SwapchainManager.hpp +++ b/src/vkcv/SwapchainManager.hpp @@ -20,11 +20,18 @@ namespace vkcv { Context *m_context; + /** + * destroys a specific swapchain by a given id + * @param id of the swapchain to be destroyed + */ void destroySwapchainById(uint64_t id); public: SwapchainManager() noexcept; + /** + * destroys every swapchain + */ ~SwapchainManager() noexcept; SwapchainManager(SwapchainManager &&other) = delete; diff --git a/src/vkcv/WindowManager.hpp b/src/vkcv/WindowManager.hpp index 66186c494c38a5af46ffe34cc31b2e86bbbc95db..184622001fe01e499a001e7ffeb0ced8731e209a 100644 --- a/src/vkcv/WindowManager.hpp +++ b/src/vkcv/WindowManager.hpp @@ -19,11 +19,18 @@ namespace vkcv { private: std::vector<Window*> m_windows; + /** + * destroys a specific window by a given id + * @param id of the window to be destroyed + */ void destroyWindowById(uint64_t id); public: WindowManager() noexcept; + /** + * destroys every window + */ ~WindowManager() noexcept; WindowManager(WindowManager &&other) = delete;