class

Asset

Base class for all assets in the Asset Pipeline. Inherits RefCounted for automatic lifetime management via Ref<T>. Two-phase loading: Load() for CPU data (any thread), CreateGPU() for GPU resources (main thread).

Module
AssetSystem
Header
#include "AssetSystem/Asset.h"
Namespace
Mowo

Constructors

SignatureNameDescription
Asset()Asset
explicit Asset(UUID id)Asset
virtual ~Asset()~Asset

Public functions

ReturnsNameDescription
AssetTypeGetAssetTypeType identification
boolLoadLoad CPU-side data.
std::stringPrimaryLoadFileThe one file whose bytes Load(path) reads first and whole, for a loader that reads them through the IO queue and hands them to LoadFromMemory.
boolLoadFromMemoryLoad(path) with file's bytes already read.
voidUnloadRelease CPU-side data.
boolCreateGPUCreate GPU resources on the main thread.
boolCreateGPUBudgetedTime-sliced GPU creation for the async-import drain.
uint64_tEstimatedMemoryUsageEstimated CPU+GPU footprint for the eviction policy.
uint64_tEstimatedUploadBytesBytes the remaining GPU creation will still upload, read BEFORE CreateGPU so the per-frame drain can meter in bytes.
voidDestroyGPUDestroy GPU resources.
boolDestroyGPUIsFrameSafeTrue when DestroyGPU only drops RHI objects whose backends already hold their release until the frames in flight have retired (images do, on every backend).
boolCanAdoptLoadedStateOff-thread reimport.
voidAdoptLoadedState
boolSaveMetadataSave import settings to a .mdfmeta MDF file
boolLoadMetadataLoad import settings from a .mdfmeta MDF file
voidWriteImportSettingsOverride in derived classes to write type-specific import settings
voidReadImportSettingsOverride in derived classes to read type-specific import settings
voidCollectDependencyIDsOverride to report the UUIDs of assets this asset references (e.g.
voidCollectDependencyPaths
UUIDGetID
voidSetID
const std::string&GetSourcePath
voidSetSourcePath
uint64_tGetSourceHashSource content hash (FNV-1a 64) + mtime, persisted in the .mdfmeta so a project re-open restores them without re-reading every source file — change detection works immediately and there's no reimport storm.
voidSetSourceHash
int64_tGetSourceMtime
voidSetSourceMtime
AssetFlagGetFlags
voidSetFlag
voidClearFlag
boolHasFlag
boolIsLoaded
boolIsGPUReady
boolIsValid

Function details

Asset

C++
Asset()

Asset

C++
explicit Asset(UUID id)

~Asset

C++
virtual ~Asset()

GetAssetType

C++
virtual AssetType GetAssetType() const = 0

Type identification

Load

C++
virtual bool Load(const std::string& path) = 0

Load CPU-side data. Can be called from any thread. Returns true on success.

PrimaryLoadFile

C++
virtual std::string PrimaryLoadFile(const std::string& path) const

The one file whose bytes Load(path) reads first and whole, for a loader that reads them through the IO queue and hands them to LoadFromMemory. Empty (the default): Load does its own IO, and the loader only gives it a slot on the completion pool.

LoadFromMemory

C++
virtual bool LoadFromMemory(const std::string& path, const std::string& file, std::vector<uint8_t>&& bytes)

Load(path) with file's bytes already read. Any thread, like Load.

Unload

C++
virtual void Unload() = 0

Release CPU-side data.

CreateGPU

C++
virtual bool CreateGPU(const GPUContext& ctx)

Create GPU resources on the main thread. Returns true on success.

CreateGPUBudgeted

C++
virtual bool CreateGPUBudgeted(const GPUContext& ctx, int budget)

Time-sliced GPU creation for the async-import drain. MAIN THREAD ONLY. Does up to budget GPU work units (<= 0 = unbounded / one-shot). Returns true once the asset reached a TERMINAL state — GPUReady on success or Invalid on failure — and false while more budgeted work remains for a following frame. The default is one-shot (a single CreateGPU); large assets (meshes) override it to yield across frames.

EstimatedMemoryUsage

C++
virtual uint64_t EstimatedMemoryUsage() const

Estimated CPU+GPU footprint for the eviction policy. 0 = negligible / unknown (never triggers eviction by itself).

EstimatedUploadBytes

C++
virtual uint64_t EstimatedUploadBytes() const

Bytes the remaining GPU creation will still upload, read BEFORE CreateGPU so the per-frame drain can meter in bytes. The default is the footprint estimate, which a texture knows from its CPU data alone; a type whose estimate needs its GPU objects (a mesh) overrides it.

DestroyGPU

C++
virtual void DestroyGPU()

Destroy GPU resources. Must be called on main thread.

DestroyGPUIsFrameSafe

C++
virtual bool DestroyGPUIsFrameSafe() const

True when DestroyGPU only drops RHI objects whose backends already hold their release until the frames in flight have retired (images do, on every backend). A reimport of such an asset needs the render thread fenced, not the whole device drained — the drain was a multi-second freeze in a Debug editor each time an artist saved a texture.

CanAdoptLoadedState

C++
virtual bool CanAdoptLoadedState() const

Off-thread reimport. The object a scene holds has to survive a reimport, so the loader cannot simply hand back a new one: it parses into a fresh object of the same type and the main thread moves that CPU state into the live one, after Unload and before CreateGPU. A type that cannot say which of its members Load fills keeps the synchronous reimport.

AdoptLoadedState

C++
virtual void AdoptLoadedState(Asset& loaded)

SaveMetadata

C++
bool SaveMetadata(const std::string& mdfmetaPath) const

Save import settings to a .mdfmeta MDF file

LoadMetadata

C++
bool LoadMetadata(const std::string& mdfmetaPath)

Load import settings from a .mdfmeta MDF file

WriteImportSettings

C++
virtual void WriteImportSettings(MdfNode& importNode) const

Override in derived classes to write type-specific import settings

ReadImportSettings

C++
virtual void ReadImportSettings(const MdfNode& importNode)

Override in derived classes to read type-specific import settings

CollectDependencyIDs

C++
virtual void CollectDependencyIDs(std::vector<UUID>& out) const

Override to report the UUIDs of assets this asset references (e.g. a material → its textures + parent). The registry stores these so it can answer "what does X need" and the reverse "who needs X" for delete-safety and a reference viewer. Default: no dependencies.

CollectDependencyPaths

C++
virtual void CollectDependencyPaths(std::vector<std::string>& out) const

GetID

C++
UUID GetID() const

SetID

C++
void SetID(UUID id)

GetSourcePath

C++
const std::string& GetSourcePath() const

SetSourcePath

C++
void SetSourcePath(const std::string& path)

GetSourceHash

C++
uint64_t GetSourceHash() const

Source content hash (FNV-1a 64) + mtime, persisted in the .mdfmeta so a project re-open restores them without re-reading every source file — change detection works immediately and there's no reimport storm.

SetSourceHash

C++
void SetSourceHash(uint64_t h)

GetSourceMtime

C++
int64_t GetSourceMtime() const

SetSourceMtime

C++
void SetSourceMtime(int64_t m)

GetFlags

C++
AssetFlag GetFlags() const

SetFlag

C++
void SetFlag(AssetFlag flag)

ClearFlag

C++
void ClearFlag(AssetFlag flag)

HasFlag

C++
bool HasFlag(AssetFlag flag) const

IsLoaded

C++
bool IsLoaded() const

IsGPUReady

C++
bool IsGPUReady() const

IsValid

C++
bool IsValid() const
Generated from AssetSystem/Asset.h via assetsystem.json · Nov 4, 2026Version 1.0.0