diff --git a/OgreMain/src/OgreRenderQueue.cpp b/OgreMain/src/OgreRenderQueue.cpp index 84b0b424e4..68b6030354 100644 --- a/OgreMain/src/OgreRenderQueue.cpp +++ b/OgreMain/src/OgreRenderQueue.cpp @@ -124,19 +124,20 @@ namespace Ogre //----------------------------------------------------------------------- void RenderQueue::_releaseManualHardwareResources() { - assert( mUsedIndirectBuffers.empty() ); - - IndirectBufferPackedVec::const_iterator itor = mFreeIndirectBuffers.begin(); - IndirectBufferPackedVec::const_iterator endt = mFreeIndirectBuffers.end(); - - while( itor != endt ) + for( IndirectBufferPacked *buf : mUsedIndirectBuffers ) { - if( ( *itor )->getMappingState() != MS_UNMAPPED ) - ( *itor )->unmap( UO_UNMAP_ALL ); - mVaoManager->destroyIndirectBuffer( *itor ); - ++itor; + if( buf->getMappingState() != MS_UNMAPPED ) + buf->unmap( UO_UNMAP_ALL ); + mVaoManager->destroyIndirectBuffer( buf ); } + mUsedIndirectBuffers.clear(); + for( IndirectBufferPacked *buf : mFreeIndirectBuffers ) + { + if( buf->getMappingState() != MS_UNMAPPED ) + buf->unmap( UO_UNMAP_ALL ); + mVaoManager->destroyIndirectBuffer( buf ); + } mFreeIndirectBuffers.clear(); } //----------------------------------------------------------------------- diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index dabffd0673..c8c319761e 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -404,7 +404,8 @@ namespace Ogre mCurrentAutoParamsBufferPtr = 0; mCurrentAutoParamsBufferSpaceLeft = 0; - mDevice->stall(); + if( !mDevice->isDeviceLost() ) + mDevice->stall(); } //------------------------------------------------------------------------- void VulkanRenderSystem::destroyVkResources1()