diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-04-17 08:38:19 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-18 07:09:09 +0200 |
commit | 7c791171a15c9192f4b025a810dde11b7dae2e51 (patch) | |
tree | bfc20218a0d5b5366d288534f2af7791aa795f57 | |
parent | bcc14954d3f13f3d32ab974344d243b175a162e1 (diff) |
Calling wglMakeCurrent on an already current context gives 100% cpu load
The problem occurs at least with nvidia cards when vsync is enabled
in the control panel.
Task-number: QTBUG-29686
Change-Id: I6fd2a3560a5baeeac7c3fe0440db85904c45026d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
-rw-r--r-- | src/plugins/platforms/windows/qwindowsglcontext.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index da3e2a6a6a..ae66ef8a3d 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -1052,8 +1052,16 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface) // Do we already have a DC entry for that window? QWindowsWindow *window = static_cast<QWindowsWindow *>(surface); const HWND hwnd = window->handle(); - if (const QOpenGLContextData *contextData = findByHWND(m_windowContexts, hwnd)) + if (const QOpenGLContextData *contextData = findByHWND(m_windowContexts, hwnd)) { + // Repeated calls to wglMakeCurrent when vsync is enabled in the driver will + // often result in 100% cpuload. This check is cheap and avoids the problem. + // This is reproducable on NVidia cards and Intel onboard chips. + if (wglGetCurrentContext() == contextData->renderingContext + && wglGetCurrentDC() == contextData->hdc) { + return true; + } return wglMakeCurrent(contextData->hdc, contextData->renderingContext); + } // Create a new entry. const QOpenGLContextData newContext(m_renderingContext, hwnd, GetDC(hwnd)); if (!newContext.hdc) |