Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

serratemplar

graphics memory management

This topic is 5219 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''m asking this question with a large DirectDraw7 app in mind, but I have a feeling it''s applicable thru Direct3D too. If you know the answer to that, please share that as well. =) I may have already answered this question for myself, but I still wanted other perspectives. Here''s my question: When you tab out of a full-screen app, all DirectDrawSurfaces that you''d stored in video RAM are lost...you have to both Restore() them and then reload them...that is, either reload the relevant bitmap information from disk, or blit it back into the surface on video RAM from a back-up of it stored in system memory. Blitting from Video RAM is much faster than blitting from system mem, so you want to work with video RAM as often as you can. For small games, like a Tetris clone, where graphics take up very little space, I''d think you could just store back-ups of the surfaces in system mem, so that when the user tabs out and the surfaces in video RAM are lost, they can be restored quickly, without having to access the disk. But what about in a larger game where there are lots of graphics? It''s got to be better to load all the bitmaps/textures/what-have-you into system mem, then have them in video RAM when they''re on deck to be used...that way you can quickly and easily recover from a restore. But it almost seems like a waste of memory, because you''ve got two copies of the same thing in two different places. Granted, most people have a TON of RAM (lots more than video RAM, like System Mem might be 2 Gigs while Vid is around 128MB) so maybe it is just best to have the bitmaps in system mem, then only put them on the vid card when they''re in the player''s view vicinity. Any thoughts or nifty tricks would benefit my purposes, I''m sure. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
You will never have more than 256MB of textures loaded at once if you want them all in video memory; duplicating this into system memory shouldn''t be an issue on modern hardware.

If you have low amounts of system ram, you''ll likely have low amounts of video ram as well.

Share this post


Link to post
Share on other sites
1) You need to remember that Windows is a virtual memory based OS (i.e. "system memory" != "physical RAM"). If the memory pages of the system memory copies of your video memory textures haven''t been touched for a while, then it''s likely that those copies have actually been swapped out to disk to the page file!

When your surfaces are lost and you restore from the "system memory" copies, if you''ve got a reasonable amount of data and a lowish amount of physical RAM, you''ll notice the hard disk thrashing as those are paged back in. So effectively the OS is often re-loading the copies from disk for you anyway (albeit using a very fast file handling mechanism involving memory mapped files).


2) Once you get into Direct3D territory, you can have "managed" resources where the whole idea of the system memory copy and the automatic uploading/management of what''s in video memory is handled automatically.


3) If all of your surfaces fit into video memory, then you know the system memory copies are only used at level start up time and when a device is lost so you could store those copies in a compressed form (e.g. zipped with something like ZLIB) and decompress straight into video memory.


4) You really don''t need any complex schemes for handling this sort of stuff unless you either have too many textures to fit into video memory or want to do something like background/seamless loading of levels.


Simon O''Connor
Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites
Also, remember that Alt-Tabbing takes a bit of a pause to do. Unless it takes more than a few seconds, I don''t think the user will notice the load time.

Share this post


Link to post
Share on other sites
The virtual memory thing totally didn''t occur to me, but I can see how that''d be an ironic clash of interest. =) Is there a way to ensure that bitmaps or textures stay in actual physical memory and don''t get swapped to a page file?

Share this post


Link to post
Share on other sites

  • 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!