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>
This commit is contained in:
parent
bcc14954d3
commit
7c791171a1
@ -1052,8 +1052,16 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface)
|
|||||||
// Do we already have a DC entry for that window?
|
// Do we already have a DC entry for that window?
|
||||||
QWindowsWindow *window = static_cast<QWindowsWindow *>(surface);
|
QWindowsWindow *window = static_cast<QWindowsWindow *>(surface);
|
||||||
const HWND hwnd = window->handle();
|
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);
|
return wglMakeCurrent(contextData->hdc, contextData->renderingContext);
|
||||||
|
}
|
||||||
// Create a new entry.
|
// Create a new entry.
|
||||||
const QOpenGLContextData newContext(m_renderingContext, hwnd, GetDC(hwnd));
|
const QOpenGLContextData newContext(m_renderingContext, hwnd, GetDC(hwnd));
|
||||||
if (!newContext.hdc)
|
if (!newContext.hdc)
|
||||||
|
Loading…
Reference in New Issue
Block a user