Sign in to follow this  
Loncs

directx 9 swapchain - out of video memory

Recommended Posts

Hi! I have a question regarding swapchains. In my app I have a window and I use a swapchain to display stuff. Every time the window is resized, I releaes and recreate the swap chain, so the Backbuffer width and height matches the new window size. the create/reset function looks like this : bool CALDirectX9Presentation::ResetSwapChain(int BackBufferWidth,int BackBufferHeight) { D3DPRESENT_PARAMETERS pp = m_PresentParameter; HRESULT hr; LPDIRECT3DSURFACE9 BackBuffer=NULL; if (m_pSwapChain) m_pSwapChain->GetBackBuffer (0,D3DBACKBUFFER_TYPE_MONO,&BackBuffer); SAFE_RELEASE(BackBuffer); SAFE_RELEASE(m_pSwapChain); pp.BackBufferWidth = BackBufferWidth; pp.BackBufferHeight = BackBufferHeight; if (FAILED(hr=m_pDevice->CreateAdditionalSwapChain(&pp, &m_pSwapChain))) return false; } So this gets called in the onsize function of my window. But after some resizeing the CreateAdditionalSwapchain function returns with D3DERR_OUTOFVIDEOMEMORY. It seems that I'm not releasing the swapchain correctly, because if I just create it once it works ok. Could anyone help me out with this? Thx, Loncs

Share this post


Link to post
Share on other sites
First, do the Debug Runtimes report any memory leaks if you resize once or twice then quit?

Second, you should only be re-creating your swap chain on the WM_SIZE message, and you can update your projection matrix in WM_SIZING (If you're not already). Re-creating the swap chain during WM_SIZING is probably going to be bad (Since it's called very frequently).

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