Jump to content
  • Advertisement
Sign in to follow this  
Loncs

directx 9 swapchain - out of video memory

This topic is 3735 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

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
Advertisement
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
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!