summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopenglfunctions.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-06-13 16:36:27 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-08-08 07:29:53 +0200
commitbb760d9514ed617ee8e7344152b3fa697b2c4171 (patch)
treeff80c5cff36421c1c17bdc86f5349da6194aefa2 /src/gui/opengl/qopenglfunctions.cpp
parent22e439141384f49028770d2410fafb18ef8cad1f (diff)
Add support for glMapBufferRange in the wrappers and resolvers
QOpenGLBuffer::map() and related helpers are becoming useless in OpenGL ES 3.0 and up: instead of the old GL_OES_map_buffer, glMapBufferRange, but not glMapBuffer, is now part of the standard. On desktop GL_ARB_map_buffer_range is present by default in OpenGL 3.0 and newer. [ChangeLog][QtGui] Added QOpenGLBuffer::mapBufferRange(). Task-number: QTBUG-38168 Change-Id: I4e9bbe8ced9ee4d535ac32849a8c08c26d79cb49 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/gui/opengl/qopenglfunctions.cpp')
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index 877cc6864d..43fff1c65a 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -388,7 +388,8 @@ static int qt_gl_resolve_extensions()
if (format.majorVersion() >= 3)
extensions |= QOpenGLExtensions::PackedDepthStencil
| QOpenGLExtensions::Depth24
- | QOpenGLExtensions::ElementIndexUint;
+ | QOpenGLExtensions::ElementIndexUint
+ | QOpenGLExtensions::MapBufferRange;
if (extensionMatcher.match("GL_OES_mapbuffer"))
extensions |= QOpenGLExtensions::MapBuffer;
@@ -429,6 +430,8 @@ static int qt_gl_resolve_extensions()
if (extensionMatcher.match("GL_EXT_packed_depth_stencil"))
extensions |= QOpenGLExtensions::PackedDepthStencil;
}
+ if (extensionMatcher.match("GL_ARB_map_buffer_range"))
+ extensions |= QOpenGLExtensions::MapBufferRange;
}
if (format.renderableType() == QSurfaceFormat::OpenGL && format.version() >= qMakePair(3, 2))
@@ -3182,11 +3185,36 @@ static void QOPENGLF_APIENTRY qopenglfResolveVertexAttribPointer(GLuint indx, GL
static GLvoid *QOPENGLF_APIENTRY qopenglfResolveMapBuffer(GLenum target, GLenum access)
{
+#ifdef QT_OPENGL_ES_3
+ // It is possible that GL_OES_map_buffer is present, but then having to
+ // differentiate between glUnmapBufferOES and glUnmapBuffer causes extra
+ // headache. QOpenGLBuffer::map() will handle this automatically, while direct
+ // calls are better off with migrating to the standard glMapBufferRange.
+ if (QOpenGLContext::currentContext()->format().majorVersion() >= 3) {
+ qWarning("QOpenGLFunctions: glMapBuffer is not available in OpenGL ES 3.0 and up. Use glMapBufferRange instead.");
+ return 0;
+ } else
+#endif
RESOLVE_FUNC(GLvoid *, ResolveOES, MapBuffer)(target, access);
}
+static GLvoid *QOPENGLF_APIENTRY qopenglfResolveMapBufferRange(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr length, GLbitfield access)
+{
+#ifdef QT_OPENGL_ES_3
+ if (QOpenGLContext::currentContext()->format().majorVersion() >= 3)
+ return ::glMapBufferRange(target, offset, length, access);
+ else
+#endif
+ RESOLVE_FUNC(GLvoid *, 0, MapBufferRange)(target, offset, length, access);
+}
+
static GLboolean QOPENGLF_APIENTRY qopenglfResolveUnmapBuffer(GLenum target)
{
+#ifdef QT_OPENGL_ES_3
+ if (QOpenGLContext::currentContext()->format().majorVersion() >= 3)
+ return ::glUnmapBuffer(target);
+ else
+#endif
RESOLVE_FUNC(GLboolean, ResolveOES, UnmapBuffer)(target);
}
@@ -3455,6 +3483,7 @@ QOpenGLExtensionsPrivate::QOpenGLExtensionsPrivate(QOpenGLContext *ctx)
: QOpenGLFunctionsPrivate(ctx)
{
MapBuffer = qopenglfResolveMapBuffer;
+ MapBufferRange = qopenglfResolveMapBufferRange;
UnmapBuffer = qopenglfResolveUnmapBuffer;
BlitFramebuffer = qopenglfResolveBlitFramebuffer;
RenderbufferStorageMultisample = qopenglfResolveRenderbufferStorageMultisample;