diff --git a/src/vkcv/SwapChain.cpp b/src/vkcv/SwapChain.cpp index e9c29482fcce2f94817b29b47b8846633656ebdd..85f67b8d0fe252a2ab65d4e0d5baf388a7cfa862 100644 --- a/src/vkcv/SwapChain.cpp +++ b/src/vkcv/SwapChain.cpp @@ -11,14 +11,29 @@ namespace vkcv { return m_swapchain; } + /** + * gets surface of the swapchain + * @return current surface + */ vk::SurfaceKHR SwapChain::getSurface() { return m_surface; } + /** + * gets the surface of the swapchain + * @return chosen format + */ vk::SurfaceFormatKHR SwapChain::getSurfaceFormat(){ return m_format; } + /** + * creates surface and checks availability + * @param window current window for the surface + * @param instance Vulkan-Instance + * @param physicalDevice Vulkan-PhysicalDevice + * @return created surface + */ vk::SurfaceKHR createSurface(GLFWwindow *window, const vk::Instance &instance, const vk::PhysicalDevice& physicalDevice) { //create surface VkSurfaceKHR surface; @@ -33,6 +48,13 @@ namespace vkcv { return vk::SurfaceKHR(surface); } + /** + * chooses Extent and clapms values to the available + * @param physicalDevice Vulkan-PhysicalDevice + * @param surface of the swapchain + * @param window of the current application + * @return chosen Extent for the surface + */ vk::Extent2D chooseSwapExtent(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface, const Window &window){ vk::SurfaceCapabilitiesKHR surfaceCapabilities; if(physicalDevice.getSurfaceCapabilitiesKHR(surface,&surfaceCapabilities) != vk::Result::eSuccess){ @@ -55,6 +77,12 @@ namespace vkcv { return extent2D; } + /** + * chooses Surface Format for the current surface + * @param physicalDevice Vulkan-PhysicalDevice + * @param surface of the swapchain + * @return available Format + */ vk::SurfaceFormatKHR chooseSwapSurfaceFormat(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface) { uint32_t formatCount; physicalDevice.getSurfaceFormatsKHR(surface, &formatCount, nullptr); @@ -71,6 +99,12 @@ namespace vkcv { return availableFormats[0]; } + /** + * returns vk::PresentModeKHR::eMailbox if available or vk::PresentModeKHR::eFifo otherwise + * @param physicalDevice Vulkan-PhysicalDevice + * @param surface of the swapchain + * @return available PresentationMode + */ vk::PresentModeKHR choosePresentMode(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface) { uint32_t modeCount; physicalDevice.getSurfacePresentModesKHR( surface, &modeCount, nullptr ); @@ -88,6 +122,12 @@ namespace vkcv { return vk::PresentModeKHR::eFifo; } + /** + * returns the minImageCount +1 for at least doublebuffering, if it's greater than maxImageCount return maxImageCount + * @param physicalDevice Vulkan-PhysicalDevice + * @param surface of the swapchain + * @return available ImageCount + */ uint32_t chooseImageCount(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface) { vk::SurfaceCapabilitiesKHR surfaceCapabilities; if(physicalDevice.getSurfaceCapabilitiesKHR(surface, &surfaceCapabilities) != vk::Result::eSuccess){ @@ -102,7 +142,12 @@ 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();