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 VkImageViewimg_views () const
 Views for the swap chain images.
 
std::span< const VkFramebufferframe_buffers () const
 Frame buffers for each swap chain image.
 
std::span< const VkFramebufferdepth_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.
 
 SwapChain (void)=default
 
 ~SwapChain (void)
 
VkSwapchainKHR id (void) const
 
VkSurfaceKHR surface (void) const
 
std::span< const VkImageViewimg_views () const
 Views for the swap chain images.
 
std::span< const VkFramebufferframe_buffers () const
 Frame buffers for each swap chain image.
 
std::span< const VkFramebufferdepth_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 ()
 
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< VkImageViewm_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< VkFramebufferm_frame_buffers = {}
 
std::vector< VkFramebufferm_depth_frame_buffers = {}
 
std::size_t i_frame = {}
 
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 = {}
 

Detailed Description

Presentation swap chain and associated objects.

Constructor & Destructor Documentation

◆ SwapChain() [1/2]

nngn::SwapChain::SwapChain ( void  )
default

◆ ~SwapChain() [1/2]

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

◆ SwapChain() [2/2]

nngn::SwapChain::SwapChain ( void  )
default

◆ ~SwapChain() [2/2]

nngn::SwapChain::~SwapChain ( void  )

Member Function Documentation

◆ acquire_img() [1/2]

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:

◆ acquire_img() [2/2]

std::pair< PresentContext, VkResult > nngn::SwapChain::acquire_img ( )

Acquires an image from the swap chain for rendering.

◆ create_depth_frame_buffers() [1/2]

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_frame_buffers() [2/2]

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

◆ create_depth_img() [1/2]

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_depth_img() [2/2]

bool nngn::SwapChain::create_depth_img ( const Instance inst,
VkExtent2D  extent 
)
private

◆ create_frame_buffers() [1/2]

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_frame_buffers() [2/2]

bool nngn::SwapChain::create_frame_buffers ( const Instance inst,
VkExtent2D  extent,
VkRenderPass  render_pass 
)
private

◆ create_img_views() [1/2]

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_img_views() [2/2]

bool nngn::SwapChain::create_img_views ( const Instance inst)
private

◆ create_sync_objects() [1/2]

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:

◆ create_sync_objects() [2/2]

bool nngn::SwapChain::create_sync_objects ( const Instance inst)
private

◆ cur_frame() [1/2]

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

◆ cur_frame() [2/2]

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

◆ depth_frame_buffers() [1/2]

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:

◆ depth_frame_buffers() [2/2]

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

Frame buffers for each depth pass image.

◆ destroy() [1/2]

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

◆ destroy() [2/2]

void nngn::SwapChain::destroy ( )
private

◆ frame_buffers() [1/2]

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:

◆ frame_buffers() [2/2]

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

Frame buffers for each swap chain image.

◆ id() [1/2]

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

◆ id() [2/2]

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

◆ img_views() [1/2]

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

Views for the swap chain images.

◆ img_views() [2/2]

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

Views for the swap chain images.

◆ init() [1/2]

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

◆ init() [2/2]

void nngn::SwapChain::init ( VkInstance  inst,
DeviceMemory dev_mem,
VkSurfaceFormatKHR  format,
VkFormat  depth_format,
VkPresentModeKHR  mode 
)

◆ recreate() [1/2]

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:

◆ recreate() [2/2]

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.

◆ set_present_mode() [1/2]

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_present_mode() [2/2]

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

Changes the presentation mode used on the next recreate.

◆ set_surface() [1/2]

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

◆ set_surface() [2/2]

void nngn::SwapChain::set_surface ( VkSurfaceKHR  s)
inline

◆ surface() [1/2]

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

◆ surface() [2/2]

VkSurfaceKHR nngn::SwapChain::surface ( void  ) const
inline

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

◆  [1/2]

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

◆  [2/2]

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.

◆  [1/2]

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

◆  [2/2]

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

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