From 812e23cea2d746641a57c697c2494e8db96fca34 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 1 Aug 2013 13:37:21 +0200 Subject: Bypass eglMakeCurrent where possible. This has the possibility to be very slow on some GPUs. A nicer alternative would have been to fix this in QOpenGLContext, but with makeCurrent and updateContext having been merged in Qt 5, makeCurrent is required every frame call, and thus cannot be fixed there. Change-Id: Ib17dbb3a1e4e89c60dfd4f12a55eeff353f9075f Done-with: Carsten Munk Reviewed-by: Gunnar Sletta --- src/platformsupport/eglconvenience/qeglplatformcontext.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/platformsupport/eglconvenience') diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 8152f74067..34ba21afdc 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -106,6 +106,14 @@ bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface) EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface); + // shortcut: on some GPUs, eglMakeCurrent is not a cheap operation + if (eglGetCurrentContext() == m_eglContext && + eglGetCurrentDisplay() == m_eglDisplay && + eglGetCurrentSurface(EGL_READ) == eglSurface && + eglGetCurrentSurface(EGL_DRAW) == eglSurface) { + return true; + } + bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext); if (!ok) qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this); -- cgit v1.2.3