Skip to content

Commit

Permalink
Add RenderQueue::_releaseManualHardwareResources() to release indirec…
Browse files Browse the repository at this point in the history
…t buffers on device lost, especially on VK RS
  • Loading branch information
eugenegff committed Nov 26, 2024
1 parent 2c3ee82 commit 139037f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions OgreMain/include/OgreRenderQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ namespace Ogre
RenderQueue( HlmsManager *hlmsManager, SceneManager *sceneManager, VaoManager *vaoManager );
~RenderQueue();

void _releaseManualHardwareResources();

/// Empty the queue - should only be called by SceneManagers.
void clear();

Expand Down
7 changes: 7 additions & 0 deletions OgreMain/src/OgreRenderQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ namespace Ogre
{
delete mCommandBuffer;

_releaseManualHardwareResources();
}
//-----------------------------------------------------------------------
void RenderQueue::_releaseManualHardwareResources()
{
assert( mUsedIndirectBuffers.empty() );

IndirectBufferPackedVec::const_iterator itor = mFreeIndirectBuffers.begin();
Expand All @@ -131,6 +136,8 @@ namespace Ogre
mVaoManager->destroyIndirectBuffer( *itor );
++itor;
}

mFreeIndirectBuffers.clear();
}
//-----------------------------------------------------------------------
IndirectBufferPacked *RenderQueue::getIndirectBuffer( size_t numDraws )
Expand Down
4 changes: 4 additions & 0 deletions OgreMain/src/OgreSceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,10 @@ namespace Ogre
//-----------------------------------------------------------------------
void SceneManager::_releaseManualHardwareResources()
{
// release indirect buffers in render queue
if( mRenderQueue )
mRenderQueue->_releaseManualHardwareResources();

// release hardware resources inside all movable objects
OGRE_LOCK_MUTEX( mMovableObjectCollectionMapMutex );
for( MovableObjectCollectionMap::iterator ci = mMovableObjectCollectionMap.begin(),
Expand Down

0 comments on commit 139037f

Please sign in to comment.