Sign in to follow this  
Nairou

Resource caching

Recommended Posts

When the resource manager loads a file from disk (and, possibly, decompresses it), you end up with a memory buffer containing the raw file contents. But that isn't directly useful, so you usually have a resource-specific component to the resource manager that interprets the data into a usable form (i.e. loading a texture file into the graphics API and receiving a handle in return, or parsing a mesh file into an actual mesh data structure). My question is regarding resource caching: which form should be cached? The raw data file, or the data it was interpreted into? In the instance where a mesh file is converted into an actual data structure, I can understand just keeping the data structure, as it is identical to the original, just in a more usable form. But for cases like textures where you don't do much beyond load them into the graphics API, do you at that point assume the API is storing it, and release the buffer to save memory, or do you continue to hang onto it as a backup? If you release the texture file from memory, can you really say the resource manager is "caching" that texture?

Share this post


Link to post
Share on other sites
Quote:
Original post by Nairou
My question is regarding resource caching: which form should be cached?


Depends on what form offers the most benefits. Often times the memory consumption is different for them both, and the amount of computation to convert data from a "raw" format to a usable structure can vary greatly. By just caching the "raw" contents, you are essentially just doing disk caching, which is fine if it doesn't take much time to convert your data to a usable structure and if it uses less memory when in a raw format.

Share this post


Link to post
Share on other sites
the device you are reading from also has great impact.

For instance, reading multiple streams from a dvd can be a problem, especially if you have to switch layers a lot. for xbox, for instance, layer switch is 35ms, full seek is 175ms.

Regarding your actual question
- First have a memory budget.
- textures: always use DXT compression. the gpu can do decompression for you anyway. Keep backup even though gpu has it (and as long as your memory budget allows you to)
- audio: 3d sounds should always be stored as mono.
- video: dont store as raw for obvious reasons :D

For singleplayer games most of this can propably ble preloaded and kept for the entire level (not video..). For multiplayer games, the resource manager will have to be smarter and throw away resources that arent used often.

For some reading on the subject I can reccomend "The One Disc Game: Compression, Streaming, and Caching Effectively" presentation from gamefest. It has a lot of good points that are not only restricted to xbox.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this