summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-09-01 11:35:12 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-09-01 11:35:53 +0200
commit2dfc786c26663a2d555a8c8152c5ff95a3b0672e (patch)
treefbf4d41dc1836ffa607e70e2348102066a83855c /src/gui/opengl
parentd444bbf110e83c72d0657203896ad3c8a4cb5107 (diff)
parent1812bb968c49d50745ab2b10787320205c54f946 (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Diffstat (limited to 'src/gui/opengl')
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp76
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp25
-rw-r--r--src/gui/opengl/qopengltextureblitter.cpp14
-rw-r--r--src/gui/opengl/qopengltexturehelper.cpp64
-rw-r--r--src/gui/opengl/qopenglversionfunctions.cpp6
5 files changed, 135 insertions, 50 deletions
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index 43fff1c65a..23861bd778 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -47,6 +47,10 @@
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
+#ifndef GL_FRAMEBUFFER_SRGB_CAPABLE_EXT
+#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
+#endif
+
QT_BEGIN_NAMESPACE
/*!
@@ -360,8 +364,6 @@ static int qt_gl_resolve_extensions()
extensions |= QOpenGLExtensions::BGRATextureFormat;
if (extensionMatcher.match("GL_ARB_texture_rectangle"))
extensions |= QOpenGLExtensions::TextureRectangle;
- if (extensionMatcher.match("GL_SGIS_generate_mipmap"))
- extensions |= QOpenGLExtensions::GenerateMipmap;
if (extensionMatcher.match("GL_ARB_texture_compression"))
extensions |= QOpenGLExtensions::TextureCompression;
if (extensionMatcher.match("GL_EXT_texture_compression_s3tc"))
@@ -385,44 +387,51 @@ static int qt_gl_resolve_extensions()
if (format.majorVersion() >= 2)
extensions |= QOpenGLExtensions::GenerateMipmap;
- if (format.majorVersion() >= 3)
+ if (format.majorVersion() >= 3) {
extensions |= QOpenGLExtensions::PackedDepthStencil
| QOpenGLExtensions::Depth24
| QOpenGLExtensions::ElementIndexUint
- | QOpenGLExtensions::MapBufferRange;
+ | QOpenGLExtensions::MapBufferRange
+ | QOpenGLExtensions::FramebufferBlit
+ | QOpenGLExtensions::FramebufferMultisample;
+ } else {
+ // Recognize features by extension name.
+ if (extensionMatcher.match("GL_OES_packed_depth_stencil"))
+ extensions |= QOpenGLExtensions::PackedDepthStencil;
+ if (extensionMatcher.match("GL_OES_depth24"))
+ extensions |= QOpenGLExtensions::Depth24;
+ if (extensionMatcher.match("GL_ANGLE_framebuffer_blit"))
+ extensions |= QOpenGLExtensions::FramebufferBlit;
+ if (extensionMatcher.match("GL_ANGLE_framebuffer_multisample"))
+ extensions |= QOpenGLExtensions::FramebufferMultisample;
+ if (extensionMatcher.match("GL_NV_framebuffer_blit"))
+ extensions |= QOpenGLExtensions::FramebufferBlit;
+ if (extensionMatcher.match("GL_NV_framebuffer_multisample"))
+ extensions |= QOpenGLExtensions::FramebufferMultisample;
+ }
if (extensionMatcher.match("GL_OES_mapbuffer"))
extensions |= QOpenGLExtensions::MapBuffer;
- if (extensionMatcher.match("GL_OES_packed_depth_stencil"))
- extensions |= QOpenGLExtensions::PackedDepthStencil;
if (extensionMatcher.match("GL_OES_element_index_uint"))
extensions |= QOpenGLExtensions::ElementIndexUint;
- if (extensionMatcher.match("GL_OES_depth24"))
- extensions |= QOpenGLExtensions::Depth24;
- // TODO: Consider matching GL_APPLE_texture_format_BGRA8888 as well, but it needs testing.
+ // We don't match GL_APPLE_texture_format_BGRA8888 here because it has different semantics.
if (extensionMatcher.match("GL_IMG_texture_format_BGRA8888") || extensionMatcher.match("GL_EXT_texture_format_BGRA8888"))
extensions |= QOpenGLExtensions::BGRATextureFormat;
- if (extensionMatcher.match("GL_ANGLE_framebuffer_blit"))
- extensions |= QOpenGLExtensions::FramebufferBlit;
- if (extensionMatcher.match("GL_ANGLE_framebuffer_multisample"))
- extensions |= QOpenGLExtensions::FramebufferMultisample;
- if (extensionMatcher.match("GL_NV_framebuffer_blit"))
- extensions |= QOpenGLExtensions::FramebufferBlit;
- if (extensionMatcher.match("GL_NV_framebuffer_multisample"))
- extensions |= QOpenGLExtensions::FramebufferMultisample;
- if (format.majorVersion() >= 3)
- extensions |= QOpenGLExtensions::FramebufferBlit | QOpenGLExtensions::FramebufferMultisample;
} else {
extensions |= QOpenGLExtensions::ElementIndexUint | QOpenGLExtensions::MapBuffer;
- // Recognize features by extension name.
- if (format.majorVersion() >= 3
- || extensionMatcher.match("GL_ARB_framebuffer_object"))
- {
+ if (format.version() >= qMakePair(1, 2))
+ extensions |= QOpenGLExtensions::BGRATextureFormat;
+
+ if (format.version() >= qMakePair(1, 4) || extensionMatcher.match("GL_SGIS_generate_mipmap"))
+ extensions |= QOpenGLExtensions::GenerateMipmap;
+
+ if (format.majorVersion() >= 3 || extensionMatcher.match("GL_ARB_framebuffer_object")) {
extensions |= QOpenGLExtensions::FramebufferMultisample |
QOpenGLExtensions::FramebufferBlit |
QOpenGLExtensions::PackedDepthStencil;
} else {
+ // Recognize features by extension name.
if (extensionMatcher.match("GL_EXT_framebuffer_multisample"))
extensions |= QOpenGLExtensions::FramebufferMultisample;
if (extensionMatcher.match("GL_EXT_framebuffer_blit"))
@@ -430,21 +439,20 @@ static int qt_gl_resolve_extensions()
if (extensionMatcher.match("GL_EXT_packed_depth_stencil"))
extensions |= QOpenGLExtensions::PackedDepthStencil;
}
+
+ if (format.version() >= qMakePair(3, 2) || extensionMatcher.match("GL_ARB_geometry_shader4"))
+ extensions |= QOpenGLExtensions::GeometryShaders;
+
if (extensionMatcher.match("GL_ARB_map_buffer_range"))
extensions |= QOpenGLExtensions::MapBufferRange;
- }
-
- if (format.renderableType() == QSurfaceFormat::OpenGL && format.version() >= qMakePair(3, 2))
- extensions |= QOpenGLExtensions::GeometryShaders;
-#ifndef QT_OPENGL_ES
- if (extensionMatcher.match("GL_EXT_framebuffer_sRGB")) {
- GLboolean srgbCapableFramebuffers = false;
- ctx->functions()->glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgbCapableFramebuffers);
- if (srgbCapableFramebuffers)
- extensions |= QOpenGLExtensions::SRGBFrameBuffer;
+ if (extensionMatcher.match("GL_EXT_framebuffer_sRGB")) {
+ GLboolean srgbCapableFramebuffers = false;
+ ctx->functions()->glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgbCapableFramebuffers);
+ if (srgbCapableFramebuffers)
+ extensions |= QOpenGLExtensions::SRGBFrameBuffer;
+ }
}
-#endif
return extensions;
}
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index 6e85e5eb4b..8c0b3997fe 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -278,16 +278,27 @@ bool QOpenGLShaderPrivate::compile(QOpenGLShader *q)
"Fragment",
"Vertex",
"Geometry",
+ "Tessellation Control",
+ "Tessellation Evaluation",
+ "Compute",
""
};
- const char *type = types[3];
- if (shaderType == QOpenGLShader::Fragment)
- type = types[0];
- else if (shaderType == QOpenGLShader::Vertex)
- type = types[1];
- else if (shaderType == QOpenGLShader::Geometry)
- type = types[2];
+ const char *type = types[6];
+ switch (shaderType) {
+ case QOpenGLShader::Fragment:
+ type = types[0]; break;
+ case QOpenGLShader::Vertex:
+ type = types[1]; break;
+ case QOpenGLShader::Geometry:
+ type = types[2]; break;
+ case QOpenGLShader::TessellationControl:
+ type = types[3]; break;
+ case QOpenGLShader::TessellationEvaluation:
+ type = types[4]; break;
+ case QOpenGLShader::Compute:
+ type = types[5]; break;
+ }
// Get info and source code lengths
GLint infoLogLength = 0;
diff --git a/src/gui/opengl/qopengltextureblitter.cpp b/src/gui/opengl/qopengltextureblitter.cpp
index ef548188c8..ebe0429290 100644
--- a/src/gui/opengl/qopengltextureblitter.cpp
+++ b/src/gui/opengl/qopengltextureblitter.cpp
@@ -248,9 +248,6 @@ bool QOpenGLTextureBlitter::create()
Q_D(QOpenGLTextureBlitter);
- d->vao->create();
- d->vao->bind();
-
if (d->program)
return true;
@@ -273,6 +270,9 @@ bool QOpenGLTextureBlitter::create()
d->program->bind();
+ // Create and bind the VAO, if supported.
+ QOpenGLVertexArrayObject::Binder vaoBinder(d->vao.data());
+
d->vertexBuffer.create();
d->vertexBuffer.bind();
d->vertexBuffer.allocate(vertex_buffer_data, sizeof(vertex_buffer_data));
@@ -292,8 +292,6 @@ bool QOpenGLTextureBlitter::create()
d->program->setUniformValue(d->swizzleUniformPos,false);
- d->vao->release();
-
return true;
}
@@ -316,7 +314,8 @@ void QOpenGLTextureBlitter::bind()
{
Q_D(QOpenGLTextureBlitter);
- d->vao->bind();
+ if (d->vao->isCreated())
+ d->vao->bind();
d->program->bind();
@@ -335,7 +334,8 @@ void QOpenGLTextureBlitter::release()
{
Q_D(QOpenGLTextureBlitter);
d->program->release();
- d->vao->release();
+ if (d->vao->isCreated())
+ d->vao->release();
}
void QOpenGLTextureBlitter::setSwizzleRB(bool swizzle)
diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp
index 27aece8eca..9cb5e8798e 100644
--- a/src/gui/opengl/qopengltexturehelper.cpp
+++ b/src/gui/opengl/qopengltexturehelper.cpp
@@ -164,6 +164,60 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
TexSubImage2D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLint , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *)>(GetProcAddress(handle, QByteArrayLiteral("glTexSubImage2D")));
TexSubImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *)>(GetProcAddress(handle, QByteArrayLiteral("glTexSubImage1D")));
+#elif defined(QT_OPENGL_ES_2)
+ // Here we are targeting OpenGL ES 2.0+ only. This is likely using EGL, where,
+ // similarly to WGL, non-extension functions (i.e. any function that is part of the
+ // GLES spec) *may* not be queried via eglGetProcAddress.
+
+ // OpenGL 1.0
+ GetIntegerv = ::glGetIntegerv;
+ GetBooleanv = ::glGetBooleanv;
+ PixelStorei = ::glPixelStorei;
+ GetTexLevelParameteriv = 0;
+ GetTexLevelParameterfv = 0;
+ GetTexParameteriv = ::glGetTexParameteriv;
+ GetTexParameterfv = ::glGetTexParameterfv;
+ GetTexImage = 0;
+ TexImage2D = ::glTexImage2D;
+ TexImage1D = 0;
+ TexParameteriv = ::glTexParameteriv;
+ TexParameteri = ::glTexParameteri;
+ TexParameterfv = ::glTexParameterfv;
+ TexParameterf = ::glTexParameterf;
+
+ // OpenGL 1.1
+ GenTextures = ::glGenTextures;
+ DeleteTextures = ::glDeleteTextures;
+ BindTexture = ::glBindTexture;
+ TexSubImage2D = ::glTexSubImage2D;
+ TexSubImage1D = 0;
+
+ // OpenGL 1.3
+ GetCompressedTexImage = 0;
+ CompressedTexSubImage1D = 0;
+ CompressedTexSubImage2D = ::glCompressedTexSubImage2D;
+ CompressedTexImage1D = 0;
+ CompressedTexImage2D = ::glCompressedTexImage2D;
+ ActiveTexture = ::glActiveTexture;
+
+ // OpenGL 3.0
+ GenerateMipmap = ::glGenerateMipmap;
+
+ // OpenGL 3.2
+ TexImage3DMultisample = 0;
+ TexImage2DMultisample = 0;
+
+ // OpenGL 4.2
+ TexStorage3D = 0;
+ TexStorage2D = 0;
+ TexStorage1D = 0;
+
+ // OpenGL 4.3
+ TexStorage3DMultisample = 0;
+ TexStorage2DMultisample = 0;
+ TexBufferRange = 0;
+ TextureView = 0;
+
#else
// OpenGL 1.0
@@ -196,6 +250,13 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
CompressedTexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3DOES")));
CompressedTexSubImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3DOES")));
} else {
+#ifdef QT_OPENGL_ES_3
+ // OpenGL ES 3.0+ has glTexImage3D.
+ TexImage3D = ::glTexImage3D;
+ TexSubImage3D = ::glTexSubImage3D;
+ CompressedTexImage3D = ::glCompressedTexImage3D;
+ CompressedTexSubImage3D = ::glCompressedTexSubImage3D;
+#else
// OpenGL 1.2
TexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLsizei , GLsizei , GLint , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexImage3D")));
TexSubImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexSubImage3D")));
@@ -203,8 +264,10 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
// OpenGL 1.3
CompressedTexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLenum , GLsizei , GLsizei , GLsizei , GLint , GLsizei , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3D")));
CompressedTexSubImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLint , GLint , GLsizei , GLsizei , GLsizei , GLenum , GLsizei , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage3D")));
+#endif
}
+#ifndef QT_OPENGL_ES_2
// OpenGL 1.3
GetCompressedTexImage = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glGetCompressedTexImage")));
CompressedTexSubImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLenum , GLsizei , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexSubImage1D")));
@@ -230,6 +293,7 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
TexStorage2DMultisample = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLsizei , GLenum , GLsizei , GLsizei , GLboolean )>(context->getProcAddress(QByteArrayLiteral("glTexStorage2DMultisample")));
TexBufferRange = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLuint , GLintptr , GLsizeiptr )>(context->getProcAddress(QByteArrayLiteral("glTexBufferRange")));
TextureView = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint , GLenum , GLuint , GLuint , GLuint , GLuint )>(context->getProcAddress(QByteArrayLiteral("glTextureView")));
+#endif
}
void QOpenGLTextureHelper::dsa_TextureParameteri(GLuint texture, GLenum target, GLenum bindingTarget, GLenum pname, GLint param)
diff --git a/src/gui/opengl/qopenglversionfunctions.cpp b/src/gui/opengl/qopenglversionfunctions.cpp
index 3335a88cbb..f5ce8865a8 100644
--- a/src/gui/opengl/qopenglversionfunctions.cpp
+++ b/src/gui/opengl/qopenglversionfunctions.cpp
@@ -98,8 +98,10 @@ void QAbstractOpenGLFunctionsPrivate::removeFunctionsBackend(QOpenGLContext *con
Qt now provides a family of classes which all inherit from
QAbstractOpenGLFunctions which expose every core OpenGL function by way of a
corresponding member function. There is a class for every valid combination
- of OpenGL version and profile. Each class follows the naming convention
- QOpenGLFunctions_<MAJOR VERSION>_<MINOR VERSION>[_PROFILE].
+ of OpenGL version and profile. Each class follows the naming convention:
+ \badcode
+ QOpenGLFunctions_<MAJOR VERSION>_<MINOR VERSION>[_PROFILE]
+ \endcode
For OpenGL versions 1.0 through to 3.0 there are no profiles, leading to the
classes: