MAGE  v0.171.0
Matthias Advanced Game Engine
mage::rendering::StateManager Class Reference

#include <state_manager.hpp>

Public Member Functions

 StateManager (ID3D11Device &device)
 
 StateManager (const StateManager &manager)=delete
 
 StateManager (StateManager &&manager) noexcept
 
 ~StateManager ()
 
StateManageroperator= (const StateManager &manager)=delete
 
StateManageroperator= (StateManager &&manager) noexcept
 
void BindPersistentState (ID3D11DeviceContext &device_context) const noexcept
 
void Bind (ID3D11DeviceContext &device_context, BlendStateID id) const noexcept
 
void Bind (ID3D11DeviceContext &device_context, DepthStencilStateID id) const noexcept
 
void Bind (ID3D11DeviceContext &device_context, RasterizerStateID id) const noexcept
 
template<typename PipelineStageT >
void BindPointWrapSamplerStateID (ID3D11DeviceContext &device_context, U32 slot, SamplerStateID id) const noexcept
 

Private Member Functions

void SetupRenderingStates ()
 
void SetupBlendStates ()
 
void SetupDepthStencilStates ()
 
void SetupRasterizerStates ()
 
void SetupSamplerStates ()
 
ID3D11BlendState * Get (BlendStateID id) const noexcept
 
NotNull< ID3D11BlendState **> ReleaseAndGetAddressOf (BlendStateID id) noexcept
 
ID3D11DepthStencilState * Get (DepthStencilStateID id) const noexcept
 
NotNull< ID3D11DepthStencilState **> ReleaseAndGetAddressOf (DepthStencilStateID id) noexcept
 
ID3D11RasterizerState * Get (RasterizerStateID id) const noexcept
 
NotNull< ID3D11RasterizerState **> ReleaseAndGetAddressOf (RasterizerStateID id) noexcept
 
ID3D11SamplerState * Get (SamplerStateID id) const noexcept
 
NotNull< ID3D11SamplerState **> ReleaseAndGetAddressOf (SamplerStateID id) noexcept
 

Private Attributes

std::reference_wrapper< ID3D11Device > m_device
 
ComPtr< ID3D11BlendState > m_blend_states [static_cast< std::size_t >(BlendStateID::Count)]
 
ComPtr< ID3D11DepthStencilState > m_depth_stencil_states [static_cast< std::size_t >(DepthStencilStateID::Count)]
 
ComPtr< ID3D11RasterizerState > m_rasterizer_states [static_cast< std::size_t >(RasterizerStateID::Count)]
 
ComPtr< ID3D11SamplerState > m_sampler_states [static_cast< std::size_t >(SamplerStateID::Count)]
 

Detailed Description

A class of state managers.

Constructor & Destructor Documentation

◆ StateManager() [1/3]

mage::rendering::StateManager::StateManager ( ID3D11Device &  device)
explicit

Constructs a state manager.

Parameters
[in,out]deviceA reference to the device.
Exceptions
ExceptionFailed to setup the rendering states of this state manager.

◆ StateManager() [2/3]

mage::rendering::StateManager::StateManager ( const StateManager manager)
delete

Constructs a state manager from the given state manager.

Parameters
[in]managerA reference to the state manager to copy.

◆ StateManager() [3/3]

mage::rendering::StateManager::StateManager ( StateManager &&  manager)
defaultnoexcept

Constructs a state manager by moving the given state manager.

Parameters
[in]managerA reference to the state manager to move.

◆ ~StateManager()

mage::rendering::StateManager::~StateManager ( )
default

Destructs this state manager.

Member Function Documentation

◆ Bind() [1/3]

void mage::rendering::StateManager::Bind ( ID3D11DeviceContext &  device_context,
BlendStateID  id 
) const
noexcept

Binds the given blend state of this state manager.

Parameters
[in,out]device_contextA reference to the device context.
[in]idThe blend state identifier.

◆ Bind() [2/3]

void mage::rendering::StateManager::Bind ( ID3D11DeviceContext &  device_context,
DepthStencilStateID  id 
) const
noexcept

Binds the given depth-stencil state of this state manager.

Parameters
[in,out]device_contextA reference to the device context.
[in]idThe depth-stencil state identifier.

◆ Bind() [3/3]

void mage::rendering::StateManager::Bind ( ID3D11DeviceContext &  device_context,
RasterizerStateID  id 
) const
noexcept

Binds the given rasterizer state of this state manager.

Parameters
[in,out]device_contextA reference to the device context.
[in]idThe rasterizer state identifier.

◆ BindPersistentState()

void mage::rendering::StateManager::BindPersistentState ( ID3D11DeviceContext &  device_context) const
noexcept

Binds the persistent state of this state manager.

Parameters
[in,out]device_contextA reference to the device context.

◆ BindPointWrapSamplerStateID()

template<typename PipelineStageT >
void mage::rendering::StateManager::BindPointWrapSamplerStateID ( ID3D11DeviceContext &  device_context,
U32  slot,
SamplerStateID  id 
) const
noexcept

Binds the point sampler state with wrapping of this state manager.

Precondition
SLOT_SAMPLER_VARIABLE_START <= slot.
slot < SLOT_SAMPLER_VARIABLE_END.
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 sampler to (ranges from SLOT_SAMPLER_VARIABLE_START to SLOT_SAMPLER_VARIABLE_END).
[in]idThe sampler state identifier.

◆ Get() [1/4]

ID3D11BlendState* mage::rendering::StateManager::Get ( BlendStateID  id) const
privatenoexcept

Returns the blend state of this state manager associated to the given identifier.

Parameters
[in]idThe blend state identifier.
Returns
A pointer to the blend state of this state manager associated to the given identifier.

◆ Get() [2/4]

ID3D11DepthStencilState* mage::rendering::StateManager::Get ( DepthStencilStateID  id) const
privatenoexcept

Returns the depth stencil state of this state manager associated to the given identifier.

Parameters
[in]idThe depth stencil identifier.
Returns
A pointer to the depth stencil state of this state manager associated to the given identifier.

◆ Get() [3/4]

ID3D11RasterizerState* mage::rendering::StateManager::Get ( RasterizerStateID  id) const
privatenoexcept

Returns the rasterizer state of this state manager associated to the given identifier.

Parameters
[in]idThe rasterizer identifier.
Returns
A pointer to the rasterizer state of this state manager associated to the given identifier.

◆ Get() [4/4]

ID3D11SamplerState* mage::rendering::StateManager::Get ( SamplerStateID  id) const
privatenoexcept

Returns the sampler state of this state manager associated to the given identifier.

Parameters
[in]idThe sampler state identifier.
Returns
A pointer to the sampler state of this state manager associated to the given identifier.

◆ operator=() [1/2]

StateManager& mage::rendering::StateManager::operator= ( const StateManager manager)
delete

Copies the given state manager to this state manager.

Parameters
[in]managerA reference to the state manager to copy.
Returns
A reference to the copy of the given state manager (i.e. this state manager).

◆ operator=() [2/2]

StateManager & mage::rendering::StateManager::operator= ( StateManager &&  manager)
defaultnoexcept

Moves the given state manager to this state manager.

Parameters
[in]managerA reference to the state manager to move.
Returns
A reference to the moved state manager (i.e. this state manager).

◆ ReleaseAndGetAddressOf() [1/4]

NotNull< ID3D11BlendState** > mage::rendering::StateManager::ReleaseAndGetAddressOf ( BlendStateID  id)
privatenoexcept

Returns and releases the address of the blend state of this state manager associated to the given identifier.

Parameters
[in]idThe blend state identifier.
Returns
A pointer to a pointer to the blend state of this state manager associated to the given identifier.

◆ ReleaseAndGetAddressOf() [2/4]

NotNull< ID3D11DepthStencilState** > mage::rendering::StateManager::ReleaseAndGetAddressOf ( DepthStencilStateID  id)
privatenoexcept

Returns and releases the address of the depth stencil state of this state manager associated to the given identifier.

Parameters
[in]idThe depth stencil identifier.
Returns
A pointer to a pointer to the depth stencil state of this state manager associated to the given identifier.

◆ ReleaseAndGetAddressOf() [3/4]

NotNull< ID3D11RasterizerState** > mage::rendering::StateManager::ReleaseAndGetAddressOf ( RasterizerStateID  id)
privatenoexcept

Returns and releases the address of the rasterizer state of this state manager associated to the given identifier.

Parameters
[in]idThe rasterizer state identifier.
Returns
A pointer to a pointer to the rasterizer state of this state manager associated to the given identifier.

◆ ReleaseAndGetAddressOf() [4/4]

NotNull< ID3D11SamplerState** > mage::rendering::StateManager::ReleaseAndGetAddressOf ( SamplerStateID  id)
privatenoexcept

Returns and releases the address of the sampler state of this state manager associated to the given identifier.

Parameters
[in]idThe sampler state identifier.
Returns
A pointer to a pointer to the sampler state of this state manager associated to the given identifier.

◆ SetupBlendStates()

void mage::rendering::StateManager::SetupBlendStates ( )
private

Setup the blend states of this state manager.

Exceptions
ExceptionFailed to setup the blend states of this state manager.

◆ SetupDepthStencilStates()

void mage::rendering::StateManager::SetupDepthStencilStates ( )
private

Setup the depth stencil states of this state manager.

Exceptions
ExceptionFailed to setup the depth stencil states of state manager.

◆ SetupRasterizerStates()

void mage::rendering::StateManager::SetupRasterizerStates ( )
private

Setup the rasterizer states of this state manager.

Exceptions
ExceptionFailed to setup the rasterizer states of this state manager.

◆ SetupRenderingStates()

void mage::rendering::StateManager::SetupRenderingStates ( )
private

Setup the rendering states (blend, depth stencil, rasterizer, sampler) of this state manager.

Exceptions
ExceptionFailed to setup the rendering states of this state manager.

◆ SetupSamplerStates()

void mage::rendering::StateManager::SetupSamplerStates ( )
private

Setup the samplers states of this state manager.

Exceptions
ExceptionFailed to setup the samplers states of this state manager.

Member Data Documentation

◆ m_blend_states

ComPtr< ID3D11BlendState > mage::rendering::StateManager::m_blend_states[ static_cast< std::size_t >(BlendStateID::Count)]
private

An array containing pointers to the blend states of this state manager.

◆ m_depth_stencil_states

ComPtr< ID3D11DepthStencilState > mage::rendering::StateManager::m_depth_stencil_states[ static_cast< std::size_t >(DepthStencilStateID::Count)]
private

An array containing pointers to the depth stencil states of this state manager.

◆ m_device

std::reference_wrapper< ID3D11Device > mage::rendering::StateManager::m_device
private

A reference to the device of this state manager.

◆ m_rasterizer_states

ComPtr< ID3D11RasterizerState > mage::rendering::StateManager::m_rasterizer_states[ static_cast< std::size_t >(RasterizerStateID::Count)]
private

An array containing pointers to the rasterizer states of this state manager.

◆ m_sampler_states

ComPtr< ID3D11SamplerState > mage::rendering::StateManager::m_sampler_states[ static_cast< std::size_t >(SamplerStateID::Count)]
private

An array containing pointers to the sampler states of this state manager.