CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::RendererMaterialManager Class Reference

A manager that controls all materials currently in use by the renderer. More...

#include <CeresEngine/Renderer/RendererMaterial.hpp>

Public Member Functions

 RendererMaterialManager (Renderer &renderer, GPUDevice &device)
 Creates a new instance of the RendererMaterialManager.
 
 ~RendererMaterialManager ()
 Destroys the RendererMaterialManager and releases all GPU resources managed and allocated by it.
 
SPtr< RendererMaterialget (const HMaterial &material)
 Gets a renderer material instance for the given material resource.
 
Async prepare (RendererContext &context)
 Prepares the materials for the rendering of the current frame.
 
RenderergetRenderer () const
 The renderer that owns this manager instance.
 
RendererMaterialgetDefaultMaterial () const
 The default material to be used as a fallback in case no material is defined by the user.
 
const GPUBindlessBuffergetUniformBuffer () const noexcept
 The uniform buffer that holds GPU parameters for all materials.
 

Private Types

using UniformBufferType = GPUDynamicStridedBindlessBufferArray< PBRMaterialParams >
 The type used to store uniform buffers.
 

Private Attributes

RenderermRenderer
 The renderer that owns this manager instance.
 
GPUDevicemDevice
 The device the renderer will render to.
 
HashMap< HMaterial, WPtr< RendererMaterial > > mMaterials
 A list of materials currently registered with the renderer.
 
SPtr< RendererMaterialmDefaultMaterial
 The default material to be used as a fallback in case no material is defined by the user.
 
UniformBufferType mUniformBuffer
 The uniform buffer that holds GPU parameters for all materials.
 

Detailed Description

A manager that controls all materials currently in use by the renderer.

Member Typedef Documentation

◆ UniformBufferType

Constructor & Destructor Documentation

◆ RendererMaterialManager()

CeresEngine::RendererMaterialManager::RendererMaterialManager ( Renderer renderer,
GPUDevice device 
)
explicit

Creates a new instance of the RendererMaterialManager.

◆ ~RendererMaterialManager()

CeresEngine::RendererMaterialManager::~RendererMaterialManager ( )

Destroys the RendererMaterialManager and releases all GPU resources managed and allocated by it.

Member Function Documentation

◆ get()

SPtr< RendererMaterial > CeresEngine::RendererMaterialManager::get ( const HMaterial material)

Gets a renderer material instance for the given material resource.

If an existing RendererMaterial for the given material resource already exists, a shared instance is returned. If no existing RendererMaterial instance exists for the given material a new one will be created and returned.

Changes done to the underlying Material resource will be automatically tracked by the manager and the renderer material will replicate the changes.

Parameters
materialThe material resource to locate a new renderer material for.
Returns
A shared RendererMaterial instance for the given material resource.

◆ getDefaultMaterial()

RendererMaterial & CeresEngine::RendererMaterialManager::getDefaultMaterial ( ) const
inline

The default material to be used as a fallback in case no material is defined by the user.

◆ getRenderer()

Renderer & CeresEngine::RendererMaterialManager::getRenderer ( ) const
inline

The renderer that owns this manager instance.

◆ getUniformBuffer()

const GPUBindlessBuffer & CeresEngine::RendererMaterialManager::getUniformBuffer ( ) const
inlinenoexcept

The uniform buffer that holds GPU parameters for all materials.

Meant to be used by bindless render passes.

◆ prepare()

Async CeresEngine::RendererMaterialManager::prepare ( RendererContext context)

Prepares the materials for the rendering of the current frame.

This will update uniform buffers and perform any other necessary operations necessary for rendering. All prepared data must be view independent.

Parameters
contextA context struct that contains parameters given by the renderer.

Member Data Documentation

◆ mDefaultMaterial

SPtr<RendererMaterial> CeresEngine::RendererMaterialManager::mDefaultMaterial
private

The default material to be used as a fallback in case no material is defined by the user.

◆ mDevice

GPUDevice& CeresEngine::RendererMaterialManager::mDevice
private

The device the renderer will render to.

Materials will be synchronized and uploaded to this device.

◆ mMaterials

HashMap<HMaterial, WPtr<RendererMaterial> > CeresEngine::RendererMaterialManager::mMaterials
private

A list of materials currently registered with the renderer.

◆ mRenderer

Renderer& CeresEngine::RendererMaterialManager::mRenderer
private

The renderer that owns this manager instance.

◆ mUniformBuffer

UniformBufferType CeresEngine::RendererMaterialManager::mUniformBuffer
private

The uniform buffer that holds GPU parameters for all materials.

Meant to be used by bindless render passes.


The documentation for this class was generated from the following file: