|
Cogs.Core
|
Effect manager responsible for loading, processing and activating Effect resources. More...
#include <EffectManager.h>
Public Member Functions | |
| EffectManager (Context *context) | |
| Constructs an EffectManager in the given context. | |
| ~EffectManager () | |
| Destructs the EffectManager. | |
| void | initialize () override |
| Initialize the effect manager. | |
| EffectHandle | loadEffect (const EffectDefinition &definition) |
| Load the effect described by the given definition. | |
| void | handleLoad (EffectLoadInfo *loadInfo) override |
| Overridden to handle effect loading. | |
| void | handleReload (ResourceHandleBase handle) override |
| ActivationResult | handleActivation (EffectHandle handle, Effect *effect) override |
| Overridden to handle effect activation, updating the effect in the renderer. | |
| void | handleDeletion (Effect *resource) override |
| Overridden to handle deletion, removing the effect resource from the renderer. | |
Public Member Functions inherited from Cogs::Core::ResourceManager< Effect, EffectLoadInfo > | |
| ResourceManager (Context *context, Collections::ElementOffset capacity=1024) | |
| Constructs a resource manager with the given context. | |
| ~ResourceManager () override | |
| Destructs a resource manager, provided for destruction via base pointer. | |
| void | clear () override |
| Clear the resource manager, cleaning up resources held by member handles. | |
| void | clearSwapping () override |
| Clear the swap queue, ensuring indirect resource references are released. | |
| ResourceHandle | create () |
| Create a new resource. | |
| ResourceHandle | release (ResourceId resourceId) |
| ResourceHandle | loadResource (EffectLoadInfo *loadInfo) |
| ResourceProxy | createLocked () |
| Creates a new resource, but returns a ResourceProxy for thread safe editing instead of a handle to the actual resource. | |
| ResourceProxy | lock (const ResourceHandle &handle) |
| Takes the handle given and returns a resource proxy to edit the contents of the held resource safely on other threads than the main thread. | |
| void | unlockProxy (const ResourceHandle &handle, const ResourceHandle &proxy) |
| Unlock the given resource proxy. | |
| ResourceHandle | generateHandle (ResourceBase *resource) |
| Generate a handle to the given resource. | |
| virtual void | handleLoad (EffectLoadInfo *) |
| Handler for resource loading. | |
| virtual void | handleFailedLoad (const EffectLoadInfo *) |
| Handler for failed resource loads using the given loadInfo. | |
| virtual ActivationResult | handleActivation (ResourceHandle, Effect *) |
| Handler for activation of resources. | |
| virtual void | handleDeletion (Effect *) |
| Handler for deletion of resources. | |
| Effect * | get (const ResourceHandleBase &handle) |
| Resolve the given handle to a resource. | |
| void | processSwapping () override |
| Process queued swap operations, exchanging resource contents of the destination resources by those indicated in the operation data. | |
| ResourceHandle | getHandle (const ResourceId id) const |
| Get a resource handle to the resource with the given id. | |
| void | registerLoader (IResourceLoader< Effect, EffectLoadInfo > *loader) |
| Register a resource loader capable of handling resources of the template type. | |
| void | destroyLoadInfoInternal (ResourceLoadInfoBase *loadInfo) override |
| EffectLoadInfo * | createLoadInfo () |
Public Member Functions inherited from Cogs::Core::ResourceManagerBase | |
| ResourceManagerBase (Context *context) | |
| void | initialize () override |
| void | clear () override |
| void | reportLeaks (std::string_view typeName) |
| std::string | getReport () |
| Return a string with current resource usage. | |
| bool | checkPreloaded (ResourceLoadInfoBase *loadInfo) |
| ResourceHandleBase | releaseInternal (ResourceId resourceId) |
| Releases a resourceId -> ResourceHandle mapping. | |
| ResourceHandleBase | loadResourceInternal (ResourceLoadInfoBase *loadInfo) |
| Load a resource using the given loadInfo. | |
| void | processLoading () final |
| Process loading resources. | |
| void | setProcessed (ResourceLoadInfoBase *loadInfo, bool swapping=false) |
| Signal the resource being loaded as done loading and ready for activation etc. | |
| void | activateResources () final |
| virtual void | processDeletion () override |
| Process resources pending deallocation. | |
| void | fillDeletionQueue (std::vector< ResourceBase * > &deletion) |
| void | destroyLocked (ResourceBase *resource) |
| void | safeDestroy (ResourceBase *resource) |
| ResourceId | getNextResourceId () override |
| Get the next unique resource id. | |
| void | resourceChanged (ResourceBase *resource) override |
| void | resourceDeleted (ResourceBase *resource) override |
| void | setResourceId (ResourceBase *resource, ResourceId id) override |
| Assign the given id to a previously created resource. | |
| void | queueResource (ResourceLoadInfoBase *loadInfo) |
| Re-queue the given loadInfo to defer loading to the next time the processLoading() phase is performed. | |
| virtual void | handleLoadInternal (ResourceLoadInfoBase *loadInfo)=0 |
| virtual ActivationResult | handleActivationInternal (ResourceHandleBase r, ResourceBase *resource)=0 |
| virtual void | handleDeletionInternal (ResourceBase *resource)=0 |
| virtual void | handleFailedLoadInternal (ResourceLoadInfoBase *loadInfo)=0 |
| virtual void | destroyLoadInfoInternal (ResourceLoadInfoBase *loadInfo)=0 |
| virtual bool | shouldAutoReload () const |
| virtual bool | shouldMergeBySource () const |
| virtual void | handleReload (ResourceHandleBase) |
| std::vector< ResourceBase * > | getAllocatedResources () const |
| ResourceHandleBase | getOrCreate (ResourceId id) |
| ResourceHandleBase | getByName (std::string_view name) const |
| ResourceHandleBase | getBySource (std::string_view source) const |
| ResourceHandleBase | createResource () |
| virtual ResourceBase * | createInternal ()=0 |
| virtual void | destroyInternal (ResourceBase *resource)=0 |
| virtual void | destroyInternalLocked (ResourceBase *resource)=0 |
| ResourceHandleBase | generateHandle (ResourceBase *resource) |
| void | clearUpdated () |
| virtual int | getUpdateQuota () const |
| size_t | updatedResourceCount () |
| size_t | orphanedResourceCount () |
| size_t | allocatedResourceCount () |
| virtual void | initialize ()=0 |
| virtual void | clear ()=0 |
| virtual void | clearSwapping ()=0 |
| virtual void | processLoading ()=0 |
| virtual void | processSwapping ()=0 |
| virtual void | activateResources ()=0 |
| virtual void | processDeletion ()=0 |
| virtual void | resourceChanged (ResourceBase *resource)=0 |
| virtual void | resourceDeleted (ResourceBase *resource)=0 |
| virtual ResourceId | getNextResourceId ()=0 |
| virtual void | setResourceId (ResourceBase *resource, ResourceId id)=0 |
Public Attributes | |
| std::string | extension |
| Extension used to lookup shader files. | |
| std::string | prefix |
| Prefix used to look up shader files. | |
Additional Inherited Members | |
Public Types inherited from Cogs::Core::ResourceManager< Effect, EffectLoadInfo > | |
| using | ResourceHandle = ResourceHandle_t< Effect > |
| Type of handle used to hold resources. | |
| using | ResourceProxy = ResourceProxy< Effect, ResourceManager > |
| Type of resource proxy objects, specialized on the type of resource. | |
Protected Member Functions inherited from Cogs::Core::ResourceManager< Effect, EffectLoadInfo > | |
| Effect * | createInternal () override |
| void | destroyInternal (ResourceBase *resource) override |
| void | handleLoadInternal (ResourceLoadInfoBase *loadInfo) override |
| ActivationResult | handleActivationInternal (ResourceHandleBase r, ResourceBase *resource) override |
| void | handleDeletionInternal (ResourceBase *resource) override |
| void | handleFailedLoadInternal (ResourceLoadInfoBase *loadInfo) override |
| IResourceLoader< Effect, EffectLoadInfo > * | findLoader (const EffectLoadInfo *loadInfo) |
| Find a loader capable of loading the resource given by loadInfo. | |
Protected Member Functions inherited from Cogs::Core::ResourceManagerBase | |
| ResourceHandleBase | getResourceHandle (ResourceId id) const |
| Get existing resource handle. | |
| bool | isValidResource (ResourceId id) const |
| Check if resource handle points to. | |
| virtual void | postProcessLoading () |
| Hook for resource managers to run code at the tail of processLoading. | |
Protected Attributes inherited from Cogs::Core::ResourceManager< Effect, EffectLoadInfo > | |
| Mutex | swapMutex |
| Collections::Pool< Effect > | resources |
| std::vector< IResourceLoader< Effect, EffectLoadInfo > * > | loaders |
| std::deque< SwapOperation > | swapQueue |
| ResourceHandle | defaultResource |
Protected Attributes inherited from Cogs::Core::ResourceManagerBase | |
| std::unique_ptr< ResourceManagerBaseStorage > | storage |
| Context * | context = nullptr |
| ResourceTypes | resourceType = ResourceTypes::Unknown |
Effect manager responsible for loading, processing and activating Effect resources.
Definition at line 31 of file EffectManager.h.
|
inline |
Constructs an EffectManager in the given context.
Definition at line 35 of file EffectManager.h.
| Cogs::Core::EffectManager::~EffectManager | ( | ) |
Destructs the EffectManager.
Definition at line 23 of file EffectManager.cpp.
|
overridevirtual |
Overridden to handle effect activation, updating the effect in the renderer.
Reimplemented from Cogs::Core::ResourceManager< Effect, EffectLoadInfo >.
Definition at line 101 of file EffectManager.cpp.
|
overridevirtual |
Overridden to handle deletion, removing the effect resource from the renderer.
Reimplemented from Cogs::Core::ResourceManager< Effect, EffectLoadInfo >.
Definition at line 138 of file EffectManager.cpp.
|
overridevirtual |
Overridden to handle effect loading.
Reimplemented from Cogs::Core::ResourceManager< Effect, EffectLoadInfo >.
Definition at line 37 of file EffectManager.cpp.
References Cogs::Core::EffectLoadInfo::definition, Cogs::Core::EffectLoadInfo::dependencies, Cogs::Core::ResourceLoadInfoBase::handle, and Cogs::Core::ResourceLoadInfoBase::preloading.
|
overridevirtual |
Reimplemented from Cogs::Core::ResourceManagerBase.
Definition at line 86 of file EffectManager.cpp.
|
overridevirtual |
Initialize the effect manager.
Implements Cogs::Core::IResourceManager.
Definition at line 28 of file EffectManager.cpp.
| Cogs::Core::EffectHandle Cogs::Core::EffectManager::loadEffect | ( | const EffectDefinition & | definition | ) |
Load the effect described by the given definition.
The effect may be loaded asynchronously, but the handle returned can be used right away.
| definition | An effect definition describing how to load the effect. |
Definition at line 106 of file EffectManager.cpp.
References Cogs::Core::EffectLoadInfo::definition, Cogs::Core::EffectDefinition::dependencies, Cogs::Core::EffectLoadInfo::dependencies, Cogs::Core::EffectDefinition::name, Cogs::OpenGLES30, Cogs::Core::ResourceLoadInfoBase::resourceName, and Cogs::WebGPU.
| std::string Cogs::Core::EffectManager::extension |
Extension used to lookup shader files.
Definition at line 66 of file EffectManager.h.
| std::string Cogs::Core::EffectManager::prefix |
Prefix used to look up shader files.
Definition at line 69 of file EffectManager.h.