diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2018-07-20 09:17:18 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2018-08-08 13:41:13 +0000 |
commit | 85f8e910fa484296afd19a4568ba939502d562f7 (patch) | |
tree | 253c300a1266c5cd1b5997c90796bbb1af0f9369 /src/render/renderers/opengl/textures/gltexture.cpp | |
parent | 0b10ab797fea863ff2c4897b1c4eb993b21b153d (diff) |
Properly update properties from Backend to Frontend textures
Taking into account we have texture sharing in the backend,
we can only update frontend texture properties once we have
created the shared backend texture.
Code was adjusted to retrieve these properties when creating
the GLTexture. Such changes are stored and sent on the next
run loop from a job where they are distributed to all referenced
frontend Texture.
The status property handling has also been updated to send status
changes to all shared textures instead of just the texture whose
data generator is used to gather the data.
A manual test checking texture property updates, sharing and
remote url sharing has also been added.
Change-Id: I8ed2449fe57c9d7337580b0f7561f974cbd5006d
Task-number: QTBUG-65775
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/renderers/opengl/textures/gltexture.cpp')
-rw-r--r-- | src/render/renderers/opengl/textures/gltexture.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/render/renderers/opengl/textures/gltexture.cpp b/src/render/renderers/opengl/textures/gltexture.cpp index 3d8664e78..bb7e06e60 100644 --- a/src/render/renderers/opengl/textures/gltexture.cpp +++ b/src/render/renderers/opengl/textures/gltexture.cpp @@ -105,10 +105,13 @@ void GLTexture::destroyGLTexture() destroyResources(); } -QOpenGLTexture* GLTexture::getOrCreateGLTexture() +GLTexture::TextureUpdateInfo GLTexture::createOrUpdateGLTexture() { QMutexLocker locker(&m_textureMutex); bool needUpload = false; + TextureUpdateInfo textureInfo; + + m_properties.status = QAbstractTexture::Error; // on the first invocation in the render thread, make sure to // evaluate the texture data generator output @@ -140,7 +143,8 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture() needUpload = true; } else { qWarning() << "[Qt3DRender::GLTexture] No QTextureData generated from Texture Generator yet. Texture will be invalid for this frame"; - return nullptr; + textureInfo.properties.status = QAbstractTexture::Loading; + return textureInfo; } } @@ -188,8 +192,10 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture() } // don't try to create the texture if the format was not set - if (m_properties.format == QAbstractTexture::Automatic) - return nullptr; + if (m_properties.format == QAbstractTexture::Automatic) { + textureInfo.properties.status = QAbstractTexture::Error; + return textureInfo; + } // if the properties changed, we need to re-allocate the texture if (testDirtyFlag(Properties)) { @@ -197,15 +203,24 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture() m_gl = nullptr; } + if (!m_gl) { m_gl = buildGLTexture(); - if (!m_gl) - return nullptr; + if (!m_gl) { + textureInfo.properties.status = QAbstractTexture::Error; + return textureInfo; + } + m_gl->allocateStorage(); if (!m_gl->isStorageAllocated()) { - return nullptr; + textureInfo.properties.status = QAbstractTexture::Error; + return textureInfo; } } + m_properties.status = QAbstractTexture::Ready; + + textureInfo.properties = m_properties; + textureInfo.texture = m_gl; // need to (re-)upload texture data? if (needUpload) { @@ -223,7 +238,7 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture() setDirtyFlag(Properties, false); setDirtyFlag(Parameters, false); - return m_gl; + return textureInfo; } RenderBuffer *GLTexture::getOrCreateRenderBuffer() @@ -442,7 +457,7 @@ void GLTexture::uploadGLTextureData() } // Upload all QTexImageData references by the TextureImages - for (int i = 0; i < m_images.size(); i++) { + for (int i = 0; i < std::min(m_images.size(), m_imageData.size()); i++) { const QTextureImageDataPtr &imgData = m_imageData.at(i); // Here the bytes in the QTextureImageData contain data for a single // layer, face or mip level, unlike the QTextureGenerator case where |