Sign in to follow this  
user88

[SlimDX] Resource Managment, Render to texture

Recommended Posts

user88    304
Hello! Here is my rendering script: 1. Save current render target surface and set render to floating point texture surface 2. Render scene 3. Perform post-processes 4. Copy result back form floating point RT to saved RT surface surface (StreachRectangle) (Optional) 5. Copy data from saved render target surface to Bitmap and save to file In a point 1. i change render target to floating point texture surface:
            // Change render targets
            m_destRt = device.GetRenderTarget(0);
            device.SetRenderTarget(0, m_colorRtSurface);

In case i render scene to screen m_destRt is back buffer of SwapChain and in case i render to Bitmap and save to file m_destRt is surface of render target texture. Then in a point 3. i copy data back:
                device.StretchRectangle(m_colorRtSurface, m_destRt, TextureFilter.None);
                device.SetRenderTarget(0, m_destRt);
                m_destRt = null;

All works good, but a got error when try to reset the device. Error says me that i did not release all Pool.Default resources. I modified point 3. a litte and my code look like next:
                device.StretchRectangle(m_colorRtSurface, m_destRt, TextureFilter.None);
                device.SetRenderTarget(0, m_destRt);
                m_destRt.Dispose();
                m_destRt = null;

Now device resets successful but i get error in a point 5. because i disposed RT texture surface. Seems there should be some fundamental knowledges of DirectX 9 Resource Managing which i don't know yet. Thanks in advice..

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