LiteFX 0.4.1.2025
Computer Graphics Engine
Loading...
Searching...
No Matches
LiteFX::Rendering::RenderTarget Class Reference

Implements a render target. More...

#include <rendering_api.hpp>

Inherits LiteFX::Rendering::IRenderTarget.

Classes

class  RenderTargetImpl
 

Public Member Functions

 RenderTarget (UInt64 uid, UInt32 location, RenderTargetType type, Format format, RenderTargetFlags flags=RenderTargetFlags::None, const Vector4f &clearValues={ 0.f, 0.f, 0.f, 0.f }, const BlendState &blendState={})
 Initializes the render target.
 
 RenderTarget (StringView name, UInt32 location, RenderTargetType type, Format format, RenderTargetFlags flags=RenderTargetFlags::None, const Vector4f &clearValues={ 0.f, 0.f, 0.f, 0.f }, const BlendState &blendState={})
 Initializes the render target.
 
 RenderTarget (const RenderTarget &_other)
 Creates a copy of a render target.
 
 RenderTarget (RenderTarget &&_other) noexcept
 Takes over another instance of a render target.
 
RenderTargetoperator= (const RenderTarget &_other)
 Assigns a render target by copying it.
 
RenderTargetoperator= (RenderTarget &&_other) noexcept
 Assigns a render target by taking it over.
 
 ~RenderTarget () noexcept override
 Releases the render target instance.
 
UInt64 identifier () const noexcept override
 A unique identifier for the render target.
Returns
The unique identifier for the render target.

 
const Stringname () const noexcept override
 Returns the name of the render target.
Returns
The name of the render target.

 
UInt32 location () const noexcept override
 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.
 
RenderTargetType type () const noexcept override
 Returns the type of the render target.
Returns
The type of the render target.

 
Format format () const noexcept override
 Returns the internal format of the render target.
Returns
The internal format of the render target.

 
RenderTargetFlags flags () const noexcept override
 Returns the flags that control the behavior of the render target.
Returns
The flags that control the behavior of the render target.

 
bool clearBuffer () const noexcept override
 Returns true, if the render target should be cleared, when the render pass is started. If the format is set to a depth format, this clears the depth buffer. Otherwise it clears the color buffer.
Returns
true, if the render target should be cleared, when the render pass is started
See also
clearStencil, clearValues, flags, RenderTargetFlags

 
bool clearStencil () const noexcept override
 Returns true, if the render target stencil should be cleared, when the render pass is started. If the format is does not contain a stencil channel, this has no effect.
Returns
true, if the render target stencil should be cleared, when the render pass is started
See also
clearStencil, clearValues, flags, RenderTargetFlags

 
const Vector4fclearValues () const noexcept override
 Returns the value, the render target is cleared with, if clearBuffer either or clearStencil is specified.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.
 
bool isVolatile () const noexcept override
 Returns true, if the target should not be made persistent for access after the render pass has finished.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.
 
const BlendStateblendState () const noexcept override
 Returns the render targets blend state.
Returns
The render targets blend state.

 
- Public Member Functions inherited from LiteFX::Rendering::IRenderTarget
virtual ~IRenderTarget () noexcept=default
 

Additional Inherited Members

- Protected Member Functions inherited from LiteFX::Rendering::IRenderTarget
 IRenderTarget () noexcept=default
 
 IRenderTarget (const IRenderTarget &)=default
 
 IRenderTarget (IRenderTarget &&) noexcept=default
 
IRenderTargetoperator= (const IRenderTarget &)=default
 
IRenderTargetoperator= (IRenderTarget &&) noexcept=default
 

Detailed Description

Implements a render target.

IRenderTarget

Constructor & Destructor Documentation

◆ RenderTarget() [1/4]

RenderTarget::RenderTarget ( UInt64 uid,
UInt32 location,
RenderTargetType type,
Format format,
RenderTargetFlags flags = RenderTargetFlags::None,
const Vector4f & clearValues = { 0.f , 0.f, 0.f, 0.f },
const BlendState & blendState = {} )
explicit

Initializes the render target.

Parameters
uidA unique identifier for the render target.
locationThe location of the render target output attachment.
typeThe type of the render target.
formatThe format of the render target.
flagsThe flags that control the behavior of the render target.
clearValuesThe values with which the render target gets cleared.
blendStateThe render target blend state.

◆ RenderTarget() [2/4]

RenderTarget::RenderTarget ( StringView name,
UInt32 location,
RenderTargetType type,
Format format,
RenderTargetFlags flags = RenderTargetFlags::None,
const Vector4f & clearValues = { 0.f , 0.f, 0.f, 0.f },
const BlendState & blendState = {} )
explicit

Initializes the render target.

This overload uses the <paramname ref="name" > parameter to compute the identifier.

Parameters
nameThe unique name of the render target.
locationThe location of the render target output attachment.
typeThe type of the render target.
formatThe format of the render target.
flagsThe flags that control the behavior of the render target.
clearValuesThe values with which the render target gets cleared.
blendStateThe render target blend state.

◆ RenderTarget() [3/4]

RenderTarget::RenderTarget ( const RenderTarget & _other)
default

Creates a copy of a render target.

Parameters
_otherThe render target instance to copy.

◆ RenderTarget() [4/4]

RenderTarget::RenderTarget ( RenderTarget && _other)
defaultnoexcept

Takes over another instance of a render target.

Parameters
_otherThe render target instance to take over.

◆ ~RenderTarget()

RenderTarget::~RenderTarget ( )
overridedefaultnoexcept

Releases the render target instance.

Member Function Documentation

◆ blendState()

const IRenderTarget::BlendState & RenderTarget::blendState ( ) const
overridevirtualnoexcept

Returns the render targets blend state.

Returns
The render targets blend state.

Implements LiteFX::Rendering::IRenderTarget.

◆ clearBuffer()

bool RenderTarget::clearBuffer ( ) const
overridevirtualnoexcept

Returns true, if the render target should be cleared, when the render pass is started. If the format is set to a depth format, this clears the depth buffer. Otherwise it clears the color buffer.

Returns
true, if the render target should be cleared, when the render pass is started
See also
clearStencil, clearValues, flags, RenderTargetFlags

Implements LiteFX::Rendering::IRenderTarget.

◆ clearStencil()

bool RenderTarget::clearStencil ( ) const
overridevirtualnoexcept

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

Returns
true, if the render target stencil should be cleared, when the render pass is started
See also
clearStencil, clearValues, flags, RenderTargetFlags

Implements LiteFX::Rendering::IRenderTarget.

◆ clearValues()

const Vector4f & RenderTarget::clearValues ( ) const
overridevirtualnoexcept

Returns the value, the render target is cleared with, if clearBuffer either or clearStencil is specified.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.

Implements LiteFX::Rendering::IRenderTarget.

◆ flags()

RenderTargetFlags RenderTarget::flags ( ) const
overridevirtualnoexcept

Returns the flags that control the behavior of the render target.

Returns
The flags that control the behavior of the render target.

Implements LiteFX::Rendering::IRenderTarget.

◆ format()

Format RenderTarget::format ( ) const
overridevirtualnoexcept

Returns the internal format of the render target.

Returns
The internal format of the render target.

Implements LiteFX::Rendering::IRenderTarget.

◆ identifier()

UInt64 RenderTarget::identifier ( ) const
overridevirtualnoexcept

A unique identifier for the render target.

Returns
The unique identifier for the render target.

Implements LiteFX::Rendering::IRenderTarget.

◆ isVolatile()

bool RenderTarget::isVolatile ( ) const
overridevirtualnoexcept

Returns true, if the target should not be made persistent for access after the render pass has finished.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.

Implements LiteFX::Rendering::IRenderTarget.

◆ location()

UInt32 RenderTarget::location ( ) const
overridevirtualnoexcept

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.

Implements LiteFX::Rendering::IRenderTarget.

◆ name()

const String & RenderTarget::name ( ) const
overridevirtualnoexcept

Returns the name of the render target.

Returns
The name of the render target.

Implements LiteFX::Rendering::IRenderTarget.

◆ operator=() [1/2]

RenderTarget & RenderTarget::operator= ( const RenderTarget & _other)
default

Assigns a render target by copying it.

Parameters
_otherThe render target instance to copy.
Returns
A reference to the current render target instance.

◆ operator=() [2/2]

RenderTarget & RenderTarget::operator= ( RenderTarget && _other)
defaultnoexcept

Assigns a render target by taking it over.

Parameters
_otherThe render target to take over.
Returns
A reference to the current render target instance.

◆ type()

RenderTargetType RenderTarget::type ( ) const
overridevirtualnoexcept

Returns the type of the render target.

Returns
The type of the render target.

Implements LiteFX::Rendering::IRenderTarget.