summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2018-07-16 10:01:18 +0200
committerPaul Lemire <paul.lemire@kdab.com>2018-07-18 07:46:39 +0000
commit78cc8598d44c1af4cf5964b0b8a935901db82856 (patch)
treee227c62d7ce22ac65ee29f9ebf8fec25532e4feb /src
parent5376853866e49b5a6841c6c41affef5a3d3d4bb5 (diff)
Renderer: do not lookup cleanup textures
Since they are already destroyed, cleanup textured ids shouldn't be used to look up backend textures but only to tell the GLTextureManager to abandon referenced textures. The was an oversight that should have been handled in d47c78e6. Change-Id: Iafaee4bb6442c907f6e011c80b5e5347579efde5 Task-number: QTBUG-69379 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/render/renderers/opengl/renderer/renderer.cpp12
-rw-r--r--src/render/renderers/opengl/renderer/renderer_p.h2
-rw-r--r--src/render/texture/apitexturemanager_p.h6
3 files changed, 10 insertions, 10 deletions
diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp
index 27d46cc81..1e0a43b30 100644
--- a/src/render/renderers/opengl/renderer/renderer.cpp
+++ b/src/render/renderers/opengl/renderer/renderer.cpp
@@ -1197,7 +1197,7 @@ void Renderer::updateGLResources()
// texture and avoid possible destroying recreating a new texture
const QVector<Qt3DCore::QNodeId> cleanedUpTextureIds = m_nodesManager->textureManager()->takeTexturesIdsToCleanup();
for (const Qt3DCore::QNodeId textureCleanedUpId: cleanedUpTextureIds)
- cleanupTexture(m_nodesManager->textureManager()->lookupResource(textureCleanedUpId));
+ cleanupTexture(textureCleanedUpId);
}
// Render Thread
@@ -1245,7 +1245,7 @@ void Renderer::updateTexture(Texture *texture)
// if this texture is a shared texture, we might need to look for a new TextureImpl
// and abandon the old one
if (glTextureManager->isShared(glTexture)) {
- glTextureManager->abandon(glTexture, texture);
+ glTextureManager->abandon(glTexture, texture->peerId());
// Note: if isUnique is true, a once shared texture will become unique
createOrUpdateGLTexture();
return;
@@ -1257,7 +1257,7 @@ void Renderer::updateTexture(Texture *texture)
if (!isUnique) {
GLTexture *newSharedTex = glTextureManager->findMatchingShared(texture);
if (newSharedTex && newSharedTex != glTexture) {
- glTextureManager->abandon(glTexture, texture);
+ glTextureManager->abandon(glTexture, texture->peerId());
glTextureManager->adoptShared(newSharedTex, texture);
texture->unsetDirty();
return;
@@ -1291,13 +1291,13 @@ void Renderer::updateTexture(Texture *texture)
}
// Render Thread
-void Renderer::cleanupTexture(const Texture *texture)
+void Renderer::cleanupTexture(Qt3DCore::QNodeId cleanedUpTextureId)
{
GLTextureManager *glTextureManager = m_nodesManager->glTextureManager();
- GLTexture *glTexture = glTextureManager->lookupResource(texture->peerId());
+ GLTexture *glTexture = glTextureManager->lookupResource(cleanedUpTextureId);
if (glTexture != nullptr)
- glTextureManager->abandon(glTexture, texture);
+ glTextureManager->abandon(glTexture, cleanedUpTextureId);
}
void Renderer::downloadGLBuffers()
diff --git a/src/render/renderers/opengl/renderer/renderer_p.h b/src/render/renderers/opengl/renderer/renderer_p.h
index 826d069c3..b501fe6a0 100644
--- a/src/render/renderers/opengl/renderer/renderer_p.h
+++ b/src/render/renderers/opengl/renderer/renderer_p.h
@@ -233,7 +233,7 @@ public:
void updateGLResources();
void updateTexture(Texture *texture);
- void cleanupTexture(const Texture *texture);
+ void cleanupTexture(Qt3DCore::QNodeId cleanedUpTextureId);
void downloadGLBuffers();
void blitFramebuffer(Qt3DCore::QNodeId inputRenderTargetId,
Qt3DCore::QNodeId outputRenderTargetId,
diff --git a/src/render/texture/apitexturemanager_p.h b/src/render/texture/apitexturemanager_p.h
index 91747b3bc..97dc1eb27 100644
--- a/src/render/texture/apitexturemanager_p.h
+++ b/src/render/texture/apitexturemanager_p.h
@@ -161,9 +161,9 @@ public:
// De-associate the given APITexture from the backend node. If the texture
// is no longer referenced by any other node, it will be deleted.
- void abandon(APITexture *tex, const Texture *node)
+ void abandon(APITexture *tex, const Qt3DCore::QNodeId nodeId)
{
- APITexture *apiTexture = m_nodeIdToGLTexture.take(node->peerId());
+ APITexture *apiTexture = m_nodeIdToGLTexture.take(nodeId);
Q_ASSERT(tex == apiTexture);
if (Q_UNLIKELY(!apiTexture)) {
@@ -176,7 +176,7 @@ public:
m_abandonedTextures.push_back(apiTexture);
} else {
QVector<Qt3DCore::QNodeId> &referencedTextureNodes = m_sharedTextures[apiTexture];
- referencedTextureNodes.removeAll(node->peerId());
+ referencedTextureNodes.removeAll(nodeId);
// If no texture nodes is referencing the shared APITexture, remove it
if (referencedTextureNodes.empty()) {