Sign in to follow this  
Kris_A

Destroy/Create instead of Reset

Recommended Posts

Hi, I'm using Direct3D 9 and I'm just setting myself up a system to restore a lost device. With the way that my system is built, it'd save time, effort and code if I just destroyed the device then recreated it, rather than calling Reset(). Is this ok to do, or does it have any disadvantages? Also, let's say that I have a D3DPOOL_DEFAULT image that I edit the pixels of by hand (with GetRenderTargetData/LockRect). Is there any way to stop the new image being lost when the device is lost? I thought about using D3DPOOL_MANAGED but it seems like there's a lot of stuff I can't do with it. Preferably I need some way to catch the device loss preliminarily, so I can transfer all of the images to system memory, then restore them when the device is restored. Cheers, Kris

Share this post


Link to post
Share on other sites
Quote:
Original post by Aiursrage2kIt boggles my mind, because I never even thought of doing it any other way.


don't be completely boggled. recreating the device actually does have some advantages. there are so many driver and system bugs with lost and resetting devices. for example check out the directx readme and you will see there is a bug with windows 2000 where after a lost device you can lock a buffer in agp and get back a bad pointer. this will crash your app if you don't try/except around it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kris_AIs there any way to stop the new image being lost when the device is lost? I thought about using D3DPOOL_MANAGED but it seems like there's a lot of stuff I can't do with it.
Preferably I need some way to catch the device loss preliminarily, so I can transfer all of the images to system memory, then restore them when the device is restored.


unfortunately no. once you find out the device is lost, all your resources are already gone. the only thing you can do is to keep a system memory copy of your texture. this winds up being just what the managed textures are though so you should take a second look at them.

Share this post


Link to post
Share on other sites
Aha, thanks. I'll have another look at them, then.
So I take it, if I use managed textures then I won't be able to do use the destroy/create method?

Another thing : Can managed textures be drawn on?

Share this post


Link to post
Share on other sites
well you could still destroy and recreate all the managed textures when you destroy and recreate the device, but resetting is really much more efficient. yeah you can update managed textures. just call LockRect. it's more expensive having to update the system mem copy and then having the vid mem copy updated also, but that's what you need in this case (and in most cases). for just about everything managed textures are the way to go.

Share this post


Link to post
Share on other sites
Important notice though, that render targets can only be in the default pool.

If you plane on rendering to managed textures, you're either going to have to use LockRect() or find a different solution (default pool).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this