Skip to content
Snippets Groups Projects
Commit dc50aab2 authored by Sebastian Gaida's avatar Sebastian Gaida
Browse files

[#16] [Docu] add comments for functions

parent 5d385670
No related branches found
No related tags found
4 merge requests!12Resolve "Swapchain Class",!7Resolve "Shader Program Class",!5Resolve "Pipeline State Object",!4Resolve "Renderpass Class"
Pipeline #24731 passed
...@@ -11,14 +11,29 @@ namespace vkcv { ...@@ -11,14 +11,29 @@ namespace vkcv {
return m_swapchain; return m_swapchain;
} }
/**
* gets surface of the swapchain
* @return current surface
*/
vk::SurfaceKHR SwapChain::getSurface() { vk::SurfaceKHR SwapChain::getSurface() {
return m_surface; return m_surface;
} }
/**
* gets the surface of the swapchain
* @return chosen format
*/
vk::SurfaceFormatKHR SwapChain::getSurfaceFormat(){ vk::SurfaceFormatKHR SwapChain::getSurfaceFormat(){
return m_format; 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) { vk::SurfaceKHR createSurface(GLFWwindow *window, const vk::Instance &instance, const vk::PhysicalDevice& physicalDevice) {
//create surface //create surface
VkSurfaceKHR surface; VkSurfaceKHR surface;
...@@ -33,6 +48,13 @@ namespace vkcv { ...@@ -33,6 +48,13 @@ namespace vkcv {
return vk::SurfaceKHR(surface); 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::Extent2D chooseSwapExtent(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface, const Window &window){
vk::SurfaceCapabilitiesKHR surfaceCapabilities; vk::SurfaceCapabilitiesKHR surfaceCapabilities;
if(physicalDevice.getSurfaceCapabilitiesKHR(surface,&surfaceCapabilities) != vk::Result::eSuccess){ if(physicalDevice.getSurfaceCapabilitiesKHR(surface,&surfaceCapabilities) != vk::Result::eSuccess){
...@@ -55,6 +77,12 @@ namespace vkcv { ...@@ -55,6 +77,12 @@ namespace vkcv {
return extent2D; 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) { vk::SurfaceFormatKHR chooseSwapSurfaceFormat(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface) {
uint32_t formatCount; uint32_t formatCount;
physicalDevice.getSurfaceFormatsKHR(surface, &formatCount, nullptr); physicalDevice.getSurfaceFormatsKHR(surface, &formatCount, nullptr);
...@@ -71,6 +99,12 @@ namespace vkcv { ...@@ -71,6 +99,12 @@ namespace vkcv {
return availableFormats[0]; 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) { vk::PresentModeKHR choosePresentMode(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface) {
uint32_t modeCount; uint32_t modeCount;
physicalDevice.getSurfacePresentModesKHR( surface, &modeCount, nullptr ); physicalDevice.getSurfacePresentModesKHR( surface, &modeCount, nullptr );
...@@ -88,6 +122,12 @@ namespace vkcv { ...@@ -88,6 +122,12 @@ namespace vkcv {
return vk::PresentModeKHR::eFifo; 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) { uint32_t chooseImageCount(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface) {
vk::SurfaceCapabilitiesKHR surfaceCapabilities; vk::SurfaceCapabilitiesKHR surfaceCapabilities;
if(physicalDevice.getSurfaceCapabilitiesKHR(surface, &surfaceCapabilities) != vk::Result::eSuccess){ if(physicalDevice.getSurfaceCapabilitiesKHR(surface, &surfaceCapabilities) != vk::Result::eSuccess){
...@@ -102,7 +142,12 @@ namespace vkcv { ...@@ -102,7 +142,12 @@ namespace vkcv {
return imageCount; 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) { SwapChain SwapChain::create(const Window &window, const Context &context) {
const vk::Instance& instance = context.getInstance(); const vk::Instance& instance = context.getInstance();
const vk::PhysicalDevice& physicalDevice = context.getPhysicalDevice(); const vk::PhysicalDevice& physicalDevice = context.getPhysicalDevice();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment