*assetcache (identifier -> assetID map, assetID -> asset map)
GeneralAssetManager (identifier(filepath) -> fromcache/fromhdd -> assetID with refcounter to raw uninterpreted data)
ShaderAssetManager (identifier(assetID to raw data) -> fromcache/fromGeneralAssetManager -> shader object ID with refcounter)
ImageAssetManager (identifier(assetID to raw data) -> fromcache/fromGeneralAssetManager -> decompressed image data ID with refcounter)
I need some classes to allow me to implement asset managers.
I expect them to be reusable template classes.
I dont want a do-it-all manager that handles everything from textures to xmls.
Managers i think ill need:
-General asset manager
*gateway between external sources (hdd, network?) and RAM
*loads the raw resource data into RAM
-GPU asset managers
*gateway between RAM and video memory
*one for shaders, another for textures...
*interprets raw data, uploads to GPU, creates the object to be used in code
For example, if i have a picture on hdd, ill tell the general asset manager to load it using a raw resource identifier (the filepath). It then checks its cache and if its not there it loads it. It will return an integer identifier (like a hash) unique to each loaded resource that i can use to refer to the loaded asset. The integer is random but shouldnt overlap with other assets.
Now i have my identifier.
Then i will ask lets say the texture cache to give me the GPU-side texture. I give it the raw asset identifier, it checks its identifier-textureobject cache, interprets and uploads raw data if necessary, and then hands me the texture object.
Ideally, i would preload the assets in memory and store the identifiers somewhere (if i have hardcoded assets ill need) and then interpret and upload those when necessary. I would only access resources through the filepath and general asset manager if i get the filepath dynamically. If i already know the filepath ill preload it at some point and set the resulting identifier in a hardcoded variable.
For textures, i might want to decompress the image but not yet upload to GPU, so i could use a cpu side texture manager that simply interprets (decompresses) the raw asset.
And then some tools for handling the lifetime of objects. The resource identifiers (which you get from the managers) should probably have a reference counter (ref. count managed along with the loaded resource). The refcount would only prevent deletion of assets in use, deleting assets that are not referenced would probably be manual.
Anything to improve on? Does this already seem fairly solid? As mentioned ill need reference counts to the asset identifiers i use to access already loaded assets, how should i implement that (the refcount will reside with the loaded asset)?