From b62cb0e2a47d5252d686ee2770ddc6fb6711a194 Mon Sep 17 00:00:00 2001 From: Kyle Cooley Date: Sun, 20 Aug 2017 19:55:16 -0400 Subject: [PATCH] Clear out GPU texture/stateset cache --- components/resource/scenemanager.cpp | 16 ++++++++++++++++ components/resource/scenemanager.hpp | 2 ++ 2 files changed, 18 insertions(+) diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 226933760..2f04aa7c2 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -122,6 +122,13 @@ namespace Resource { return _sharedStateSetList.size(); } + + void clearCache() + { + OpenThreads::ScopedLock lock(_listMutex); + _sharedTextureList.clear(); + _sharedStateSetList.clear(); + } }; /// Set texture filtering settings on textures contained in a FlipController. @@ -710,6 +717,15 @@ namespace Resource mSharedStateMutex.unlock(); } + void SceneManager::clearCache() + { + ResourceManager::clearCache(); + + mSharedStateMutex.lock(); + mSharedStateManager->clearCache(); + mSharedStateMutex.unlock(); + } + void SceneManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const { { diff --git a/components/resource/scenemanager.hpp b/components/resource/scenemanager.hpp index c6ff02acf..14032df77 100644 --- a/components/resource/scenemanager.hpp +++ b/components/resource/scenemanager.hpp @@ -143,6 +143,8 @@ namespace Resource /// @see ResourceManager::updateCache virtual void updateCache(double referenceTime); + virtual void clearCache(); + virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const; private: