Skip to content

Commit

Permalink
[Vk] Fix dangling pointer after destroying TextureGpu (#416)
Browse files Browse the repository at this point in the history
Fixes #416
  • Loading branch information
darksylinc committed Sep 12, 2023
1 parent 26d43e4 commit 4efe057
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions RenderSystems/Vulkan/src/OgreVulkanQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,10 +1051,14 @@ namespace Ogre
if( mEncoderState == EncoderCopyOpen )
{
bool needsToFlush = false;
bool mustRemoveFromBarrier = false;
TextureGpuDownloadMap::const_iterator itor = mCopyDownloadTextures.find( texture );

if( itor != mCopyDownloadTextures.end() )
{
needsToFlush = true;
mustRemoveFromBarrier = true;
}
else
{
FastArray<TextureGpu *>::const_iterator it2 =
Expand All @@ -1072,6 +1076,14 @@ namespace Ogre
OGRE_ASSERT_LOW( texture->mCurrLayout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL ||
texture->mCurrLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL );
endCopyEncoder();

if( mustRemoveFromBarrier )
{
// endCopyEncoder() just called solver.assumeTransition() on this texture
// but we're destroying the texture. Remove the dangling pointer.
BarrierSolver &solver = mRenderSystem->getBarrierSolver();
solver.textureDeleted( texture );
}
}
}
}
Expand Down

0 comments on commit 4efe057

Please sign in to comment.