From 16a9c7bca037992d37281f5f9185c1dc79cb427b Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Mon, 30 Dec 2024 13:23:55 +0100 Subject: [PATCH] [Vk] Don't stall in VulkanRenderSystem::destroyVkResources0() when device is lost. Also, RenderQueue::mUsedIndirectBuffers could be non empty after device lost. --- OgreMain/src/OgreRenderQueue.cpp | 21 ++++++++++--------- .../Vulkan/src/OgreVulkanRenderSystem.cpp | 3 ++- 2 files changed, 13 insertions(+), 11 deletions(-) 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()