PeriDyno 1.0.0
Loading...
Searching...
No Matches
VulkanSwapChain Class Reference

#include <VulkanSwapChain.h>

Public Member Functions

void connect (VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device)
 
void create (uint32_t *width, uint32_t *height, bool vsync=false)
 
VkResult acquireNextImage (VkSemaphore presentCompleteSemaphore, uint32_t *imageIndex)
 
VkResult queuePresent (VkQueue queue, uint32_t imageIndex, VkSemaphore waitSemaphore=VK_NULL_HANDLE)
 
void cleanup ()
 

Public Attributes

VkFormat colorFormat
 
VkColorSpaceKHR colorSpace
 
VkSwapchainKHR swapChain = VK_NULL_HANDLE
 
uint32_t imageCount
 
std::vector< VkImage > images
 
std::vector< SwapChainBufferbuffers
 
uint32_t queueNodeIndex = UINT32_MAX
 

Private Attributes

VkInstance instance
 
VkDevice device
 
VkPhysicalDevice physicalDevice
 
VkSurfaceKHR surface
 
PFN_vkGetPhysicalDeviceSurfaceSupportKHR fpGetPhysicalDeviceSurfaceSupportKHR
 
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR fpGetPhysicalDeviceSurfaceCapabilitiesKHR
 
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR fpGetPhysicalDeviceSurfaceFormatsKHR
 
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR fpGetPhysicalDeviceSurfacePresentModesKHR
 
PFN_vkCreateSwapchainKHR fpCreateSwapchainKHR
 
PFN_vkDestroySwapchainKHR fpDestroySwapchainKHR
 
PFN_vkGetSwapchainImagesKHR fpGetSwapchainImagesKHR
 
PFN_vkAcquireNextImageKHR fpAcquireNextImageKHR
 
PFN_vkQueuePresentKHR fpQueuePresentKHR
 

Detailed Description

Definition at line 31 of file VulkanSwapChain.h.

Member Function Documentation

◆ acquireNextImage()

VkResult VulkanSwapChain::acquireNextImage ( VkSemaphore presentCompleteSemaphore,
uint32_t * imageIndex )

Acquires the next image in the swap chain

Parameters
presentCompleteSemaphore(Optional) Semaphore that is signaled when the image is ready for use
imageIndexPointer to the image index that will be increased if the next image could be acquired
Note
The function will always wait until the next image has been acquired by setting timeout to UINT64_MAX
Returns
VkResult of the image acquisition

Definition at line 368 of file VulkanSwapChain.cpp.

◆ cleanup()

void VulkanSwapChain::cleanup ( )

Destroy and free Vulkan resources used for the swapchain

Definition at line 405 of file VulkanSwapChain.cpp.

◆ connect()

void VulkanSwapChain::connect ( VkInstance instance,
VkPhysicalDevice physicalDevice,
VkDevice device )

Set instance, physical and logical device to use for the swapchain and get all required function pointers

Parameters
instanceVulkan instance to use
physicalDevicePhysical device used to query properties and formats relevant to the swapchain
deviceLogical representation of the device to create the swapchain for

Definition at line 163 of file VulkanSwapChain.cpp.

◆ create()

void VulkanSwapChain::create ( uint32_t * width,
uint32_t * height,
bool vsync = false )

Create the swapchain and get its images with given width and height

Parameters
widthPointer to the width of the swapchain (may be adjusted to fit the requirements of the swapchain)
heightPointer to the height of the swapchain (may be adjusted to fit the requirements of the swapchain)
vsync(Optional) Can be used to force vsync-ed rendering (by using VK_PRESENT_MODE_FIFO_KHR as presentation mode)

Definition at line 187 of file VulkanSwapChain.cpp.

Here is the call graph for this function:

◆ queuePresent()

VkResult VulkanSwapChain::queuePresent ( VkQueue queue,
uint32_t imageIndex,
VkSemaphore waitSemaphore = VK_NULL_HANDLE )

Queue an image for presentation

Parameters
queuePresentation queue for presenting the image
imageIndexIndex of the swapchain image to queue for presentation
waitSemaphore(Optional) Semaphore that is waited on before the image is presented (only used if != VK_NULL_HANDLE)
Returns
VkResult of the queue presentation

Definition at line 384 of file VulkanSwapChain.cpp.

Member Data Documentation

◆ buffers

std::vector<SwapChainBuffer> VulkanSwapChain::buffers

Definition at line 54 of file VulkanSwapChain.h.

◆ colorFormat

VkFormat VulkanSwapChain::colorFormat

Definition at line 49 of file VulkanSwapChain.h.

◆ colorSpace

VkColorSpaceKHR VulkanSwapChain::colorSpace

Definition at line 50 of file VulkanSwapChain.h.

◆ device

VkDevice VulkanSwapChain::device
private

Definition at line 35 of file VulkanSwapChain.h.

◆ fpAcquireNextImageKHR

PFN_vkAcquireNextImageKHR VulkanSwapChain::fpAcquireNextImageKHR
private

Definition at line 46 of file VulkanSwapChain.h.

◆ fpCreateSwapchainKHR

PFN_vkCreateSwapchainKHR VulkanSwapChain::fpCreateSwapchainKHR
private

Definition at line 43 of file VulkanSwapChain.h.

◆ fpDestroySwapchainKHR

PFN_vkDestroySwapchainKHR VulkanSwapChain::fpDestroySwapchainKHR
private

Definition at line 44 of file VulkanSwapChain.h.

◆ fpGetPhysicalDeviceSurfaceCapabilitiesKHR

PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR VulkanSwapChain::fpGetPhysicalDeviceSurfaceCapabilitiesKHR
private

Definition at line 40 of file VulkanSwapChain.h.

◆ fpGetPhysicalDeviceSurfaceFormatsKHR

PFN_vkGetPhysicalDeviceSurfaceFormatsKHR VulkanSwapChain::fpGetPhysicalDeviceSurfaceFormatsKHR
private

Definition at line 41 of file VulkanSwapChain.h.

◆ fpGetPhysicalDeviceSurfacePresentModesKHR

PFN_vkGetPhysicalDeviceSurfacePresentModesKHR VulkanSwapChain::fpGetPhysicalDeviceSurfacePresentModesKHR
private

Definition at line 42 of file VulkanSwapChain.h.

◆ fpGetPhysicalDeviceSurfaceSupportKHR

PFN_vkGetPhysicalDeviceSurfaceSupportKHR VulkanSwapChain::fpGetPhysicalDeviceSurfaceSupportKHR
private

Definition at line 39 of file VulkanSwapChain.h.

◆ fpGetSwapchainImagesKHR

PFN_vkGetSwapchainImagesKHR VulkanSwapChain::fpGetSwapchainImagesKHR
private

Definition at line 45 of file VulkanSwapChain.h.

◆ fpQueuePresentKHR

PFN_vkQueuePresentKHR VulkanSwapChain::fpQueuePresentKHR
private

Definition at line 47 of file VulkanSwapChain.h.

◆ imageCount

uint32_t VulkanSwapChain::imageCount

Definition at line 52 of file VulkanSwapChain.h.

◆ images

std::vector<VkImage> VulkanSwapChain::images

Definition at line 53 of file VulkanSwapChain.h.

◆ instance

VkInstance VulkanSwapChain::instance
private

Definition at line 34 of file VulkanSwapChain.h.

◆ physicalDevice

VkPhysicalDevice VulkanSwapChain::physicalDevice
private

Definition at line 36 of file VulkanSwapChain.h.

◆ queueNodeIndex

uint32_t VulkanSwapChain::queueNodeIndex = UINT32_MAX

Definition at line 55 of file VulkanSwapChain.h.

◆ surface

VkSurfaceKHR VulkanSwapChain::surface
private

Definition at line 37 of file VulkanSwapChain.h.

◆ swapChain

VkSwapchainKHR VulkanSwapChain::swapChain = VK_NULL_HANDLE

Definition at line 51 of file VulkanSwapChain.h.


The documentation for this class was generated from the following files: