Archived

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

sagmam

managing resources

Recommended Posts

Hi, I''m trying to figure out some things about managing vertex buffer efficiently. Could someone explain the relationships between the "managed pool", "dynamic vertex buffer" and the locking flags of DISCARD and NOOVERWRITE? My problem is actually this: I have some objects that are static (like a terrain) and dynamic (like animated creatures). I know that terrain is best placed directly in video memory, since I never try to Lock() it for changes (at least in my implementation). I also know that the animated creatures are changing every frame, so it''s best put somewhere else. What flags should I use for CreateVertexBuffer and Lock calls, if I want to create both kinds of buffers, and what is the logic behind such decisions?

Share this post


Link to post
Share on other sites
I''m not an expert at the inner workings, but from what I gather:

"Managed pool" is handled by DirectX. It will store the object in system memory, and then send it over to the graphics card to place into its video memory. DirectX will internally keep a timestamp of when it was last used. If its been along time, DirectX managed pool will flush out the video memory when it hasn''t been used for awhile to make room for newer objects. Managed allows you alt-tab without recreating the device since the directx runtime will place it back into video memory from its system memory when your app gains focus.

"Dynamic" is only placed on video card ram, but its placed in a "non static" area. Meaning the buffer is going to change contents alot. It could be a cached area of the video cards memory. This memory is usually not allowed to grow or shrink. You just have X spots for mesh polygon and when it fills up. You draw them at 0 filling them up to X, then draw them and start filling again at 0. The DirectX CFont Class will do this type of thing internally (which you can see in the source code, it will create a dynamic buffer and fill up to 100 polygons (50 characters) and draw when it fills, and restarts it until all the string data is drawn)

Sounds like you have it down right, you would want to make your character buffer a dynamic one, and probably your other buffer as "default" pool. You are going to have to handle the alt-tab since dynamic buffers can''t be managed buffers (where directx is going to handle that for you) so you are going to have to code in the alt-tab stuff anyways... So just drop managed all together and write your own...

The flags would be D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY (I dont see nooverwrite and discard in DirectX9, they might have removed them)

Share this post


Link to post
Share on other sites