diff options
| author | Laszlo Agocs <laszlo.agocs@qt.io> | 2023-03-01 13:51:58 +0100 |
|---|---|---|
| committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2023-03-02 17:39:10 +0000 |
| commit | 7cf6c57648c67bea42a54c561dc3c1616a305756 (patch) | |
| tree | 6d29c8672b569a8430f1f7d860861ec2d558d2f3 /src/opengl/qopengltexturecache_p.h | |
| parent | d6c5a2f9177f427d14aae64d111c172d1bf28b6c (diff) | |
Avoid incomplete textures in GL paint engine
...which can happen if the OpenGL implementation reuses IDs
so that a glGenTextures results in the same ID that was used
by a texture destroyed by glDeleteTextures just before.
In this case the lastTextureUsed tracking needs to be aware
and invalidate, otherwise the newly created texture is
assumed to be already existing (the ID is the same as before
after all), and so operations such as setting the minification
filter is skipped (which is fatal with OpenGL given that we
do not use mipmaps).
This is exercised in practice by the drawPixmapFragments test
introduced in the previous patch. On Intel graphics it would
work, but it does not render correctly with NVIDIA due to how
the driver's internal ID handling works.
Pick-to: 6.5.0 6.5 6.4 6.2
Change-Id: Ic2771fe9a2dec7da4aa3804d8498dd89e3c18415
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/opengl/qopengltexturecache_p.h')
| -rw-r--r-- | src/opengl/qopengltexturecache_p.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/opengl/qopengltexturecache_p.h b/src/opengl/qopengltexturecache_p.h index afc12f0b383..b70520aa1c8 100644 --- a/src/opengl/qopengltexturecache_p.h +++ b/src/opengl/qopengltexturecache_p.h @@ -35,10 +35,20 @@ public: QOpenGLTextureCache(QOpenGLContext *); ~QOpenGLTextureCache(); - GLuint bindTexture(QOpenGLContext *context, const QPixmap &pixmap, - QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption); - GLuint bindTexture(QOpenGLContext *context, const QImage &image, - QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption); + enum class BindResultFlag : quint8 { + NewTexture = 0x01 + }; + Q_DECLARE_FLAGS(BindResultFlags, BindResultFlag) + + struct BindResult { + GLuint id; + BindResultFlags flags; + }; + + BindResult bindTexture(QOpenGLContext *context, const QPixmap &pixmap, + QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption); + BindResult bindTexture(QOpenGLContext *context, const QImage &image, + QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption); void invalidate(qint64 key); @@ -46,12 +56,14 @@ public: void freeResource(QOpenGLContext *ctx) override; private: - GLuint bindTexture(QOpenGLContext *context, qint64 key, const QImage &image, QOpenGLTextureUploader::BindOptions options); + BindResult bindTexture(QOpenGLContext *context, qint64 key, const QImage &image, QOpenGLTextureUploader::BindOptions options); QMutex m_mutex; QCache<quint64, QOpenGLCachedTexture> m_cache; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLTextureCache::BindResultFlags) + class QOpenGLCachedTexture { public: |
