MAGE  v0.171.0
Matthias Advanced Game Engine
mage::rendering::ConstantBuffer< T > Class Template Reference

#include <constant_buffer.hpp>

Public Member Functions

 ConstantBuffer (ID3D11Device &device)
 
 ConstantBuffer (const ConstantBuffer &buffer)=delete
 
 ConstantBuffer (ConstantBuffer &&buffer) noexcept=default
 
 ~ConstantBuffer ()=default
 
ConstantBufferoperator= (const ConstantBuffer &buffer)=delete
 
ConstantBufferoperator= (ConstantBuffer &&buffer) noexcept=default
 
void UpdateData (ID3D11DeviceContext &device_context, const T &data)
 
ID3D11Buffer & Get () const noexcept
 
template<typename PipelineStageT >
void Bind (ID3D11DeviceContext &device_context, U32 slot) const noexcept
 

Private Member Functions

void SetupConstantBuffer (ID3D11Device &device)
 

Private Attributes

ComPtr< ID3D11Buffer > m_buffer
 

Detailed Description

template<typename T>
class mage::rendering::ConstantBuffer< T >

A class of constant buffers.

Template Parameters
TThe data type.

Constructor & Destructor Documentation

◆ ConstantBuffer() [1/3]

template<typename T>
mage::rendering::ConstantBuffer< T >::ConstantBuffer ( ID3D11Device &  device)
explicit

Constructs a constant buffer.

Parameters
[in]deviceA reference to the device.
Exceptions
ExceptionFailed to setup this constant buffer.

◆ ConstantBuffer() [2/3]

template<typename T>
mage::rendering::ConstantBuffer< T >::ConstantBuffer ( const ConstantBuffer< T > &  buffer)
delete

Constructs a constant buffer from the given constant buffer.

Parameters
[in]bufferA reference to the constant buffer to copy.

◆ ConstantBuffer() [3/3]

template<typename T>
mage::rendering::ConstantBuffer< T >::ConstantBuffer ( ConstantBuffer< T > &&  buffer)
defaultnoexcept

Constructs a constant buffer by moving the given constant buffer.

Parameters
[in]bufferA reference to the constant buffer to move.

◆ ~ConstantBuffer()

template<typename T>
mage::rendering::ConstantBuffer< T >::~ConstantBuffer ( )
default

Destructs this constant buffer.

Member Function Documentation

◆ Bind()

template<typename T>
template<typename PipelineStageT >
void mage::rendering::ConstantBuffer< T >::Bind ( ID3D11DeviceContext &  device_context,
U32  slot 
) const
noexcept

Binds this constant buffer.

Precondition
slot < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT.
Template Parameters
PipelineStageTThe pipeline stage type.
Parameters
[in,out]device_contextA reference to the device context.
[in]slotThe index into the device's zero-based array to set the constant buffer to (ranges from 0 to D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT
  • 1).

◆ Get()

template<typename T>
ID3D11Buffer& mage::rendering::ConstantBuffer< T >::Get ( ) const
noexcept

Returns the buffer resource of this constant buffer.

Returns
A reference to the buffer resource of this constant buffer.

◆ operator=() [1/2]

template<typename T>
ConstantBuffer& mage::rendering::ConstantBuffer< T >::operator= ( const ConstantBuffer< T > &  buffer)
delete

Copies the given constant buffer to this constant buffer.

Parameters
[in]bufferA reference to the constant buffer to copy.
Returns
A reference to the copy of the given constant buffer (i.e. this constant buffer).

◆ operator=() [2/2]

template<typename T>
ConstantBuffer& mage::rendering::ConstantBuffer< T >::operator= ( ConstantBuffer< T > &&  buffer)
defaultnoexcept

Moves the given constant buffer to this constant buffer.

Parameters
[in]bufferA reference to the constant buffer to move.
Returns
A reference to the moved constant buffer (i.e. this constant buffer).

◆ SetupConstantBuffer()

template<typename T>
void mage::rendering::ConstantBuffer< T >::SetupConstantBuffer ( ID3D11Device &  device)
private

Sets up the resource buffer of this constant buffer.

Parameters
[in]deviceA reference to the device.
Exceptions
ExceptionFailed to setup this constant buffer.

◆ UpdateData()

template<typename T>
void mage::rendering::ConstantBuffer< T >::UpdateData ( ID3D11DeviceContext &  device_context,
const T &  data 
)

Updates the data of this constant buffer with the given data.

Parameters
[in,out]device_contextA reference to the device context.
[in]dataA reference to the data.
Exceptions
ExceptionFailed to update the data.

Member Data Documentation

◆ m_buffer

template<typename T>
ComPtr< ID3D11Buffer > mage::rendering::ConstantBuffer< T >::m_buffer
private

A pointer to the buffer resource of this constant buffer.