nngn
Loading...
Searching...
No Matches
nngn::SwapChain Class Reference

Presentation swap chain and associated objects. More...

#include <swapchain.h>

Collaboration diagram for nngn::SwapChain:

Classes

struct  PresentContext
 Information used to present an image. More...
 

Public Member Functions

 SwapChain (void)=default
 
 ~SwapChain (void)
 
VkSwapchainKHR id (void) const
 
VkSurfaceKHR surface (void) const
 
std::span< const VkImageView > img_views () const
 Views for the swap chain images.
 
std::span< const VkFramebuffer > frame_buffers () const
 Frame buffers for each swap chain image.
 
std::span< const VkFramebuffer > depth_frame_buffers () const
 Frame buffers for each depth pass image.
 
std::size_t cur_frame () const
 
void set_present_mode (VkPresentModeKHR m)
 Changes the presentation mode used on the next recreate.
 
void set_surface (VkSurfaceKHR s)
 
void init (VkInstance inst, DeviceMemory *dev_mem, VkSurfaceFormatKHR format, VkFormat depth_format, VkPresentModeKHR mode)
 
bool recreate (const Instance &inst, const Device &dev, std::uint32_t n_images, VkRenderPass depth_pass, VkRenderPass render_pass, VkExtent2D extent, VkSurfaceTransformFlagBitsKHR transform, VkExtent2D shadow_map_size, VkExtent2D shadow_cube_size, std::span< const VkImageView > shadow_map, std::span< const VkImageView > shadow_cube)
 Destroys resources and recreate them.
 
std::pair< PresentContext, VkResult > acquire_img ()
 Acquires an image from the swap chain for rendering.
 

Private Member Functions

bool create_img_views (const Instance &inst)
 
bool create_depth_img (const Instance &inst, VkExtent2D extent)
 
bool create_sync_objects (const Instance &inst)
 
bool create_frame_buffers (const Instance &inst, VkExtent2D extent, VkRenderPass render_pass)
 
bool create_depth_frame_buffers (const Instance &inst, VkRenderPass render_pass, VkExtent2D shadow_map_size, VkExtent2D shadow_cube_size, std::span< const VkImageView > shadow_map, std::span< const VkImageView > shadow_cube)
 
void destroy ()
 

Private Attributes

VkSwapchainKHR h = {}
 
VkInstance instance = {}
 
VkSurfaceKHR m_surface = {}
 
VkDevice dev = {}
 
DeviceMemorydev_mem = {}
 
VkSurfaceFormatKHR format = {}
 
VkPresentModeKHR present_mode = {}
 
std::vector< VkImageView > m_img_views = {}
 
VkFormat depth_format = {}
 
Image depth_img = {}
 
VkImageView depth_img_view = {}
 
struct { 
 
   std::vector< VkSemaphore >   render 
 Signaled when an image has been acquired and rendering can begin. More...
 
   std::vector< VkSemaphore >   present 
 Signaled when an image has been presented. More...
 
semaphores = {} 
 
struct { 
 
   std::vector< VkFence >   render 
 Signaled when an image has been acquired and rendering can begin. More...
 
   std::vector< VkFence >   present 
 Signaled when all rendering commands targeting an image finished. More...
 
fences = {} 
 
std::vector< VkFramebuffer > m_frame_buffers = {}
 
std::vector< VkFramebuffer > m_depth_frame_buffers = {}
 
std::size_t i_frame = {}
 

Detailed Description

Presentation swap chain and associated objects.

Constructor & Destructor Documentation

◆ SwapChain()

nngn::SwapChain::SwapChain ( void )
default

◆ ~SwapChain()

nngn::SwapChain::~SwapChain ( void )
Here is the call graph for this function:

Member Function Documentation

◆ acquire_img()

auto nngn::SwapChain::acquire_img ( )

Acquires an image from the swap chain for rendering.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_depth_frame_buffers()

bool nngn::SwapChain::create_depth_frame_buffers ( const Instance & inst,
VkRenderPass render_pass,
VkExtent2D shadow_map_size,
VkExtent2D shadow_cube_size,
std::span< const VkImageView > shadow_map,
std::span< const VkImageView > shadow_cube )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_depth_img()

bool nngn::SwapChain::create_depth_img ( const Instance & inst,
VkExtent2D extent )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_frame_buffers()

bool nngn::SwapChain::create_frame_buffers ( const Instance & inst,
VkExtent2D extent,
VkRenderPass render_pass )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_img_views()

bool nngn::SwapChain::create_img_views ( const Instance & inst)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_sync_objects()

bool nngn::SwapChain::create_sync_objects ( const Instance & inst)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cur_frame()

std::size_t nngn::SwapChain::cur_frame ( ) const
inline

◆ depth_frame_buffers()

std::span< const VkFramebuffer > nngn::SwapChain::depth_frame_buffers ( ) const
inline

Frame buffers for each depth pass image.

Here is the caller graph for this function:

◆ destroy()

void nngn::SwapChain::destroy ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ frame_buffers()

std::span< const VkFramebuffer > nngn::SwapChain::frame_buffers ( ) const
inline

Frame buffers for each swap chain image.

Here is the caller graph for this function:

◆ id()

VkSwapchainKHR nngn::SwapChain::id ( void ) const
inline

◆ img_views()

std::span< const VkImageView > nngn::SwapChain::img_views ( ) const
inline

Views for the swap chain images.

◆ init()

void nngn::SwapChain::init ( VkInstance inst,
DeviceMemory * dev_mem,
VkSurfaceFormatKHR format,
VkFormat depth_format,
VkPresentModeKHR mode )
Here is the caller graph for this function:

◆ recreate()

bool nngn::SwapChain::recreate ( const Instance & inst,
const Device & dev,
std::uint32_t n_images,
VkRenderPass depth_pass,
VkRenderPass render_pass,
VkExtent2D extent,
VkSurfaceTransformFlagBitsKHR transform,
VkExtent2D shadow_map_size,
VkExtent2D shadow_cube_size,
std::span< const VkImageView > shadow_map,
std::span< const VkImageView > shadow_cube )

Destroys resources and recreate them.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_present_mode()

void nngn::SwapChain::set_present_mode ( VkPresentModeKHR m)
inline

Changes the presentation mode used on the next recreate.

Here is the caller graph for this function:

◆ set_surface()

void nngn::SwapChain::set_surface ( VkSurfaceKHR s)
inline
Here is the caller graph for this function:

◆ surface()

VkSurfaceKHR nngn::SwapChain::surface ( void ) const
inline
Here is the caller graph for this function:

Member Data Documentation

◆ depth_format

VkFormat nngn::SwapChain::depth_format = {}
private

◆ depth_img

Image nngn::SwapChain::depth_img = {}
private

◆ depth_img_view

VkImageView nngn::SwapChain::depth_img_view = {}
private

◆ dev

VkDevice nngn::SwapChain::dev = {}
private

◆ dev_mem

DeviceMemory* nngn::SwapChain::dev_mem = {}
private

◆ [struct]

struct { ... } nngn::SwapChain::fences

◆ format

VkSurfaceFormatKHR nngn::SwapChain::format = {}
private

◆ h

VkSwapchainKHR nngn::SwapChain::h = {}
private

◆ i_frame

std::size_t nngn::SwapChain::i_frame = {}
private

◆ instance

VkInstance nngn::SwapChain::instance = {}
private

◆ m_depth_frame_buffers

std::vector<VkFramebuffer> nngn::SwapChain::m_depth_frame_buffers = {}
private

◆ m_frame_buffers

std::vector<VkFramebuffer> nngn::SwapChain::m_frame_buffers = {}
private

◆ m_img_views

std::vector<VkImageView> nngn::SwapChain::m_img_views = {}
private

◆ m_surface

VkSurfaceKHR nngn::SwapChain::m_surface = {}
private

◆ present [1/2]

std::vector<VkSemaphore> nngn::SwapChain::present

Signaled when an image has been presented.

◆ present [2/2]

std::vector<VkFence> nngn::SwapChain::present

Signaled when all rendering commands targeting an image finished.

Elements are a permutation of render depending on the order images are made available in the swap chain.

◆ present_mode

VkPresentModeKHR nngn::SwapChain::present_mode = {}
private

◆ render [1/2]

std::vector<VkSemaphore> nngn::SwapChain::render

Signaled when an image has been acquired and rendering can begin.

◆ render [2/2]

std::vector<VkFence> nngn::SwapChain::render

Signaled when an image has been acquired and rendering can begin.

◆ [struct]

struct { ... } nngn::SwapChain::semaphores

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