From 50e3e909dadf37ffaa5cbe75b528ba458af207cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Tue, 23 Jul 2013 22:34:41 +0200 Subject: [PATCH] prevent yield/swap cpu overhead on nvidia CCBUG: 322060 REVIEW: 111663 --- eglonxbackend.cpp | 12 ++++++++++++ glxbackend.cpp | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/eglonxbackend.cpp b/eglonxbackend.cpp index cc5df0d2d7..86c763eb08 100644 --- a/eglonxbackend.cpp +++ b/eglonxbackend.cpp @@ -277,6 +277,18 @@ void EglOnXBackend::present() eglWaitGL(); if (char result = m_swapProfiler.end()) { gs_tripleBufferUndetected = gs_tripleBufferNeedsDetection = false; + if (result == 'd' && GLPlatform::instance()->driver() == Driver_NVidia) { + // TODO this is a workaround, we should get __GL_YIELD set before libGL checks it + if (qstrcmp(qgetenv("__GL_YIELD"), "USLEEP")) { + options->setGlPreferBufferSwap(0); + eglSwapInterval(dpy, 0); + kWarning(1212) << "\nIt seems you are using the nvidia driver without triple buffering\n" + "You must export __GL_YIELD=\"USLEEP\" to prevent large CPU overhead on synced swaps\n" + "Preferably, enable the TripleBuffer Option in the xorg.conf Device\n" + "For this reason, the tearing prevention has been disabled.\n" + "See https://bugs.kde.org/show_bug.cgi?id=322060\n"; + } + } setBlocksForRetrace(result == 'd'); } } diff --git a/glxbackend.cpp b/glxbackend.cpp index 773bb91886..7f2449cfe4 100644 --- a/glxbackend.cpp +++ b/glxbackend.cpp @@ -432,6 +432,18 @@ void GlxBackend::present() glXWaitGL(); if (char result = m_swapProfiler.end()) { gs_tripleBufferUndetected = gs_tripleBufferNeedsDetection = false; + if (result == 'd' && GLPlatform::instance()->driver() == Driver_NVidia) { + // TODO this is a workaround, we should get __GL_YIELD set before libGL checks it + if (qstrcmp(qgetenv("__GL_YIELD"), "USLEEP")) { + options->setGlPreferBufferSwap(0); + setSwapInterval(0); + kWarning(1212) << "\nIt seems you are using the nvidia driver without triple buffering\n" + "You must export __GL_YIELD=\"USLEEP\" to prevent large CPU overhead on synced swaps\n" + "Preferably, enable the TripleBuffer Option in the xorg.conf Device\n" + "For this reason, the tearing prevention has been disabled.\n" + "See https://bugs.kde.org/show_bug.cgi?id=322060\n"; + } + } setBlocksForRetrace(result == 'd'); } }