Sign in to follow this  

CreateRenderTarget fails ocasionally - should I reset?

This topic is 3718 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 have an application where CreateRenderTarget fails occasionally (the arguments used are exactly the same). Should I reset the device when this happens? Will the meshes have to be recreated if I reset the device?

Share this post


Link to post
Share on other sites
Why does it fail? What error code does CreateRenderTarget return? Since it will be place in the default memory it may be a memory issue. And if your meshes are created there as well you need to create those again after reset.

I'm no expert but a reset seems pretty harsh. Maybe something else could be changed(release something you do not use perhaps) to make CreateRenderTarget succeed every time.

Share this post


Link to post
Share on other sites
Quote:
Original post by Constantin
I have an application where CreateRenderTarget fails occasionally (the arguments used are exactly the same). Should
I reset the device when this happens? Will the meshes have to be recreated if
I reset the device?

How often is occasionally? Once a second? Once an hour?

Are you calling CreateRenderTarget every frame? Any chance you're out of video memory? Any debug output (if you're using the debug runtimes)?

Share this post


Link to post
Share on other sites
I keep creating and recreating render targets because I need them
at different dimensions each time. Other than release, what else do I need
to call to cleanup previously created render targets? And how do I release
those that I have set into the device using SetRenderTarget?

Share this post


Link to post
Share on other sites
You have to Release() every surface you requested. You have to read the default rendertarget and set rendering back to this target when you're done with the current rendertarget. If you Release() the rendertarget and it returns any number other then zero, you have missed to Release() some of its resources, and the rendertarget will remain in memory. So check the return code of the Release()-call.

Resource management is a buffered process like any other process in DirectX. If you release a rendertarget, the video memory it occupies is not freed instantly but upto several frames later when the GPU is done with it. So if you have a constant stream of large allocations and releases, the actual amount of video ram occupied is much larger than what the numbers add up to. On GPUs with only a few MBs of video memory you might indeed hit the OutOfVideoMemory border.

Create a manager class that handles a set of preallocated rendertargets and make some effort to resuse them. For example if you need a smaller rendertarget, use a portion of a larger rendertarget using SetViewport().

Bye, Thomas

Share this post


Link to post
Share on other sites
If you have normal managed textures around as well as render targets then you could try calling IDirect3DDevice9::EvictManagedResources() when CreateRenderTarget() fails with the out of memory message, and then retry it. If it still fails after that then you're definitely out of video ram (i.e. the default pool is full).

The debug runtimes can be helpful for tracking down texture memory leaks. See the FAQ for more details.

Share this post


Link to post
Share on other sites

This topic is 3718 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.

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