Skip to content

Commit

Permalink
[GL3+] Fix destruction of RenderTextures destroying regular Textures
Browse files Browse the repository at this point in the history
destroyInternalResourcesImpl was only being called from within
GL3PlusTextureGpu's destructor.

However it is a virtual call, and thus
GL3PlusTextureGpuRenderTarget::destroyInternalResourcesImpl would never
get called.

This led GL3PlusTextureGpu::destroyInternalResourcesImpl to believe
there is a regular Texture in mFinalTextureName, because derived class
never got to zero it out.

To trigger this scenario:
* The RenderTexture had to be a depth buffer or be created with the
NotTexture flag
* The TextureGpu must be destroyed without having been transitioned to
non-resident
* A regular texture and a RenderTarget had both been asigned the same
mFinalTextureName handle value (one is a glRenderbuffer, the other a
glTexture)

Although the conditions are hard to trigger, the fix for shared depth
buffers leaking (#103) skyrocketed the likehood of encountering this bug
  • Loading branch information
darksylinc committed Jul 2, 2020
1 parent 41760a6 commit ae48695
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions RenderSystems/GL3Plus/include/OgreGL3PlusTextureGpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ namespace Ogre
VaoManager *vaoManager, IdString name, uint32 textureFlags,
TextureTypes::TextureTypes initialType,
TextureGpuManager *textureManager );
virtual ~GL3PlusTextureGpuRenderTarget();

virtual void _setDepthBufferDefaults( uint16 depthBufferPoolId, bool preferDepthTexture,
PixelFormatGpu desiredDepthBufferFormat );
Expand Down
5 changes: 5 additions & 0 deletions RenderSystems/GL3Plus/src/OgreGL3PlusTextureGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,11 @@ namespace Ogre
mDepthBufferPoolId = 0;
}
//-----------------------------------------------------------------------------------
GL3PlusTextureGpuRenderTarget::~GL3PlusTextureGpuRenderTarget()
{
destroyInternalResourcesImpl();
}
//-----------------------------------------------------------------------------------
void GL3PlusTextureGpuRenderTarget::createInternalResourcesImpl(void)
{
if( mPixelFormat == PFG_NULL )
Expand Down

0 comments on commit ae48695

Please sign in to comment.