Jump to content
  • Advertisement
Sign in to follow this  
TobyWilson

[SlimDX] device.Reset() fail

This topic is 2694 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 working on some printing functionality of a simple cad viewer I've created using SlimDX.

Briefly, my printing strategy is:
-Get bounds of printable area from GDI+ context.
-Resize the Direct3D9 back buffer to fit this.
-Render the scene.
-Convert the render target to a memory resident bitmap of the same size.
-Chuck that bitmap at the printer.

To achieve this I need to be able to resize the back buffer of my Direct3D9 Device context, however my call to device.reset() fails with "All user created D3DPOOL_DEFAULT surfaces must be freed before ResetEx can succeed. ResetEx Fails."

In the simplest case I just have a few vertex buffers allocated; should these be freed and reallocated?
If so, is there any other way to resize the back buffer without calling device.reset?

[edit] And those vertex buffers are created with Pool.Managed.

Share this post


Link to post
Share on other sites
Advertisement
Sounds like you still have a surface in the default pool. First I'd have a look at SlimDX.ObjectTable (enable SlimDX.Configuration.EnableObjectTracking) right before the reset to find what's still lying around. Or run your app through PIX.

Just guessing: "Forgotten" surfaces usually come from some GetXYZ from the device (e.g. GetBackBuffer). Dispose them after usage.

By the way: If you use a render target instead of the backbuffer for rendering, you won't need a device reset. Just don't forget to also create a depth/stencil surface of the same dimensions in case you need one.

Share this post


Link to post
Share on other sites
That's fixed my problem thanks.

Just a note that's worth a mention incase this fixes someone elses problem; the render states don't survive device.reset; so my setup of having a single solid white material being ambient recoloured for each entity looked a bit crazy before I figured out what the problem was!

Share this post


Link to post
Share on other sites
You're welcome. Congrats on solving the other issue. Though I somewhere read that states should be preserved, I experienced it differently (and saw a couple of threads here confirming this problem). That's why I encourage always setting all relevant render states and never rely on defaults. They get screwed too easily.

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!