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

Public Member Functions

 MaterialManager (size_t capacity, size_t parametersCapacity)
 
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)
 
void upload (const Material &material)
 
void uploadParameters (const ShaderMaterial &material)
 
bool hasPendingUploads () const
 
void collectRetired ()
 
size_t releaseUnusedMemory (const vireo::CommandList &commandList)
 
void flush ()
 
void flush (const vireo::CommandList &commandList)
 
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
 
void collectRetired ()
 
Material & create (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
 
ResourcesManager & operator= (ResourcesManager &) = delete
 
Material & operator[] (const unique_id id)
 
const Material & operator[] (const unique_id id) const
 
void requireAvailable (const size_t count)
 
void setRetirementProvider (std::function< UsageGuards ()> provider)
 
void use (const unique_id id)
 
virtual ~ResourcesManager ()
 

Additional Inherited Members

- Public Typedefs inherited from ResourcesManager< Material >
using UsageGuards = std::vector< std::weak_ptr< const void > >
 
- Protected Member Functions inherited from ResourcesManager< Material >
 ResourcesManager (const size_t capacity, const std::string &name)
 
Material & allocate (std::unique_ptr< Material > instance)
 
void enableGrowth (size_t maximum=std::numeric_limits< uint32 >::max ())
 
bool isFull () const
 
- Protected Attributes inherited from ResourcesManager< Material >
std::vector< std::unique_ptr< Material > > resources
 
std::recursive_mutex resourcesMutex
 

Constructor & Destructor Documentation

MaterialManager ( size_t  capacity,
size_t  parametersCapacity 
)

Construct a manager bound to the given runtime context.

Parameters
capacityInitial number of material slots
parametersCapacityInitial float4 parameter capacity across all shader materials

Member Function Documentation

void collectRetired ( )

Collect retired CPU slots and GPU allocations without submitting commands.

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 ( )
void flush ( const vireo::CommandList &  commandList)

Record global uploads/migrations on the shared graphics queue command list.

auto getBuffer ( ) const
inline
auto getParametersBuffer ( ) const
inline

Returns the GPU buffer for the shader material parameters SSBO.

bool hasPendingUploads ( ) const

Returns whether resource uploads are pending.

size_t releaseUnusedMemory ( const vireo::CommandList &  commandList)
void upload ( const Material &  material)
void uploadParameters ( const ShaderMaterial &  material)

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