Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::GBuffer Class Reference

G-buffer manages a set of render targets. More...

#include <GBuffer.hpp>

Classes

struct  ElementDesc
 G-buffer element description. More...
 

Public Member Functions

 GBuffer (const ElementDesc *Elements, size_t NumElements)
 Initializes the G-buffer object.
 
 GBuffer (const ElementDesc *Elements, size_t NumElements, IRenderDevice *pDevice, Uint32 Width, Uint32 Height)
 Initializes the G-buffer object and creates the textures.
 
const ElementDescGetElementDesc (Uint32 Index) const
 Gets the element description for the specified index.
 
ITextureGetBuffer (Uint32 Index) const
 Gets the buffer texture for the specified index.
 
size_t GetBufferCount () const
 Gets the number of buffers in the G-buffer.
 
void Resize (IRenderDevice *pDevice, Uint32 Width, Uint32 Height)
 Resizes the G-buffer textures.
 
void Bind (IDeviceContext *pContext, Uint32 BuffersMask, ITextureView *pDSV, Uint32 ClearMask=0, const Uint32 *RTIndices=nullptr)
 Binds the G-buffer textures to the device context.
 

Detailed Description

G-buffer manages a set of render targets.

Constructor & Destructor Documentation

◆ GBuffer()

Diligent::GBuffer::GBuffer ( const ElementDesc * Elements,
size_t NumElements )

Initializes the G-buffer object.

The textures will be created when the GBuffer::Resize() method is called.

Member Function Documentation

◆ Bind()

void Diligent::GBuffer::Bind ( IDeviceContext * pContext,
Uint32 BuffersMask,
ITextureView * pDSV,
Uint32 ClearMask = 0,
const Uint32 * RTIndices = nullptr )

Binds the G-buffer textures to the device context.

Parameters
[in]pContext- Device context to bind the textures to.
[in]BuffersMask- Bitmask indicating which buffers to bind.
[in]pDSV- Depth-stencil view to set.
[in]ClearMask- Bitmask indicating which buffers to clear.
[in]RTIndices- Optional array of render target indices to use for each buffer. If null, the buffer index is used. The array must contain one index for each buffer specified by the BuffersMask.

The method binds all textures in the order they were specified in the constructor.

If the corresponding bit in the BuffersMask is not set, null view is bound.

If there are depth-stencil textures in the G-buffer and the corresponding bit in the BuffersMask is set, the texture is bound as depth-stencil view. Otherwise, the user-provided depth-stencil view is bound.

If the corresponding bit in the ClearMask is set, the texture is cleared with the clear value specified in the corresponding element description.