Do you prefer to create game resources in DirectX using managed or unmanaged memory? I realize that using the managed setting helps you during a lost device situation but there must be some drawbacks.
Managed memory vs. unmanaged memory
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
You must be talking about playing around with C#, right?Mr.Mike
Author, Programmer, Brewer, Patriot -
No what I mean is you can create a mesh and have D3D manage it or manage it yourself. If D3D manages it you don't have to restore it when you lose the device. If you manage it you have to restore it every time the device is lost. Which method do you prefer?
-
I think he means along the lines of specifying D3DPOOL_DEFAULT/D3DPOOL_MANAGED/D3DPOOL_SCRATCH when creating DX resources like vertex buffers, index buffers, textures, etc.pan narrans
-
Oh THAT!!!!
Having DirectX manage its own memory is generally a good thing, only to be ditched if you have a specific reason to do so, such as you've got some crazy memory manager of your own that you want to use.Mr.Mike
Author, Programmer, Brewer, Patriot -
From my own personal experience I've found that using managed memory D3DPOOL_MANAGED works well for all your static geometry - e.g. buildings, rocks, cars, whatever... You never again have to worry about restoring the geometry in the vertex/index buffers after the device has been lost.
For dynamic geometry - such as a particle system - you won't be able to get D3D to manage that for you using D3DPOOL_MANAGED. It just won't work. You'll have to do it all yourself using D3DPOOL_DEFAULT. But when you think about it it kind of makes sense since for dynamic geometry you will typically alter the geometry many times per frame anyway which basically means you're replacing the vertex/index buffer's geometry per frame. -
One thing to keep in mind - the managed memory essentially keeps two copies of things, one in the device memory and a device independant copy in main memory.
When the device is restored, the main memory gets copied back into device memory.
Yes, it is fast, and yes, it takes lots of memory.
Your only fallback is to manage it yourself, and reload the lost data from disk or something, which would be a lot slower.Mr.Mike
Author, Programmer, Brewer, Patriot
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0