diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-01-05 19:01:36 +0000 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-01-06 10:29:14 +0000 |
commit | 440589a0747d9668fec3ff924b390d75be5c6733 (patch) | |
tree | 17d2e22c76f69ee1f2d1dbff40d61634245f43c0 | |
parent | 32605e5e25ebcc8de0ca0a8327248e6d28853cd4 (diff) |
Fix race condition with dynamic texture updatesv5.8.0
Mutex protect the dirty flag written by both the threadpool and the
submisison thread. Without this it is easy to end up with no textures
being used when the user updates them under certain workloads.
Task-number: QTBUG-57939
Change-Id: Idba4137f023ccfcb6ceb409cc6df3a2b4dddf510
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
-rw-r--r-- | src/render/texture/gltexture.cpp | 4 | ||||
-rw-r--r-- | src/render/texture/gltexture_p.h | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/render/texture/gltexture.cpp b/src/render/texture/gltexture.cpp index 1a76617a7..0e3291fb0 100644 --- a/src/render/texture/gltexture.cpp +++ b/src/render/texture/gltexture.cpp @@ -97,6 +97,7 @@ void GLTexture::destroyGLTexture() { delete m_gl; m_gl = nullptr; + QMutexLocker locker(&m_dirtyFlagMutex); m_dirty = 0; destroyResources(); @@ -104,6 +105,7 @@ void GLTexture::destroyGLTexture() QOpenGLTexture* GLTexture::getOrCreateGLTexture() { + QMutexLocker locker(&m_dirtyFlagMutex); bool needUpload = false; bool texturedDataInvalid = false; @@ -210,6 +212,7 @@ void GLTexture::setParameters(const TextureParameters ¶ms) { if (m_parameters != params) { m_parameters = params; + QMutexLocker locker(&m_dirtyFlagMutex); m_dirty |= Parameters; } } @@ -218,6 +221,7 @@ void GLTexture::setProperties(const TextureProperties &props) { if (m_properties != props) { m_properties = props; + QMutexLocker locker(&m_dirtyFlagMutex); m_dirty |= Properties; } } diff --git a/src/render/texture/gltexture_p.h b/src/render/texture/gltexture_p.h index 7c6bf9c90..424e77854 100644 --- a/src/render/texture/gltexture_p.h +++ b/src/render/texture/gltexture_p.h @@ -142,7 +142,11 @@ public: // Called by TextureDataManager when it has new texture data from // a generator that needs to be uploaded. - void requestUpload() { m_dirty |= TextureData; } + void requestUpload() + { + QMutexLocker locker(&m_dirtyFlagMutex); + m_dirty |= TextureData; + } protected: @@ -178,6 +182,7 @@ private: bool m_unique; DirtyFlags m_dirty; + QMutex m_dirtyFlagMutex; QOpenGLTexture *m_gl; TextureDataManager *m_textureDataManager; |