Pyrogenesis  trunk
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Renderer::Backend::GL::CDevice Class Referencefinal

#include <Device.h>

Inheritance diagram for Renderer::Backend::GL::CDevice:
Inheritance graph
[legend]
Collaboration diagram for Renderer::Backend::GL::CDevice:
Collaboration graph
[legend]

Classes

struct  BackbufferKeyHash
 

Public Member Functions

 ~CDevice () override
 
Backend GetBackend () const override
 
const std::string & GetName () const override
 
const std::string & GetVersion () const override
 
const std::string & GetDriverInformation () const override
 
const std::vector< std::string > & GetExtensions () const override
 
void Report (const ScriptRequest &rq, JS::HandleValue settings) override
 
std::unique_ptr< IDeviceCommandContextCreateCommandContext () override
 
std::unique_ptr< IGraphicsPipelineStateCreateGraphicsPipelineState (const SGraphicsPipelineStateDesc &pipelineStateDesc) override
 Creates a graphics pipeline state. More...
 
std::unique_ptr< IVertexInputLayoutCreateVertexInputLayout (const PS::span< const SVertexAttributeFormat > attributes) override
 Creates a vertex input layout. More...
 
CDeviceCommandContextGetActiveCommandContext ()
 
std::unique_ptr< ITextureCreateTexture (const char *name, const ITexture::Type type, const uint32_t usage, const Format format, const uint32_t width, const uint32_t height, const Sampler::Desc &defaultSamplerDesc, const uint32_t MIPLevelCount, const uint32_t sampleCount) override
 
std::unique_ptr< ITextureCreateTexture2D (const char *name, const uint32_t usage, const Format format, const uint32_t width, const uint32_t height, const Sampler::Desc &defaultSamplerDesc, const uint32_t MIPLevelCount=1, const uint32_t sampleCount=1) override
 
std::unique_ptr< IFramebufferCreateFramebuffer (const char *name, SColorAttachment *colorAttachment, SDepthStencilAttachment *depthStencilAttachment) override
 
std::unique_ptr< IBufferCreateBuffer (const char *name, const IBuffer::Type type, const uint32_t size, const bool dynamic) override
 
std::unique_ptr< IShaderProgramCreateShaderProgram (const CStr &name, const CShaderDefines &defines) override
 
bool AcquireNextBackbuffer () override
 Acquires a backbuffer for rendering a frame. More...
 
IFramebufferGetCurrentBackbuffer (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...
 
void OnWindowResize (const uint32_t width, const uint32_t height) override
 Should be called on window surface resize. More...
 
bool UseFramebufferInvalidating () const
 
bool IsTextureFormatSupported (const Format format) const override
 
bool IsFramebufferFormatSupported (const Format format) const override
 
Format GetPreferredDepthStencilFormat (const uint32_t usage, const bool depth, const bool stencil) const override
 Returns the most suitable format for the usage. More...
 
const CapabilitiesGetCapabilities () const override
 
- Public Member Functions inherited from Renderer::Backend::IDevice
virtual ~IDevice ()
 

Static Public Member Functions

static std::unique_ptr< IDeviceCreate (SDL_Window *window, const bool arb)
 Creates the GL device and the GL context for the window if it presents. More...
 

Private Types

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

Private Member Functions

 CDevice ()
 

Private Attributes

SDL_Windowm_Window = nullptr
 
SDL_GLContext m_Context = nullptr
 
int m_SurfaceDrawableWidth = 0
 
int m_SurfaceDrawableHeight = 0
 
bool m_ARB = false
 
std::string m_Name
 
std::string m_Version
 
std::string m_DriverInformation
 
std::vector< std::string > m_Extensions
 
CDeviceCommandContextm_ActiveCommandContext = nullptr
 
std::unordered_map< BackbufferKey, std::unique_ptr< CFramebuffer >, BackbufferKeyHashm_Backbuffers
 
bool m_BackbufferAcquired = false
 
bool m_UseFramebufferInvalidating = false
 
Capabilities m_Capabilities {}
 

Member Typedef Documentation

◆ BackbufferKey

Constructor & Destructor Documentation

◆ ~CDevice()

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

◆ CDevice()

Renderer::Backend::GL::CDevice::CDevice ( )
privatedefault

Member Function Documentation

◆ AcquireNextBackbuffer()

bool Renderer::Backend::GL::CDevice::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::IDevice.

◆ Create()

std::unique_ptr< IDevice > Renderer::Backend::GL::CDevice::Create ( SDL_Window window,
const bool  arb 
)
static

Creates the GL device and the GL context for the window if it presents.

◆ CreateBuffer()

std::unique_ptr< IBuffer > Renderer::Backend::GL::CDevice::CreateBuffer ( const char *  name,
const IBuffer::Type  type,
const uint32_t  size,
const bool  dynamic 
)
overridevirtual

◆ CreateCommandContext()

std::unique_ptr< IDeviceCommandContext > Renderer::Backend::GL::CDevice::CreateCommandContext ( )
overridevirtual

◆ CreateFramebuffer()

std::unique_ptr< IFramebuffer > Renderer::Backend::GL::CDevice::CreateFramebuffer ( const char *  name,
SColorAttachment colorAttachment,
SDepthStencilAttachment depthStencilAttachment 
)
overridevirtual
See also
IFramebuffer

The color attachment and the depth-stencil attachment should not be nullptr at the same time. There should not be many different clear colors along all color attachments for all framebuffers created for the device.

Returns
A valid framebuffer if it was created successfully else nullptr.

Implements Renderer::Backend::IDevice.

◆ CreateGraphicsPipelineState()

std::unique_ptr< IGraphicsPipelineState > Renderer::Backend::GL::CDevice::CreateGraphicsPipelineState ( const SGraphicsPipelineStateDesc pipelineStateDesc)
overridevirtual

Creates a graphics pipeline state.

It's a caller responsibility to guarantee a lifespan of IShaderProgram stored in the description.

Implements Renderer::Backend::IDevice.

◆ CreateShaderProgram()

std::unique_ptr< IShaderProgram > Renderer::Backend::GL::CDevice::CreateShaderProgram ( const CStr &  name,
const CShaderDefines defines 
)
overridevirtual

◆ CreateTexture()

std::unique_ptr< ITexture > Renderer::Backend::GL::CDevice::CreateTexture ( const char *  name,
const ITexture::Type  type,
const uint32_t  usage,
const Format  format,
const uint32_t  width,
const uint32_t  height,
const Sampler::Desc defaultSamplerDesc,
const uint32_t  MIPLevelCount,
const uint32_t  sampleCount 
)
overridevirtual

◆ CreateTexture2D()

std::unique_ptr< ITexture > Renderer::Backend::GL::CDevice::CreateTexture2D ( const char *  name,
const uint32_t  usage,
const Format  format,
const uint32_t  width,
const uint32_t  height,
const Sampler::Desc defaultSamplerDesc,
const uint32_t  MIPLevelCount = 1,
const uint32_t  sampleCount = 1 
)
overridevirtual

◆ CreateVertexInputLayout()

std::unique_ptr< IVertexInputLayout > Renderer::Backend::GL::CDevice::CreateVertexInputLayout ( const PS::span< const SVertexAttributeFormat attributes)
overridevirtual

Creates a vertex input layout.

It's recommended to use as few different layouts as posible.

Implements Renderer::Backend::IDevice.

◆ GetActiveCommandContext()

CDeviceCommandContext* Renderer::Backend::GL::CDevice::GetActiveCommandContext ( )
inline

◆ GetBackend()

Backend Renderer::Backend::GL::CDevice::GetBackend ( ) const
inlineoverridevirtual

◆ GetCapabilities()

const Capabilities& Renderer::Backend::GL::CDevice::GetCapabilities ( ) const
inlineoverridevirtual

◆ GetCurrentBackbuffer()

IFramebuffer * Renderer::Backend::GL::CDevice::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::IDevice.

◆ GetDriverInformation()

const std::string& Renderer::Backend::GL::CDevice::GetDriverInformation ( ) const
inlineoverridevirtual

◆ GetExtensions()

const std::vector<std::string>& Renderer::Backend::GL::CDevice::GetExtensions ( ) const
inlineoverridevirtual

◆ GetName()

const std::string& Renderer::Backend::GL::CDevice::GetName ( ) const
inlineoverridevirtual

◆ GetPreferredDepthStencilFormat()

Format Renderer::Backend::GL::CDevice::GetPreferredDepthStencilFormat ( const uint32_t  usage,
const bool  depth,
const bool  stencil 
) const
overridevirtual

Returns the most suitable format for the usage.

Returns Format::UNDEFINED if there is no such format.

Implements Renderer::Backend::IDevice.

◆ GetVersion()

const std::string& Renderer::Backend::GL::CDevice::GetVersion ( ) const
inlineoverridevirtual

◆ IsFramebufferFormatSupported()

bool Renderer::Backend::GL::CDevice::IsFramebufferFormatSupported ( const Format  format) const
overridevirtual

◆ IsTextureFormatSupported()

bool Renderer::Backend::GL::CDevice::IsTextureFormatSupported ( const Format  format) const
overridevirtual

◆ OnWindowResize()

void Renderer::Backend::GL::CDevice::OnWindowResize ( const uint32_t  width,
const uint32_t  height 
)
overridevirtual

Should be called on window surface resize.

It's the device owner responsibility to call that function. Shouldn't be called during rendering to an acquired backbuffer.

Implements Renderer::Backend::IDevice.

◆ Present()

void Renderer::Backend::GL::CDevice::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::IDevice.

◆ Report()

void Renderer::Backend::GL::CDevice::Report ( const ScriptRequest rq,
JS::HandleValue  settings 
)
overridevirtual

◆ UseFramebufferInvalidating()

bool Renderer::Backend::GL::CDevice::UseFramebufferInvalidating ( ) const
inline

Member Data Documentation

◆ m_ActiveCommandContext

CDeviceCommandContext* Renderer::Backend::GL::CDevice::m_ActiveCommandContext = nullptr
private

◆ m_ARB

bool Renderer::Backend::GL::CDevice::m_ARB = false
private

◆ m_BackbufferAcquired

bool Renderer::Backend::GL::CDevice::m_BackbufferAcquired = false
private

◆ m_Backbuffers

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

◆ m_Capabilities

Capabilities Renderer::Backend::GL::CDevice::m_Capabilities {}
private

◆ m_Context

SDL_GLContext Renderer::Backend::GL::CDevice::m_Context = nullptr
private

◆ m_DriverInformation

std::string Renderer::Backend::GL::CDevice::m_DriverInformation
private

◆ m_Extensions

std::vector<std::string> Renderer::Backend::GL::CDevice::m_Extensions
private

◆ m_Name

std::string Renderer::Backend::GL::CDevice::m_Name
private

◆ m_SurfaceDrawableHeight

int Renderer::Backend::GL::CDevice::m_SurfaceDrawableHeight = 0
private

◆ m_SurfaceDrawableWidth

int Renderer::Backend::GL::CDevice::m_SurfaceDrawableWidth = 0
private

◆ m_UseFramebufferInvalidating

bool Renderer::Backend::GL::CDevice::m_UseFramebufferInvalidating = false
private

◆ m_Version

std::string Renderer::Backend::GL::CDevice::m_Version
private

◆ m_Window

SDL_Window* Renderer::Backend::GL::CDevice::m_Window = nullptr
private

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