Jump to content
  • Advertisement
Sign in to follow this  
Darkneon

Managed vs System Memory

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

Hi I'm looking for a clear explanation between those two options when loading a mesh. If I use
Mesh.FromFile(file, MeshFlags.Managed, device, out mtrl);
I understand that the whole mesh will be stored in system memory and only when a part is about to be rendered it will be copied to the device accessible memory. Now, if I use
Mesh.FromFile(file, MeshFlags.SystemMemory, device, out mtrl);
What happens? From MSDN it says:
Quote:
Resources consume system RAM but do not reduce pageable RAM. System memory is not typically accessible by the 3-D device. These resources do not need to be re-created when a device is lost. They can be locked and also used as the source for a Device.UpdateSurface or Device.UpdateTexture operation to a memory resource created with Default.
What do they mean "not typically accessible"? Also, I thought that advantage of Managed Memory was that the resources do not need to be re-created when the device is lost? Thanks Guys

Share this post


Link to post
Share on other sites
Advertisement
Quote:
I understand that the whole mesh will be stored in system memory and only when a part is about to be rendered it will be copied to the device accessible memory.


Actually, I think two copies are kept - one in VRAM (or maybe the AGP aperture? Someone more knowledgable want to pitch in?) and one in system mem. That way, when the device is reset, it just has to copy from system mem back into VRAM.

Quote:
What do they mean "not typically accessible"?


Just that. You usually won't be able to draw things that are in the SystemMemory pool. I think it's more for sort of scratchpad resources.

Quote:
Also, I thought that advantage of Managed Memory was that the resources do not need to be re-created when the device is lost?


That's exactly the advantage.

Share this post


Link to post
Share on other sites
Quote:

You usually won't be able to draw things that are in the SystemMemory pool


The thing is, if I use SystemMemory when loading the mesh, I still can draw it. So , is DirectX doing some crazy things in the background to let the device access that memory. Also, what would normally happen if I allocate the resource in System Memory and the device cannot access it. Does the program crash or just ignores it?

Thanks

Darkneon

Share this post


Link to post
Share on other sites
I'm not real sure. I've never created anything with pools other than Managed or Default.

Is there a reason why you need to use SystemMemory?

Share this post


Link to post
Share on other sites
Quote:
Original post by Drakex
__________________________________________
Remember, the fastest polygons are those shot from a cannon.


... *mutter* ....

Well...

Anyway...

System Memory resources should eitherway not be _directly_ used when drawing either way, as they would need to be sent over the bus to the VRAM or the AGP memory.

Default Pool resources are just sent away to the graphics VRAM or AGP memory... and that is it... that is all to it... everything needs to be handled by you... even releasing from the memory if you want to free up memory in the VRAM/AGP memory... also restoring resource if anything fails is up to you.

Managed Pool resources is just a hybrid of the two previous... keeping one copy in system memory, and sending the other one to the "default pool"... when memory is needed on the device, managed resources are kicked out to leave space... when the device is lost, the system memory copy is once again sent to the graphics adapter.

So, what does it all mean?

System Memory is commonly a medium for having a local copy or used for updating textures (creating system, creating default, copying system to default)...

Default Pool is mainly for vertex buffers, can be used for textures, but rarely necessary and would likely just produce for problems as you could end up using more memory than available (Default pool doesn't keep a local copy so it doesn't eat any/as much system ram as managed though).

Managed Pool is meant for pretty much all non-super-extra-terrestrial-engine stuff that uses custom managers with the default pool... that is, you got a texture? go managed... managed is pretty much to go with everything that can be managed.

This is what I've come to understand.

Share this post


Link to post
Share on other sites
Quote:
Original post by Darkneon
The thing is, if I use SystemMemory when loading the mesh, I still can draw it. So, is DirectX doing some crazy things in the background to let the device access that memory.
I would guess so, yes - a DrawPrimitive call from a system memory VB probably works in a very similar way to DrawPrimitiveUP.

Share this post


Link to post
Share on other sites
I'm starting to get it but a few things are still blury.

So after more research, more reading and more re-reading, here's what I came to understand.

That second parameter in Mesh.FromFile is only to specify how buffer(s) should be stored. It says nothing about materials and texture (which is fine).

I was thinking what Syranide said and realized that if the mesh is to be render continuously then the best choice is Default.



*** Suspence ***


MeshFlags.Default does not exist. WTF?! When you create a VertexBuffer object, you can store it into Default. Am I missing something here?

Next, if you don't render a vertex buffer often but you manipulate it often, you store it into SystemMemory? Right? So what is Pool.Scratch used for then?



Darkneon

Share this post


Link to post
Share on other sites
Quote:
That second parameter in Mesh.FromFile is only to specify how buffer(s) should be stored. It says nothing about materials and texture (which is fine).


Right. Materials aren't really resources, and don't take up much space at all. Textures are not even loaded by the Mesh.FromFile method; it's up to you to do that.

Quote:
I was thinking what Syranide said and realized that if the mesh is to be render continuously then the best choice is Default.


Any reason why? You can also use Managed, which frees you from having to do a bunch of tedious memory management, and from having to reload everything from disk when the device is reset. Performancewise, I doubt it'd be much of a performance hit to use Managed geometry either - the runtime wouldn't exactly be itching to get the buffer out of VRAM if it's being rendered every frame.

Quote:
MeshFlags.Default does not exist. WTF?! When you create a VertexBuffer object, you can store it into Default. Am I missing something here?


I'm not sure about managed DX, but in unmanaged, if you don't specify a pool (pass in 0), it uses the Default pool.

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!