Jump to content
  • Advertisement
Sign in to follow this  
gharen2

[mdx] dynamic texture and pool.default woes

This topic is 4210 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 generating a procedural texture by writing raw pixel data to a texture with LockRectangle and UnlockRectangle. In order to do this, you need a texture created with the usage flag Dynamic, which also requires that you create it with Pool.Default. I realise that I need to dispose Pool.Default resources prior to resetting the device. And that's exactly what I do: I dispose the texture, reset the device, and recreate the texture. But there's a peculiarity that's making me pull my hair out: So long as I create the texture but don't actually use the texture, it works fine. The texture disposes, the device resets, the texture is recreated, and everyone is happy. But after I use the texture to render a sprite (with the Sprite class), the texture won't dispose any more. Instead, when I try to reset the device I get the dreaded "All user created D3DPOOL_DEFAULT surfaces must be freed before Reset can succeed. Reset Fails." error. I've tried disposing the spite class both before and after the texture. I've also set Device.IsUsingEventHandlers to false. Whatever I do, that infernal texture just won't go away, preventing me from resetting the device. Hopefully this is enough info. The code is part of a complex engine so it'd take a bit of work for me to provide a concise code sample. I will if necessary though. edit- interestingly, when I set Device.IsUsingEventHandlers to true, the application hangs while disposing the the texture, with not debug info provided by directx. [Edited by - gharen2 on April 10, 2007 2:26:07 AM]

Share this post


Link to post
Share on other sites
Advertisement
Try calling OLostDevice on the Sprite interface before resetting and calling OnResetDevice after resetting. Chances are the Sprite interface isn't releasing its reference to the texture.

Share this post


Link to post
Share on other sites
Unfortunately, that didn't work.

I think I must be overlooking a particularly obnoxious bug, because I tried to recreate the error with a simple test case, but the test case works perfectly.

I'll investigate some more.

Share this post


Link to post
Share on other sites
Just a random guess, but maybe you're fetching a surface from the texture somewhere (for drawing dimensions/locking) which you forgot to dispose? Also, are you sure that the texture/surfacelevel is unlocked before you use it anywhere else? Probably a bit obvious too, but accidentally drawing a texture that is still locked is a sure way to get into trouble.

Hope this is of some help. The D3D debug runtimes also might be able to provide you with some information on which resource hasn't been disposed, but I've found getting the exact MDX resource from that info is an art beyond my skills :)

Share this post


Link to post
Share on other sites
Quote:
Original post by remigius
Just a random guess, but maybe you're fetching a surface from the texture somewhere (for drawing dimensions/locking) which you forgot to dispose?


Bingo :)

I was retrieving surface 0 to get the texture's dimensions, and wasn't disposing it. In hind sight, a silly mistake considering I already knew you had to dispose of the surface you get from SwapChain.GetBackBuffer.

Funny how the simplest bugs are the most annoying :P

Thanks for your help guys. Now to clean up all the ugly hacks I put in while trying to fix the bug.

[Edited by - gharen2 on April 10, 2007 12:16:11 PM]

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!