|
Nebula
|
#include <materialloader.h>
Inherits Resources::ResourceLoader.
Public Member Functions | |
| virtual void | Setup () override |
| setup resource loader, initiates the placeholder and error resources if valid, so don't forget to run! | |
| ResourceInitOutput | InitializeResource (const ResourceLoadJob &job, const Ptr< IO::Stream > &stream) override |
| update reserved resource, the info struct is loader dependent (overload to implement resource deallocation, remember to set resource state!) | |
| ResourceInitOutput | ReinitializeResource (const ResourceLoadJob &job, const Ptr< IO::Stream > &stream) override |
| rebuild a loaded material in place from its reloaded file, also when its template changed | |
| Public Member Functions inherited from Resources::ResourceLoader | |
| ResourceLoader () | |
| constructor | |
| virtual | ~ResourceLoader () |
| destructor | |
| virtual void | Discard () |
| discard resource loader | |
| virtual void | LoadFallbackResources () |
| load placeholder and error resources | |
| void | ClearPendingUnloads () |
| clear pending unloads | |
| Resources::ResourceId | CreateResource (const IO::URI &res, const void *loadInfo, SizeT loadInfoSize, const Util::StringAtom &tag, std::function< void(const Resources::ResourceId)> success, std::function< void(const Resources::ResourceId)> failed, bool immediate, bool stream) |
| Create a resource from URI, returns project placeholder resource unless immediate. | |
| Resources::ResourceId | CreateResource (const IO::URN &res, const void *loadInfo, SizeT loadInfoSize, const Util::StringAtom &tag, std::function< void(const Resources::ResourceId)> success, std::function< void(const Resources::ResourceId)> failed, bool immediate, bool stream) |
| Create a resoujrce using URN, the loader itself decides how to resolve the path. | |
| Resources::ResourceId | CreateResource (const IO::Path &res, const void *loadInfo, SizeT loadInfoSize, const Util::StringAtom &tag, std::function< void(const Resources::ResourceId)> success, std::function< void(const Resources::ResourceId)> failed, bool immediate, bool stream) |
| Create a resoujrce using URN, the loader itself decides how to resolve the path. | |
| void | DiscardResource (const Resources::ResourceId id) |
| discard container | |
| void | DiscardByTag (const Util::StringAtom &tag) |
| discard all resources associated with a tag | |
| void | CreateListener (const Resources::ResourceId res, std::function< void(const Resources::ResourceId)> success, std::function< void(const Resources::ResourceId)> failed) |
| Create new listener on resource. | |
| const Resources::ResourceName & | GetName (const Resources::ResourceId id) const |
| get resource name | |
| const uint32_t | GetUsage (const Resources::ResourceId id) const |
| get resource usage from resource id | |
| const Util::StringAtom | GetTag (const Resources::ResourceId id) const |
| get resource tag was first registered with | |
| const Resource::State | GetState (const Resources::ResourceId id) const |
| get resource state | |
| const Resources::ResourceId | GetId (const Resources::ResourceName &name) const |
| get resource id by name, use with care | |
| const Util::Dictionary< Resources::ResourceName, Ids::Id32 > & | GetResources () const |
| get the dictionary of all resource-id pairs | |
| const bool | HasResource (const Resources::ResourceId id) const |
| returns true if pool has resource | |
| const int32_t & | GetUniqueId () const |
| get the global identifier for this pool | |
| void | ReloadResource (const Resources::ResourceName &res, std::function< void(const Resources::ResourceId)> success, std::function< void(const Resources::ResourceId)> failed) |
| reload resource using resource name | |
| void | ReloadResource (const Resources::ResourceId &id, std::function< void(const Resources::ResourceId)> success, std::function< void(const Resources::ResourceId)> failed) |
| reload resource using resource id | |
| void | SetMinLod (const Resources::ResourceId &id, const float lod, bool immediate) |
| begin updating a resources lod | |
| Public Member Functions inherited from Core::RefCounted | |
| RefCounted () | |
| constructor | |
| int | GetRefCount () const |
| get the current refcount | |
| void | AddRef () |
| increment refcount by one | |
| void | Release () |
| decrement refcount and destroy object if refcount is zero | |
| bool | IsInstanceOf (const Rtti &rtti) const |
| return true if this object is instance of given class | |
| bool | IsInstanceOf (const Util::String &className) const |
| return true if this object is instance of given class by string | |
| bool | IsInstanceOf (const Util::FourCC &classFourCC) const |
| return true if this object is instance of given class by fourcc | |
| bool | IsA (const Rtti &rtti) const |
| return true if this object is instance of given class, or a derived class | |
| bool | IsA (const Util::String &rttiName) const |
| return true if this object is instance of given class, or a derived class, by string | |
| bool | IsA (const Util::FourCC &rttiFourCC) const |
| return true if this object is instance of given class, or a derived class, by fourcc | |
| const Util::String & | GetClassName () const |
| get the class name | |
| Util::FourCC | GetClassFourCC () const |
| get the class FourCC code | |
Static Public Member Functions | |
| static void * | AllocateConstantMemory (SizeT size) |
| Allocate constant memory explicitly. | |
| static void | FlushMaterialBuffers (const CoreGraphics::CmdBufferId id, const CoreGraphics::QueueType queue) |
| Update GPU buffers. | |
| static CoreGraphics::BufferId | GetMaterialBindingBuffer (const CoreGraphics::QueueType queue=CoreGraphics::GraphicsQueueType) |
| Get the material binding buffer the given queue keeps up to date, use the one of the queue that reads it. | |
| static CoreGraphics::BufferId | GetMaterialBuffer (const MaterialTemplatesGPULang::MaterialProperties type) |
| Get material buffer. | |
| static IndexT | RegisterTerrainMaterial (const MaterialInterfaces::TerrainMaterial &terrain) |
| Bit of a special way to register a terrain material. | |
| Static Public Member Functions inherited from Core::RefCounted | |
| static void | DumpRefCountingLeaks () |
| dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!) | |
Private Member Functions | |
| __DeclareClass (MaterialLoader) | |
| void | Unload (const Resources::ResourceId id) override |
| unload resource (overload to implement resource deallocation) | |
Friends | |
| class | Models::ModelContext |
Additional Inherited Members | |
| Protected Member Functions inherited from Resources::ResourceLoader | |
| virtual void | UpdateLoaderSyncState () |
| Update loader internal state. | |
| virtual ResourceStreamOutput | StreamResource (const ResourceLoadJob &job) |
| Stream resource. | |
| virtual uint | LodMask (const _StreamData &stream, float lod, bool async) const |
| Create load mask based on LOD. This will be used to determine if the resoure is fully loaded. | |
| virtual void | RequestLOD (const Ids::Id32 entry, float lod) const |
| Set lod factor for resource. | |
| void | AddReloadListener (const std::function< void(Resources::ResourceId)> &callback) |
| Register a reload listener callback. | |
| virtual void | Update (IndexT frameIndex) |
| update the resource loader, this is done every frame | |
| void | SetupIdFromEntry (const Ids::Id32 entry, ResourceId &cacheEntry) |
| Construct resource ID based on loader entry. | |
| void | RunCallbacks (Resource::State status, const Resources::ResourceId id) |
| run callbacks | |
| void | EnqueueJob (const std::function< void()> &func) |
| Issue async job. | |
| Resources::ResourceId | GetPlaceholder (const Resources::ResourceName &name) |
| get placeholder based on resource name | |
| Protected Member Functions inherited from Core::RefCounted | |
| virtual | ~RefCounted () |
| destructor (called when refcount reaches zero) | |
| Protected Attributes inherited from Resources::ResourceLoader | |
| Util::FixedArray< _PlaceholderResource > | placeholders |
| IO::Path | placeholderResourceName |
| these types need to be properly initiated in a subclass Setup function | |
| IO::Path | failResourceName |
| Resources::ResourceId | placeholderResourceId |
| Resources::ResourceId | failResourceId |
| Util::StringAtom | loaderExtension |
| bool | async |
| Ptr< ResourceLoaderThread > | streamerThread |
| std::function< void()> | preJobFunc |
| std::function< void()> | postJobFunc |
| Util::StringAtom | streamerThreadName |
| Util::Array< IndexT > | pendingLoads |
| Util::Array< _PendingResourceUnload > | pendingUnloads |
| Util::Array< _PendingStreamLod > | pendingStreamLods |
| Threading::SafeQueue< _PendingStreamLod > | pendingStreamQueue |
| Util::Array< std::function< void(Resources::ResourceId)> > | reloadListeners |
| Threading::SafeQueue< ResourceLoadOutput > | loadOutputs |
| Util::Array< ResourceLoadJob > | dependentJobs |
| Util::Dictionary< Resources::ResourceName, uint32_t > | ids |
| Ids::IdPool | resourceInstanceIndexPool |
| Util::FixedArray< Resources::ResourceName > | names |
| Util::FixedArray< uint32_t > | usage |
| Util::FixedArray< Util::StringAtom > | tags |
| Util::FixedArray< Resource::State > | states |
| Util::FixedArray< LoadState > | loadStates |
| Util::FixedArray< ResourceId > | resources |
| Util::FixedArray< Util::Array< _Callbacks > > | callbacks |
| Util::FixedArray< _PendingResourceLoad > | loads |
| Util::FixedArray< _LoadMetaData > | metaData |
| Util::FixedArray< _StreamData > | streamDatas |
| uint32_t | uniqueResourceId |
| int32_t | uniqueId |
| id in resource manager | |
| Threading::CriticalSection | asyncSection |
| async section to sync callbacks and pending list with thread | |
| Threading::ThreadId | creatorThread |
| Static Protected Attributes inherited from Resources::ResourceLoader | |
| static const uint32_t | ResourceIndexGrow = 512 |
| static int32_t | UniquePoolCounter = 0 |
|
private |
|
static |
Allocate constant memory explicitly.
|
static |
Update GPU buffers.
|
static |
Get the material binding buffer the given queue keeps up to date, use the one of the queue that reads it.
|
static |
Get material buffer.
|
overridevirtual |
update reserved resource, the info struct is loader dependent (overload to implement resource deallocation, remember to set resource state!)
Implements Resources::ResourceLoader.
|
static |
Bit of a special way to register a terrain material.
|
overridevirtual |
rebuild a loaded material in place from its reloaded file, also when its template changed
Rebuilds the material from the reloaded file under the same id, also for another template: the constant buffer, resource tables, textures and the slot in the material buffers.
Models cache the template of their materials to batch their draws, the reload listener in ModelContext::Create updates them.
A file that can't be loaded keeps the material as it was. Failing the reload would turn it into the error material, which can't be reloaded once the file is fixed
Reimplemented from Resources::ResourceLoader.
|
overridevirtual |
setup resource loader, initiates the placeholder and error resources if valid, so don't forget to run!
Reimplemented from Resources::ResourceLoader.
|
overrideprivatevirtual |
unload resource (overload to implement resource deallocation)
Implements Resources::ResourceLoader.
|
friend |