Hello,
We've noticed a bit of an oddity with the Direct3D9 renderer when it comes to render targets. When a render window is created it is stored once attached in the map RenderSystem::mRenderTargets. However, for D3D9RenderSystem, it is also stored in a vector named mRenderWindows. When we have to destroy this render window, we used to call Ogre::Root::getSingletonPtr()->destroyRenderTarget(m_pRenderWindow);. This will call the detachRenderTarget method of the current renderer. Since this method is not overloaded in D3D9RenderSystem, the method of the parent class is called which will only remove the render target from the map RenderSystem::mRenderTargets. Therefore, a dangling pointer is left in the vector mRenderWindows of D3D9RenderSystem. As a result, when another piece of code calls directly D3D9RenderSystem::destroyRenderTarget (in our case from D3D9HardwarePixelBuffer::destroyRenderTexture), the dangling pointer leads to a crash when accessed ((*sw)->getName()).
For now we're going to use Ogre::Root::getSingleton().getRenderSystem()->destroyRenderTarget(m_pRenderWindow->getName()); directly as a workaround. We would provide a patch, but we're unsure on what is the correct way to fix this problem.
Best regards,
Nicolas GIROD -- Ice Development.
[BUG] Problem with destroyRenderTarget and D3D9RenderSystem
-
- Gnoblar
- Posts: 8
- Joined: Thu Sep 22, 2011 10:31 am
[BUG] Problem with destroyRenderTarget and D3D9RenderSystem
Last edited by Icedev on Tue Apr 03, 2012 8:21 am, edited 1 time in total.
-
- OGRE Expert User
- Posts: 1920
- Joined: Sun Feb 19, 2012 9:24 pm
- Location: Russia
- x 201
Re: [BUG] Problem with destroyRenderTarget and D3D9RenderSys
Yeah, doesn't look good. I think you can submit a ticket.