From 1d7471d93b4463657f2721074f2a63a12ea18752 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 3 Jul 2012 16:05:13 +0200 Subject: [PATCH] Let ShaderEffectSource use same multisample count as GL context. Change-Id: I9b772a2c405c2fab13dfee3527212117de16e9c0 Reviewed-by: Gunnar Sletta --- src/quick/items/qquickshadereffectsource.cpp | 18 +++++++++++------- src/quick/items/qquickshadereffectsource_p.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp index 71a0aaf..3f36c86 100644 --- a/src/quick/items/qquickshadereffectsource.cpp +++ b/src/quick/items/qquickshadereffectsource.cpp @@ -140,7 +140,7 @@ QQuickShaderEffectTexture::QQuickShaderEffectTexture(QQuickItem *shaderSource) , m_live(true) , m_recursive(false) , m_dirtyTexture(true) - , m_multisamplingSupportChecked(false) + , m_multisamplingChecked(false) , m_multisampling(false) , m_grab(false) { @@ -316,11 +316,15 @@ void QQuickShaderEffectTexture::grab() if (!m_fbo || m_fbo->size() != m_size || m_fbo->format().internalTextureFormat() != m_format || (!m_fbo->format().mipmap() && m_mipmap)) { - if (!m_multisamplingSupportChecked) { - QList extensions = QByteArray((const char *)glGetString(GL_EXTENSIONS)).split(' '); - m_multisampling = extensions.contains("GL_EXT_framebuffer_multisample") - && extensions.contains("GL_EXT_framebuffer_blit"); - m_multisamplingSupportChecked = true; + if (!m_multisamplingChecked) { + if (m_context->glContext()->format().samples() <= 1) { + m_multisampling = false; + } else { + QList extensions = QByteArray((const char *)glGetString(GL_EXTENSIONS)).split(' '); + m_multisampling = extensions.contains("GL_EXT_framebuffer_multisample") + && extensions.contains("GL_EXT_framebuffer_blit"); + } + m_multisamplingChecked = true; } if (m_multisampling) { // Don't delete the FBO right away in case it is used recursively. @@ -329,7 +333,7 @@ void QQuickShaderEffectTexture::grab() QOpenGLFramebufferObjectFormat format; format.setInternalTextureFormat(m_format); - format.setSamples(8); + format.setSamples(m_context->glContext()->format().samples()); m_secondaryFbo = new QOpenGLFramebufferObject(m_size, format); m_depthStencilBuffer = m_context->depthStencilBufferForFbo(m_secondaryFbo); } else { diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h index 3fae06f..7c339a2 100644 --- a/src/quick/items/qquickshadereffectsource_p.h +++ b/src/quick/items/qquickshadereffectsource_p.h @@ -147,7 +147,7 @@ private: uint m_live : 1; uint m_recursive : 1; uint m_dirtyTexture : 1; - uint m_multisamplingSupportChecked : 1; + uint m_multisamplingChecked : 1; uint m_multisampling : 1; uint m_grab : 1; }; -- 2.7.4