From aefadfaa6a61e8e27ca4dc301d4e3260de1434c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Thu, 11 Dec 2014 22:22:08 +0100 Subject: [PATCH] Don't generate mipmaps in GLTexture::bind() This code is broken in a number of different ways; firstly by assuming that the mipmaps need to be regenerated when the texture filter has changed. Secondly by preventing mipmaps from being specified by other means. This commit removes the code from bind() and adds a generateMipmaps() method instead. --- effects/logout/logout.cpp | 1 + effects/lookingglass/lookingglass.cpp | 1 + libkwineffects/kwingltexture.cpp | 14 +++++++++----- libkwineffects/kwingltexture.h | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index 28ae121fad..59c078becc 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -357,6 +357,7 @@ void LogoutEffect::renderBlurTexture() glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); blurTexture->bind(); + blurTexture->generateMipmaps(); blurTexture->render(infiniteRegion(), effects->virtualScreenGeometry()); blurTexture->unbind(); glDisable(GL_BLEND); diff --git a/effects/lookingglass/lookingglass.cpp b/effects/lookingglass/lookingglass.cpp index d30aa7f008..784b303a66 100644 --- a/effects/lookingglass/lookingglass.cpp +++ b/effects/lookingglass/lookingglass.cpp @@ -239,6 +239,7 @@ void LookingGlassEffect::postPaintScreen() assert(target == m_fbo); Q_UNUSED(target); m_texture->bind(); + m_texture->generateMipmaps(); // Use the shader ShaderBinder binder(m_shader); diff --git a/libkwineffects/kwingltexture.cpp b/libkwineffects/kwingltexture.cpp index 03e09be066..6a56474f0a 100644 --- a/libkwineffects/kwingltexture.cpp +++ b/libkwineffects/kwingltexture.cpp @@ -283,7 +283,6 @@ void GLTexture::update(const QImage &image, const QPoint &offset, const QRect &s } unbind(); - setDirty(); if (useUnpack) { glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); @@ -312,7 +311,6 @@ void GLTexture::bind() if (d->s_supportsFramebufferObjects && d->m_canUseMipmaps) { glTexParameteri(d->m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(d->m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glGenerateMipmap(d->m_target); } else { // can't use trilinear, so use bilinear d->m_filter = GL_LINEAR; @@ -337,6 +335,14 @@ void GLTexture::bind() } } +void GLTexture::generateMipmaps() +{ + Q_D(GLTexture); + + if (d->m_canUseMipmaps && d->s_supportsFramebufferObjects) + glGenerateMipmap(d->m_target); +} + void GLTexture::unbind() { Q_D(GLTexture); @@ -460,9 +466,7 @@ void GLTexture::setWrapMode(GLenum mode) void GLTexturePrivate::onDamage() { - if (m_filter == GL_LINEAR_MIPMAP_LINEAR && !m_filterChanged) { - glGenerateMipmap(m_target); - } + // No-op } void GLTexture::setDirty() diff --git a/libkwineffects/kwingltexture.h b/libkwineffects/kwingltexture.h index 34fd8844c2..d559ab0bbe 100644 --- a/libkwineffects/kwingltexture.h +++ b/libkwineffects/kwingltexture.h @@ -101,6 +101,8 @@ public: void setWrapMode(GLenum mode); void setDirty(); + void generateMipmaps(); + static bool framebufferObjectSupported(); protected: