Lysa  0.0
Lysa 3D Engine
MaterialManager Class Reference
+ Inheritance diagram for MaterialManager:

Public Member Functions

 MaterialManager (size_t capacity, size_t parametersCapacity)
 
StandardMaterialcreate ()
 
ShaderMaterialcreate (const std::shared_ptr< ShaderMaterial > &orig)
 
ShaderMaterialcreate (const std::string &fragShaderFileName, const std::string &vertShaderFileName, uint32 parameterCount=0, RenderingPhase stage=RenderingPhase::DEFAULT)
 
ShaderMaterialcreate (const std::string &fragShaderFileName, uint32 parameterCount=0, RenderingPhase stage=RenderingPhase::DEFAULT)
 
void upload (const Material &material)
 
void uploadParameters (const ShaderMaterial &material)
 
void flush ()
 
auto getBuffer () const
 
auto getParametersBuffer () const
 
bool destroy (unique_id id) override
 
bool destroy (const StandardMaterial &m)
 
bool destroy (const ShaderMaterial &m)
 
- Public Member Functions inherited from ResourcesManager< Material >
 ResourcesManager (ResourcesManager &) = delete
 
Materialcreate (Args &&...args)
 
virtual bool destroy (const Material &res)
 
void destroy (const std::vector< unique_id > &ids)
 
void forEach (Func &&func)
 
void forEach (Func &&func) const
 
unique_id getCapacity () const
 
bool have (const unique_id id) const
 
ResourcesManageroperator= (ResourcesManager &) = delete
 
Materialoperator[] (const unique_id id)
 
const Materialoperator[] (const unique_id id) const
 
void use (const unique_id id)
 
virtual ~ResourcesManager ()
 

Additional Inherited Members

- Protected Member Functions inherited from ResourcesManager< Material >
 ResourcesManager (const size_t capacity, const std::string &name)
 
Materialallocate (std::unique_ptr< Material > instance)
 
bool isFull () const
 
- Protected Attributes inherited from ResourcesManager< Material >
std::vector< std::unique_ptr< Material > > resources
 
std::mutex resourcesMutex
 

Constructor & Destructor Documentation

MaterialManager ( size_t  capacity,
size_t  parametersCapacity 
)

Construct a manager bound to the given runtime context.

Parameters
capacityMaximum number of materials
parametersCapacityTotal maximum number of float4 parameter slots across all shader materials

Member Function Documentation

StandardMaterial& create ( )
ShaderMaterial& create ( const std::shared_ptr< ShaderMaterial > &  orig)
ShaderMaterial& create ( const std::string &  fragShaderFileName,
const std::string &  vertShaderFileName,
uint32  parameterCount = 0,
RenderingPhase  stage = RenderingPhase::DEFAULT 
)
ShaderMaterial& create ( const std::string &  fragShaderFileName,
uint32  parameterCount = 0,
RenderingPhase  stage = RenderingPhase::DEFAULT 
)
bool destroy ( const ShaderMaterial m)
inline
bool destroy ( const StandardMaterial m)
inline
bool destroy ( unique_id  id)
overridevirtual

Releases a resource by ID, decrementing its reference counter. The slot is returned to the free list only when the counter reaches zero.

Parameters
idUnique identifier of the resource to destroy.
Returns
true if the resource was actually freed, false if references remain.

Reimplemented from lysa::ResourcesManager< Material >::destroy()

void flush ( )
auto getBuffer ( ) const
inline
auto getParametersBuffer ( ) const
inline

Returns the GPU buffer for the shader material parameters SSBO.

void upload ( const Material material)
void uploadParameters ( const ShaderMaterial material)

Schedules an upload of the parameters SSBO block for the given ShaderMaterial.