From f46d7a99bc2f3bc70f274422ec8d16257e2a97aa Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Sat, 13 Aug 2011 16:07:08 +0200 Subject: [PATCH] ati: limit glxSwapBuffers going to far ahead --- xbmc/windowing/X11/WinSystemX11GL.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11GL.cpp b/xbmc/windowing/X11/WinSystemX11GL.cpp index 94f369eb58cd0..870999ea321cb 100644 --- a/xbmc/windowing/X11/WinSystemX11GL.cpp +++ b/xbmc/windowing/X11/WinSystemX11GL.cpp @@ -43,7 +43,27 @@ CWinSystemX11GL::~CWinSystemX11GL() bool CWinSystemX11GL::PresentRenderImpl(const CDirtyRegionList& dirty) { - if(m_iVSyncMode == 3) + if(m_iVSyncMode == 2) + { + static unsigned int last = 0; + unsigned int now; + if(m_glXGetVideoSyncSGI(&now) != 0) + CLog::Log(LOGERROR, "%s - glXGetVideoSyncSGI - Failed to get current retrace count", __FUNCTION__); + + if (now == last) + { + if (m_glXWaitVideoSyncSGI(2, (last + 1) % 2, &now) != 0) + CLog::Log(LOGERROR, "%s - glXWaitVideoSyncSGI - Returned error", __FUNCTION__); + if(m_glXGetVideoSyncSGI(&now) != 0) + CLog::Log(LOGERROR, "%s - glXGetVideoSyncSGI - Failed to get current retrace count", __FUNCTION__); + last = now + 1; + } + else + last = now; + + glXSwapBuffers(m_dpy, m_glWindow); + } + else if(m_iVSyncMode == 3) { glFinish(); unsigned int before = 0, after = 0; @@ -236,7 +256,6 @@ bool CWinSystemX11GL::CreateNewWindow(const CStdString& name, bool fullScreen, R else m_glXSwapIntervalMESA = NULL; - return true; }