Pass a sized format when creating multisampled renderbuffers on ES

Task-number: QTBUG-40921
Change-Id: I96b05442dd5928992dab06553b3d41feca89084d
Reviewed-by: BogDan Vatra <bogdan@kde.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Laszlo Agocs 2014-10-03 09:50:19 +02:00
parent 54814bbd8f
commit 1a801e0eef
3 changed files with 18 additions and 15 deletions

View File

@ -80,7 +80,8 @@ public:
SRGBFrameBuffer = 0x00020000, SRGBFrameBuffer = 0x00020000,
MapBuffer = 0x00040000, MapBuffer = 0x00040000,
GeometryShaders = 0x00080000, GeometryShaders = 0x00080000,
MapBufferRange = 0x00100000 MapBufferRange = 0x00100000,
Sized8Formats = 0x00200000
}; };
Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension) Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension)

View File

@ -452,13 +452,7 @@ void QOpenGLFramebufferObjectPrivate::init(QOpenGLFramebufferObject *, const QSi
if (!funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample) if (!funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
|| !funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)) { || !funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)) {
samples = 0; samples = 0;
} } else if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
// On GLES 2.0 multisampled framebuffers are available through vendor-specific extensions
const bool msaaES2 = ctx->isOpenGLES() && (ctx->hasExtension("GL_ANGLE_framebuffer_multisample")
|| ctx->hasExtension("GL_NV_framebuffer_multisample"));
if (!ctx->isOpenGLES() || msaaES2) {
GLint maxSamples; GLint maxSamples;
funcs.glGetIntegerv(GL_MAX_SAMPLES, &maxSamples); funcs.glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
samples = qBound(0, int(samples), int(maxSamples)); samples = qBound(0, int(samples), int(maxSamples));
@ -483,11 +477,15 @@ void QOpenGLFramebufferObjectPrivate::init(QOpenGLFramebufferObject *, const QSi
initTexture(texture_target, internal_format, size, mipmap); initTexture(texture_target, internal_format, size, mipmap);
} else { } else {
GLenum storageFormat = internal_format; GLenum storageFormat = internal_format;
// ES requires a sized format. The older desktop extension does not. Correct the format on ES.
if (ctx->isOpenGLES() && internal_format == GL_RGBA) {
#ifdef GL_RGBA8_OES #ifdef GL_RGBA8_OES
// Correct the internal format used by the render buffer when using ES with extensions if (funcs.hasOpenGLExtension(QOpenGLExtensions::Sized8Formats))
if (msaaES2 && internal_format == GL_RGBA) storageFormat = GL_RGBA8_OES;
storageFormat = GL_RGBA8_OES; else
#endif #endif
storageFormat = GL_RGBA4;
}
mipmap = false; mipmap = false;
funcs.glGenRenderbuffers(1, &color_buffer); funcs.glGenRenderbuffers(1, &color_buffer);

View File

@ -385,7 +385,8 @@ static int qt_gl_resolve_extensions()
| QOpenGLExtensions::ElementIndexUint | QOpenGLExtensions::ElementIndexUint
| QOpenGLExtensions::MapBufferRange | QOpenGLExtensions::MapBufferRange
| QOpenGLExtensions::FramebufferBlit | QOpenGLExtensions::FramebufferBlit
| QOpenGLExtensions::FramebufferMultisample; | QOpenGLExtensions::FramebufferMultisample
| QOpenGLExtensions::Sized8Formats;
} else { } else {
// Recognize features by extension name. // Recognize features by extension name.
if (extensionMatcher.match("GL_OES_packed_depth_stencil")) if (extensionMatcher.match("GL_OES_packed_depth_stencil"))
@ -400,6 +401,8 @@ static int qt_gl_resolve_extensions()
extensions |= QOpenGLExtensions::FramebufferBlit; extensions |= QOpenGLExtensions::FramebufferBlit;
if (extensionMatcher.match("GL_NV_framebuffer_multisample")) if (extensionMatcher.match("GL_NV_framebuffer_multisample"))
extensions |= QOpenGLExtensions::FramebufferMultisample; extensions |= QOpenGLExtensions::FramebufferMultisample;
if (extensionMatcher.match("GL_OES_rgb8_rgba8"))
extensions |= QOpenGLExtensions::Sized8Formats;
} }
if (extensionMatcher.match("GL_OES_mapbuffer")) if (extensionMatcher.match("GL_OES_mapbuffer"))
@ -419,9 +422,10 @@ static int qt_gl_resolve_extensions()
extensions |= QOpenGLExtensions::GenerateMipmap; extensions |= QOpenGLExtensions::GenerateMipmap;
if (format.majorVersion() >= 3 || extensionMatcher.match("GL_ARB_framebuffer_object")) { if (format.majorVersion() >= 3 || extensionMatcher.match("GL_ARB_framebuffer_object")) {
extensions |= QOpenGLExtensions::FramebufferMultisample | extensions |= QOpenGLExtensions::FramebufferMultisample
QOpenGLExtensions::FramebufferBlit | | QOpenGLExtensions::FramebufferBlit
QOpenGLExtensions::PackedDepthStencil; | QOpenGLExtensions::PackedDepthStencil
| QOpenGLExtensions::Sized8Formats;
} else { } else {
// Recognize features by extension name. // Recognize features by extension name.
if (extensionMatcher.match("GL_EXT_framebuffer_multisample")) if (extensionMatcher.match("GL_EXT_framebuffer_multisample"))