summaryrefslogtreecommitdiffstats
path: root/src/render/renderers/opengl/renderer
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-02-14 10:20:38 +0100
committerPaul Lemire <paul.lemire@kdab.com>2020-02-17 07:03:58 +0100
commite52382023b85c435e9c1e3a37eeac65178ee54e0 (patch)
tree82624e1155601df7d21e05c6152431f1082b5937 /src/render/renderers/opengl/renderer
parent42c0dbc377af4d307747a32ca1c1fd267ce4337f (diff)
Fix and improve FBO handling
FBO need to be rebuild when one of the attachments directly or indirectly changes. By direct change we mean one of the FBO attachment texture being resized or the list of attachments changing. By indirect we mean when texture resource is recreated internally by the engine. Failure to handle this cases resulted in FBO referencing invalid attachments. Change-Id: I8dd4c08e464eed7fb0eeefd61a4158304ab4245f Task-number: QTBUG-64757 Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/renderers/opengl/renderer')
-rw-r--r--src/render/renderers/opengl/renderer/renderer.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp
index 3e5bef3cd..aced13fc5 100644
--- a/src/render/renderers/opengl/renderer/renderer.cpp
+++ b/src/render/renderers/opengl/renderer/renderer.cpp
@@ -1359,13 +1359,15 @@ void Renderer::updateGLResources()
if (texture == nullptr)
continue;
- // Create or Update GLTexture (the GLTexture instance is created if required
- // and all things that can take place without a GL context are done here)
+ // Create or Update GLTexture (the GLTexture instance is created
+ // (not the underlying GL instance) if required and all things that
+ // can take place without a GL context are done here)
updateTexture(texture);
}
// We want to upload textures data at this point as the SubmissionThread and
// AspectThread are locked ensuring no races between Texture/TextureImage and
// GLTexture
+ QNodeIdVector updatedTexturesForFrame;
if (m_submissionContext != nullptr) {
GLTextureManager *glTextureManager = m_nodesManager->glTextureManager();
const QVector<HGLTexture> glTextureHandles = glTextureManager->activeHandles();
@@ -1387,10 +1389,15 @@ void Renderer::updateGLResources()
updateInfo.handleType = QAbstractTexture::OpenGLTextureId;
updateInfo.handle = info.texture ? QVariant(info.texture->textureId()) : QVariant();
m_updatedTextureProperties.push_back({updateInfo, referenceTextureIds});
+ updatedTexturesForFrame += referenceTextureIds;
}
}
}
+ // If the underlying GL Texture was for whatever reason recreated, we need to make sure
+ // that if it is used as a color attachment, we rebuild the FBO next time it is used
+ m_submissionContext->setUpdatedTexture(std::move(updatedTexturesForFrame));
+
// Record ids of texture to cleanup while we are still blocking the aspect thread
m_textureIdsToCleanup += m_nodesManager->textureManager()->takeTexturesIdsToCleanup();
}