[1.12.0] Proper resource destruction

Problems building or running the engine, queries about how to use features etc.
Post Reply
Pellaeon
Halfling
Posts: 97
Joined: Thu Apr 28, 2011 12:23 pm
x 3

[1.12.0] Proper resource destruction

Post by Pellaeon » Mon May 20, 2019 1:50 pm

Ogre Version: 1.12.0
Operating System: Win 10 x64
Render System: DX11

Hello,

I try to migrate my application from Ogre 1.11.5 with DX9 to v1.12.0 with DX11 renderer with the help of RTSS.
Rendering works fine, but when closing the application I get an assert from D3D11DeviceResourceManager that the resources are not empty.

At first: this necer happend before with ogre 1.11.5 and DX 9 renderer.

Second: when looking into the debugger the tells me that a texture I created manually wasn't released.
Before destroying the ogre root, I reset the smart pointer, the resource group is also unloaded. The rectangle which uses the texture is also remove from the scene graph (and the scene graph is also deleting all it's children when it is destructed) So I don't understand why the texture resource is still there.

code for texture creation

Code: Select all

m_videoTexture = Ogre::TextureManager::getSingleton().load(castWStringToString(textureFile), ArGraphic::getARViewerResourceGroup());
m_material->getTechnique(0)->getPass(0)->createTextureUnitState(m_videoTexture->getName());
m_rectangle->setMaterial(m_material);
And also strange: my application uses mygui and a normal model loaded with ogremax scene loader. To find out the problem I outcommented parts of rendered primitives. When only rendering mygui, then my explained texture from aboth isn't destroyed. But when rendering the GUI elements and my model, then two textures from the model aren't destructed, but my manual texture is destroyed properly. :?: :?: :?: I see no logic behind this.

So my first question: what is the right method to remove a manual object proper when closing the application and what is done automatically in teh destructors of the managers etc.
And second: does anyone else have problems like this and perhaps some hints/suggestions how to deal with this problem?

Regards

Pellaeon
Attachments
screen.jpg
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 853
Joined: Sun Mar 30, 2014 2:51 pm
x 168
Contact:

Re: [1.12.0] Proper resource destruction

Post by paroj » Tue May 21, 2019 11:19 am

Pellaeon wrote:
Mon May 20, 2019 1:50 pm
Second: when looking into the debugger the tells me that a texture I created manually wasn't released.
Before destroying the ogre root, I reset the smart pointer, the resource group is also unloaded. The rectangle which uses the texture is also remove from the scene graph (and the scene graph is also deleting all it's children when it is destructed) So I don't understand why the texture resource is still there.
do you call remove? https://ogrecave.github.io/ogre/api/lat ... ddcf7b3f19

the issue does not show with DX9 as it does not fully track resources to handle device lost.
0 x

Pellaeon
Halfling
Posts: 97
Joined: Thu Apr 28, 2011 12:23 pm
x 3

Re: [1.12.0] Proper resource destruction

Post by Pellaeon » Wed May 22, 2019 7:50 am

Yes, I remove the texture with the following code

Code: Select all

Ogre::TextureManager* textureManager = Ogre::TextureManager::getSingletonPtr();
if (textureManager && textureManager->resourceExists(graphicCst::textureName, ArGraphic::getARViewerResourceGroup()))
{
	textureManager->remove(graphicCst::textureName, ArGraphic::getARViewerResourceGroup());
}
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 853
Joined: Sun Mar 30, 2014 2:51 pm
x 168
Contact:

Re: [1.12.0] Proper resource destruction

Post by paroj » Wed May 22, 2019 10:57 am

please remove the null checks. If any of them fail you are already in an invalid state.
0 x

Pellaeon
Halfling
Posts: 97
Joined: Thu Apr 28, 2011 12:23 pm
x 3

Re: [1.12.0] Proper resource destruction

Post by Pellaeon » Wed May 22, 2019 12:48 pm

I can remove the check for textureManager but not the resourceExist call because there is the case in my application that the texture wasn't created. But in the latter case I haven't the problem at all. It "only" occurs when the texure was really created.
0 x

rpgplayerrobin
Gremlin
Posts: 151
Joined: Wed Mar 18, 2009 3:03 am
x 16

Re: [1.12.0] Proper resource destruction

Post by rpgplayerrobin » Sat May 25, 2019 12:11 am

I don't know if this helps, but this is the way I handle destroying a manual texture that I create on the fly:

Code: Select all

String tmpStr = resource->getName();
TextureManager::getSingleton().unload( tmpStr );
TextureManager::getSingleton().remove( tmpStr );
resource.reset();
Also, I make sure that the texture is not used in any materials, so before destroying it I remove it from all materials it was used in by setting the texture to something I know exists (for me it is "white.png").
0 x

Post Reply