Fixed RenderTextureImplFBO's destructor incorrectly triggering deletion of other RenderTextureImplFBOs' active FBOs even when the context they reside in isn't being destroyed.
This commit is contained in:
parent
bb3bd05823
commit
b012266258
@ -53,6 +53,23 @@ namespace
|
|||||||
// Mutex to protect both active and stale frame buffer sets
|
// Mutex to protect both active and stale frame buffer sets
|
||||||
sf::Mutex mutex;
|
sf::Mutex mutex;
|
||||||
|
|
||||||
|
// This function is called either when a RenderTextureImplFBO is
|
||||||
|
// destroyed or via contextDestroyCallback when context destruction
|
||||||
|
// might trigger deletion of its contained stale FBOs
|
||||||
|
void destroyStaleFBOs()
|
||||||
|
{
|
||||||
|
sf::Uint64 contextId = sf::Context::getActiveContextId();
|
||||||
|
|
||||||
|
for (std::set<std::pair<sf::Uint64, unsigned int> >::iterator iter = staleFrameBuffers.begin(); iter != staleFrameBuffers.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (iter->first == contextId)
|
||||||
|
{
|
||||||
|
GLuint frameBuffer = static_cast<GLuint>(iter->second);
|
||||||
|
glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Callback that is called every time a context is destroyed
|
// Callback that is called every time a context is destroyed
|
||||||
void contextDestroyCallback(void* arg)
|
void contextDestroyCallback(void* arg)
|
||||||
{
|
{
|
||||||
@ -79,14 +96,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Destroy stale frame buffer objects
|
// Destroy stale frame buffer objects
|
||||||
for (std::set<std::pair<sf::Uint64, unsigned int> >::iterator iter = staleFrameBuffers.begin(); iter != staleFrameBuffers.end(); ++iter)
|
destroyStaleFBOs();
|
||||||
{
|
|
||||||
if (iter->first == contextId)
|
|
||||||
{
|
|
||||||
GLuint frameBuffer = static_cast<GLuint>(iter->second);
|
|
||||||
glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +160,7 @@ RenderTextureImplFBO::~RenderTextureImplFBO()
|
|||||||
staleFrameBuffers.insert(std::make_pair(iter->first, iter->second));
|
staleFrameBuffers.insert(std::make_pair(iter->first, iter->second));
|
||||||
|
|
||||||
// Clean up FBOs
|
// Clean up FBOs
|
||||||
contextDestroyCallback(0);
|
destroyStaleFBOs();
|
||||||
|
|
||||||
// Delete the backup context if we had to create one
|
// Delete the backup context if we had to create one
|
||||||
delete m_context;
|
delete m_context;
|
||||||
|
Loading…
Reference in New Issue
Block a user