Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Renderer::Backend::GL::CSwapChain Class Referencefinal

#include <SwapChain.h>

Inheritance diagram for Renderer::Backend::GL::CSwapChain:
Collaboration diagram for Renderer::Backend::GL::CSwapChain:

Classes

struct  BackbufferKeyHash
 

Public Member Functions

 ~CSwapChain () override
 
IDevice * GetDevice () override
 
bool IsValid () const override
 
bool AcquireNextBackbuffer () override
 Acquires a backbuffer for rendering a frame. More...
 
IFramebuffer * GetCurrentBackbuffer (const AttachmentLoadOp colorAttachmentLoadOp, const AttachmentStoreOp colorAttachmentStoreOp, const AttachmentLoadOp depthStencilAttachmentLoadOp, const AttachmentStoreOp depthStencilAttachmentStoreOp) override
 Returns a framebuffer for the current backbuffer with the required attachment operations. More...
 
void Present () override
 Presents the backbuffer to the swapchain queue to be flipped on a screen. More...
 
virtual bool IsValid () const =0
 
virtual bool AcquireNextBackbuffer ()=0
 Acquires a backbuffer for rendering a frame. More...
 
virtual IFramebuffer * GetCurrentBackbuffer (const AttachmentLoadOp colorAttachmentLoadOp, const AttachmentStoreOp colorAttachmentStoreOp, const AttachmentLoadOp depthStencilAttachmentLoadOp, const AttachmentStoreOp depthStencilAttachmentStoreOp)=0
 Returns a framebuffer for the current backbuffer with the required attachment operations. More...
 
virtual void Present ()=0
 Presents the backbuffer to the swapchain queue to be flipped on a screen. More...
 
- Public Member Functions inherited from Renderer::Backend::IDeviceObject< ISwapChain >
virtual ~IDeviceObject ()
 
virtual IDevice * GetDevice ()=0
 
T * As ()
 

Private Types

using BackbufferKey = std::tuple< AttachmentLoadOp, AttachmentStoreOp, AttachmentLoadOp, AttachmentStoreOp >
 

Private Member Functions

 CSwapChain ()
 

Static Private Member Functions

static std::unique_ptr< CSwapChain > Create (CDevice *device, SDL_Window *window, int surfaceDrawableWidth, int surfaceDrawableHeight, const bool vsync)
 

Private Attributes

CDevice * m_Device {nullptr}
 
SDL_Window * m_Window {nullptr}
 
int m_SurfaceDrawableWidth {0}
 
int m_SurfaceDrawableHeight {0}
 
std::unordered_map< BackbufferKey, std::unique_ptr< CFramebuffer >, BackbufferKeyHash > m_Backbuffers
 
bool m_BackbufferAcquired {false}
 

Friends

class CDevice
 

Member Typedef Documentation

◆ BackbufferKey

Constructor & Destructor Documentation

◆ ~CSwapChain()

Renderer::Backend::GL::CSwapChain::~CSwapChain ( )
override

◆ CSwapChain()

Renderer::Backend::GL::CSwapChain::CSwapChain ( )
privatedefault

Member Function Documentation

◆ AcquireNextBackbuffer()

bool Renderer::Backend::GL::CSwapChain::AcquireNextBackbuffer ( )
overridevirtual

Acquires a backbuffer for rendering a frame.

Returns
True if it was successfully acquired and we can render to it.

Implements Renderer::Backend::ISwapChain.

◆ Create()

std::unique_ptr< CSwapChain > Renderer::Backend::GL::CSwapChain::Create ( CDevice *  device,
SDL_Window *  window,
int  surfaceDrawableWidth,
int  surfaceDrawableHeight,
const bool  vsync 
)
staticprivate

◆ GetCurrentBackbuffer()

IFramebuffer * Renderer::Backend::GL::CSwapChain::GetCurrentBackbuffer ( const AttachmentLoadOp  colorAttachmentLoadOp,
const AttachmentStoreOp  colorAttachmentStoreOp,
const AttachmentLoadOp  depthStencilAttachmentLoadOp,
const AttachmentStoreOp  depthStencilAttachmentStoreOp 
)
overridevirtual

Returns a framebuffer for the current backbuffer with the required attachment operations.

It should not be called if the last AcquireNextBackbuffer call returned false.

It's guaranteed that for the same acquired backbuffer this function returns a framebuffer with the same attachments and properties except load and store operations.

Returns
The last successfully acquired framebuffer that wasn't presented.

Implements Renderer::Backend::ISwapChain.

◆ GetDevice()

IDevice * Renderer::Backend::GL::CSwapChain::GetDevice ( )
overridevirtual

◆ IsValid()

bool Renderer::Backend::GL::CSwapChain::IsValid ( ) const
inlineoverridevirtual
Returns
True if we still can use the swapchain to present. A swapchain can become invalid on window resize or some other system event.

Implements Renderer::Backend::ISwapChain.

◆ Present()

void Renderer::Backend::GL::CSwapChain::Present ( )
overridevirtual

Presents the backbuffer to the swapchain queue to be flipped on a screen.

Should be called only if the last AcquireNextBackbuffer call returned true.

Implements Renderer::Backend::ISwapChain.

Friends And Related Function Documentation

◆ CDevice

friend class CDevice
friend

Member Data Documentation

◆ m_BackbufferAcquired

bool Renderer::Backend::GL::CSwapChain::m_BackbufferAcquired {false}
private

◆ m_Backbuffers

std::unordered_map< BackbufferKey, std::unique_ptr<CFramebuffer>, BackbufferKeyHash> Renderer::Backend::GL::CSwapChain::m_Backbuffers
private

◆ m_Device

CDevice* Renderer::Backend::GL::CSwapChain::m_Device {nullptr}
private

◆ m_SurfaceDrawableHeight

int Renderer::Backend::GL::CSwapChain::m_SurfaceDrawableHeight {0}
private

◆ m_SurfaceDrawableWidth

int Renderer::Backend::GL::CSwapChain::m_SurfaceDrawableWidth {0}
private

◆ m_Window

SDL_Window* Renderer::Backend::GL::CSwapChain::m_Window {nullptr}
private

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