Skip to content

Commit

Permalink
videorefclock: try polling for nvidia
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Mar 26, 2012
1 parent df5eef2 commit 1b97e79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
23 changes: 17 additions & 6 deletions xbmc/video/VideoReferenceClock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ void CVideoReferenceClock::Process()
m_RefreshChanged = 0;
m_Started.Set();

SetPriority(1);

if (SetupSuccess)
{
m_UseVblank = true; //tell other threads we're using vblank as clock
Expand Down Expand Up @@ -270,12 +272,21 @@ bool CVideoReferenceClock::SetupGLX()
return false;
}

m_bIsATI = false;
m_bPolling = false;

CStdString Vendor = g_Windowing.GetRenderVendor();
Vendor.ToLower();
if (Vendor.compare(0, 3, "ati") == 0)
{
CLog::Log(LOGDEBUG, "CVideoReferenceClock: GL_VENDOR: %s, using ati workaround", Vendor.c_str());
m_bIsATI = true;
m_bPolling = true;
}
else if (Vendor.compare(0, 6, "nvidia") == 0)
{
CLog::Log(LOGDEBUG, "CVideoReferenceClock: GL_VENDOR: %s, use polling", Vendor.c_str());
m_bPolling = true;
}

m_vInfo = glXChooseVisual(m_Dpy, DefaultScreen(m_Dpy), singleBufferAttributes);
Expand All @@ -285,7 +296,7 @@ bool CVideoReferenceClock::SetupGLX()
return false;
}

if (!m_bIsATI)
if (!m_bPolling)
{
Swa.border_pixel = 0;
Swa.event_mask = StructureNotifyMask;
Expand Down Expand Up @@ -313,7 +324,7 @@ bool CVideoReferenceClock::SetupGLX()
return false;
}

if (!m_bIsATI)
if (!m_bPolling)
ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context);
else
ReturnV = glXMakeCurrent(m_Dpy, m_glPixmap, m_Context);
Expand All @@ -324,7 +335,7 @@ bool CVideoReferenceClock::SetupGLX()
return false;
}

if (!m_bIsATI)
if (!m_bPolling)
{
m_glXWaitVideoSyncSGI = (int (*)(int, int, unsigned int*))glXGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI");
if (!m_glXWaitVideoSyncSGI)
Expand Down Expand Up @@ -567,7 +578,7 @@ void CVideoReferenceClock::RunGLX()
while(!m_bStop)
{
//wait for the next vblank
if (!m_bIsATI)
if (!m_bPolling)
{
ReturnV = m_glXWaitVideoSyncSGI(2, (VblankCount + 1) % 2, &VblankCount);
m_glXGetVideoSyncSGI(&VblankCount); //the vblank count returned by glXWaitVideoSyncSGI is not always correct
Expand All @@ -591,7 +602,7 @@ void CVideoReferenceClock::RunGLX()
sleepTime = std::max(int(300000LL/m_RefreshRate), sleepTime);

unsigned int iterations = 0;
while (VblankCount == PrevVblankCount && !m_bStop)
while (VblankCount == PrevVblankCount && iterations < 500 && !m_bStop)
{
usleep(sleepTime);
m_glXGetVideoSyncSGI(&VblankCount);
Expand Down Expand Up @@ -652,7 +663,7 @@ void CVideoReferenceClock::RunGLX()
}

CLog::Log(LOGDEBUG, "CVideoReferenceClock: Attaching glX context");
if (!m_bIsATI)
if (!m_bPolling)
ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context);
else
ReturnV = glXMakeCurrent(m_Dpy, m_glPixmap, m_Context);
Expand Down
1 change: 1 addition & 0 deletions xbmc/video/VideoReferenceClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class CVideoReferenceClock : public CThread

bool m_UseNvSettings;
bool m_bIsATI;
bool m_bPolling;

#elif defined(_WIN32) && defined(HAS_DX)
bool SetupD3D();
Expand Down

0 comments on commit 1b97e79

Please sign in to comment.