Jump to content
  • Advertisement
Sign in to follow this  
Raeldor

Resource Cache Design

This topic is 4523 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been reading 'Game Coding Complete', and the design of the resource cache seems to load the entire resource into a block of memory. This is fine, but then when using the resource you are also creating another object (texture or game node for example) using the same data from the memory stream. Isn't this duplicating the data meaning you have two sets of mostly the same information? It doesn't seem very efficient. Ok, I understand that for textures it can sit in video memory, but that may not be true for other resources. Is there a reason why the resource manager shouldn't directly create the texture/mesh object etc? Also, assuming you have a lot of game objects (for example nodes in a scene graph), do these objects also need their own cache and temporary file area? Especially if you are dealing with an open-environment game like an MMORPG. Thanks for any clarification!

Share this post


Link to post
Share on other sites
Advertisement
Well, I'm not sure about the specifics behind the book (not having read it myself) but typically, cache systems work so great because instead of the slow-read and seek from pulling the objects off of a hard disk, you already have it in ram. So is the tradeoff; RAM space and quick load vs a hard-disk and a slower load.

Yes, you do end up having copies of the same thing in memory (one with a better detailed representation than the other), but intellegent caches will destroy the previous copy once loaded in this way, and then cache the new copy with any added information.

Now, you might think that it's dumb to cache; a lot of people think so (sadly). But, caching is an effecient way of having what you need, when you need it. As for an MMO or something that's got a huge amount of objects, you need to be sure to manage the size of the cache. Keeping objects that haven't been accessed in a certain amount of time should be destroyed, objects that don't get used a lot shouldn't even be cached in the first place to save room in the cache for more commonly used things.

Resource management is almost the art of writing a good game IMO. You might have a very good looking game, but if it takes forever to load you end up just pissing off users.

If you've got any specific questions, I'll try to help.

Share this post


Link to post
Share on other sites
Quote:
Original post by ciroknight
You might have a very good looking game, but if it takes forever to load you end up just pissing off users.


If the average person cared that much about load times, the PlayStation never would've taken off.

Over aggressive caching can certainly hurt. You don't want to force the user's computer to start swapping. Frequently reloading objects from disk will usually be faster than swapping - (remember, swapping works 4k at a time, whereas you would load the objects off disk in one shot most likely).

As you mentioned, caching would probably be important for an MMO. But for a level based game it's probably not a big deal.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!