Jump to content
  • Advertisement
Sign in to follow this  
BMKane

Weak references in DX10

This topic is 3093 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 was looking at the documentation for ID3D10Device::IASetVertexBuffers, and it says "The method will not hold a reference to the interfaces passed in. For that reason, applications should be careful not to release an interface currently in use by the device." Apparently, NONE of the Set functions hold references to interfaces passed in. I'm assuming that when you make a Draw() call, THAT'S when the device acquires a reference, and it holds that reference until it finishes with the buffer, but the docs don't say that. Does anyone know for sure if this is the case? The problem is, if that's not how it works, there's really no way to know when it's safe to release a vertex buffer. Draw() calls don't happen immediately, they go into a command queue and DirectX gets to them in its own time. So, there's no way to tell when DirectX is finished with your vertex buffer. Except, I suppose, waiting until every backbuffer in your swap chain is presented, guaranteeing that DirectX must have finished that original frame. Personally, I've never run into any problems with this myself, and I know I've released vertex buffers immediately after draw calls before, so presumably Draw() is indeed calling AddRef() on my buffers, but I'd like to know for sure. Anyone have any more information on this? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I don't think draw calls AddRef. The thing about calling Release on resources is that the actual GPU resource doesn't actually get deleted right away. The driver will have its own internal reference counts, and it will clean things up once it's actually done with it. This is the same reason why you can't depend on your GPU memory being freed up immediately after releasing your D3D objects.

Share this post


Link to post
Share on other sites
D3D keeps internal reference counts and external (user) reference counts. It's just stating that if the user ref count goes to zero that the resource is essentially slated for destruction -- to prevent that it's important to maintain user ref counts.

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!