Jump to content
  • Advertisement
Sign in to follow this  
ChugginWindex

OpenGL How does fast resource re-init work when device context is lost?

This topic is 2684 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

Just a question that has been bothering me for a while. When you lose your device context in OpenGL, DirectX etc. you have to reinitialize all of your resources created with that context. A frequent example of this effect is during full screen-windowed mode switching. So how is it that in these AAA titles like Crysis, Stalker etc. you get these massive resolution textures (and a huge variety of them), yet can switch between full screen and windowed display in around 5 seconds on decent hardware? Is this just a case of me not truly understanding the speed of current hardware and it can really all be reloaded THAT fast? Or is there some sort of secret caching method that lets you load things in faster or some other concept I'm missing? I know at least in DirectX you can load resources from the context as shared resources and then you don't need to reload them when the context is lost, but I thought there was some sort of performance hit with that.

Share this post


Link to post
Share on other sites
Advertisement
IIRC a lost device doesn't exist in GL, only in DX (GL will automatically mirror your resources in main RAM and handle the lost device for you).

The fastest way to deal with it is to mirror all your resources in main RAM (as well as having them in video RAM) - DX's managed pool does this for you. When a lost device happens, you/it just has to transfer all that data from main RAM back to video RAM. The bandwidth between the two is ranges somewhere from 250MB to 16GB per second, so 5 seconds should be plenty of time to re-copy all your data back to video RAM.

If you don't use the managed pool, and don't manually mirror your resources in main RAM, then you probably have to re-load them from disk, which of course is going to be horribly slow.

Share this post


Link to post
Share on other sites
Yes, which is one reason why console games get away with 512MB (total including both main RAM and video RAM) whereas an equivalent PC port will often require 512MB+ of main RAM AND 256MB+ of video RAM.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!