SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::render::IRenderTarget Class Referenceabstract

Represents a render target, which is an abstract view of the output of a RenderPass. A render target represents one output of a render pass, stored within an IImage. It is contained by a RenderPass, that contains the FrameBuffer, that stores the actual render target image resource. More...

#include <RenderTarget.h>

Inheritance diagram for spark::render::IRenderTarget:
spark::render::RenderTarget

Classes

struct  BlendState
 Describes the blend state of a render target. More...
 

Public Member Functions

virtual std::string name () const noexcept=0
 Gets the name of the render target.
 
virtual unsigned int location () const noexcept=0
 Gets the location of the render target output attachment within the fragment shader.
 
virtual RenderTargetType type () const noexcept=0
 Gets the type of the render target.
 
virtual Format format () const noexcept=0
 Gets the internal format of the render target.
 
virtual bool clearBuffer () const noexcept=0
 Checks if the render target should be cleared when the render pass is started.
 
virtual bool clearStencil () const noexcept=0
 Checks if the render target stencil should be cleared when the render pass is started.
 
virtual math::Vector4< float > clearValues () const noexcept=0
 Gets the value the render target is cleared with, if clearBuffer() or clearStencil() returns true.
 
virtual bool isVolatile () const noexcept=0
 Checks if the target should not be persistent for access after the render pass has finished.
 
virtual BlendState blendState () const noexcept=0
 Gets the render target blend state.
 

Detailed Description

Represents a render target, which is an abstract view of the output of a RenderPass. A render target represents one output of a render pass, stored within an IImage. It is contained by a RenderPass, that contains the FrameBuffer, that stores the actual render target image resource.

Member Function Documentation

◆ blendState()

virtual BlendState spark::render::IRenderTarget::blendState ( ) const
nodiscardpure virtualnoexcept

Gets the render target blend state.

Returns
A BlendState value describing the blend state of the render target.

Implemented in spark::render::RenderTarget.

◆ clearBuffer()

virtual bool spark::render::IRenderTarget::clearBuffer ( ) const
pure virtualnoexcept

Checks if the render target should be cleared when the render pass is started.

Returns
true, if the render target should be cleared when the render pass is started, false otherwise.
Note
If the format() is a depth format, the depth buffer will be cleared. Otherwise, the color buffer will be cleared.

Implemented in spark::render::RenderTarget.

◆ clearStencil()

virtual bool spark::render::IRenderTarget::clearStencil ( ) const
pure virtualnoexcept

Checks if the render target stencil should be cleared when the render pass is started.

Returns
true, if the render target stencil should be cleared when the render pass is started, false otherwise.
Note
If the format() is does not contain a stencil channel, this has no effect.

Implemented in spark::render::RenderTarget.

◆ clearValues()

virtual math::Vector4< float > spark::render::IRenderTarget::clearValues ( ) const
nodiscardpure virtualnoexcept

Gets the value the render target is cleared with, if clearBuffer() or clearStencil() returns true.

Returns
The value the render target is cleared with.

If the format() is a color format and clearBuffer() is specified, this contains the clear color. However, if the format is a depth/stencil format, the R and G channels contain the depth and stencil value to clear the buffer with. Note that the stencil buffer is only cleared, if clearStencil() is specified and vice versa.

Implemented in spark::render::RenderTarget.

◆ format()

virtual Format spark::render::IRenderTarget::format ( ) const
nodiscardpure virtualnoexcept

Gets the internal format of the render target.

Returns
A Format value describing the internal format of the render target.

Implemented in spark::render::RenderTarget.

◆ isVolatile()

virtual bool spark::render::IRenderTarget::isVolatile ( ) const
nodiscardpure virtualnoexcept

Checks if the target should not be persistent for access after the render pass has finished.

Returns
true, if the target should not be persistent for access after the render pass has finished, false otherwise.

A render target can be marked as volatile if it does not need to be accessed after the render pass has finished. This can be used to optimize away unnecessary GPU/CPU memory round-trips. For example a depth buffer may only be used as an input for the lighting stage of a deferred renderer, but is not required after this. So instead of reading it from the GPU after the lighting pass has finished and then discarding it anyway, it can be marked as volatile in order to prevent it from being read from the GPU memory again in the first place.

Implemented in spark::render::RenderTarget.

◆ location()

virtual unsigned int spark::render::IRenderTarget::location ( ) const
nodiscardpure virtualnoexcept

Gets the location of the render target output attachment within the fragment shader.

Returns
The location of the render target output attachment within the fragment shader.

The locations of all render targets of a frame buffer must be within a continuous domain, starting at 0. A frame buffer validates the render target locations when it is initialized and will raise an exception, if a location is either not mapped or assigned multiple times.

Implemented in spark::render::RenderTarget.

◆ name()

virtual std::string spark::render::IRenderTarget::name ( ) const
nodiscardpure virtualnoexcept

Gets the name of the render target.

Returns
A std::string containing the name of the render target.

Implemented in spark::render::RenderTarget.

◆ type()

virtual RenderTargetType spark::render::IRenderTarget::type ( ) const
nodiscardpure virtualnoexcept

Gets the type of the render target.

Returns
A RenderTargetType value describing the type of the render target.

Implemented in spark::render::RenderTarget.