Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Swapchain Class Reference

A swapchain handles the creation and presentation of the backbuffer, along with GPU work submission and synchronization. More...

#include <Swapchain.hpp>

Public Member Functions

 Swapchain (GPUContext &context, const RenderingConfig &config)
 
void resize (uint w, uint h)
 
bool nextFrame ()
 
uint count ()
 
uint minCount ()
 
 ~Swapchain ()
 
Texturecolor ()
 
Texturedepth ()
 
void getFormats (VkFormat &color, VkFormat &depth, VkFormat &stencil)
 

Private Member Functions

void setup (uint32_t width, uint32_t height)
 
bool finishFrame ()
 
void clean ()
 

Private Attributes

GPUContext_context = nullptr
 The GPU internal context.
 
VkSwapchainKHR _swapchain = VK_NULL_HANDLE
 Native handle.
 
std::vector< Texture_colors
 Backbuffers.
 
Texture _depth
 The shared depth texture.
 
Texture_backbuffer = nullptr
 The current backbuffer.
 
std::vector< VkSemaphore > _imagesAvailable
 Semaphores signaling when swapchain images are available for a new frame.
 
std::vector< VkSemaphore > _framesFinished
 Semaphores signaling when a frame has been completed.
 
std::vector< VkFence > _framesInFlight
 Fences ensuring that frames are properly ordered.
 
uint _imageCount = 0
 Number of images in the swapchain.
 
uint _minImageCount = 0
 Minimum number of images required by the swapchain.
 
bool _vsync = false
 Is V-sync enabled.
 
uint32_t _imageIndex = 0
 Current image index.
 
bool _frameStarted = false
 Has a frame been previously submitted.
 

Detailed Description

A swapchain handles the creation and presentation of the backbuffer, along with GPU work submission and synchronization.

Constructor & Destructor Documentation

◆ Swapchain()

Swapchain::Swapchain ( GPUContext context,
const RenderingConfig config 
)

Create a swapchain.

Parameters
contextthe GPU internal context
configthe renderer configuration

◆ ~Swapchain()

Swapchain::~Swapchain ( )

Destructor.

Member Function Documentation

◆ clean()

void Swapchain::clean ( )
private

Destroy internal structures.

◆ color()

Texture & Swapchain::color ( )
inline
Returns
the swapchain color texture

◆ count()

uint Swapchain::count ( )
inline
Returns
the number of backbuffers handled by the swapchain.

◆ depth()

Texture & Swapchain::depth ( )
inline
Returns
the swapchain depth texture

◆ finishFrame()

bool Swapchain::finishFrame ( )
private

Submit the current frame's work.

Returns
true if the submission was successful

◆ getFormats()

void Swapchain::getFormats ( VkFormat &  color,
VkFormat &  depth,
VkFormat &  stencil 
)

Query the formats used by the swapchain backbuffer

Parameters
colorwill contain the color format
depthwill contain the depth format
stencilwill contain the stencil format

◆ minCount()

uint Swapchain::minCount ( )
inline
Returns
the minimum number of backbuffers required by the swapchain.

◆ nextFrame()

bool Swapchain::nextFrame ( )

Submit the current frame's work and start the next one.

Returns
true if a new frame has been successfully started

◆ resize()

void Swapchain::resize ( uint  w,
uint  h 
)

Resize an existing swapchain, recreating backbuffers.

Parameters
wthe new width
hthe new height

◆ setup()

void Swapchain::setup ( uint32_t  width,
uint32_t  height 
)
private

Setup the swapchain for a given size

Parameters
widththe new width
heightthe new height

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