summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2009-10-05 18:38:17 +0800
committerSam Spilsbury <smspillaz@gmail.com>2009-10-05 18:38:17 +0800
commitf1242a32b5790880bd0a4c4b45cd9fe808f36a35 (patch)
treee9c0793e45fddbc2854a28ae039237c622957f2d
parent547bc2af17f3efd1fac9c5f88c87ff904d7157b3 (diff)
downloadworkarounds-f1242a32b5790880bd0a4c4b45cd9fe808f36a35.tar.gz
workarounds-f1242a32b5790880bd0a4c4b45cd9fe808f36a35.tar.bz2
Add no wait for video sync and force swap buffers (damageScreen on every repaint) options. Use with care
-rw-r--r--src/workarounds.cpp50
-rw-r--r--src/workarounds.h10
-rw-r--r--workarounds.xml.in10
3 files changed, 70 insertions, 0 deletions
diff --git a/src/workarounds.cpp b/src/workarounds.cpp
index eb336ff..ca83673 100644
--- a/src/workarounds.cpp
+++ b/src/workarounds.cpp
@@ -42,6 +42,15 @@ WorkaroundsScreen::checkFunctions (bool checkWindow, bool checkScreen)
gScreen->glPaintOutputSetEnabled (this, false);
}
+ if (haveOpenGL && optionGetForceSwapBuffers () && checkScreen)
+ {
+ cScreen->preparePaintSetEnabled (this, true);
+ }
+ else if (haveOpenGL && checkScreen)
+ {
+ cScreen->preparePaintSetEnabled (this, false);
+ }
+
if ((optionGetLegacyFullscreen () ||
optionGetFirefoxMenuFix () ||
optionGetOooMenuFix () ||
@@ -124,6 +133,33 @@ WorkaroundsScreen::updateParameterFix ()
GL::programEnvParameter4f = origProgramEnvParameter4f;
}
+void
+WorkaroundsScreen::updateVideoSyncFix ()
+{
+ if ((!GL::getVideoSync || origGetVideoSync) ||
+ (!GL::waitVideoSync || origWaitVideoSync))
+ return;
+ if (optionGetNoWaitForVideoSync ())
+ {
+ GL::getVideoSync = NULL;
+ GL::waitVideoSync = NULL;
+ }
+ else
+ {
+ GL::getVideoSync = origGetVideoSync;
+ GL::waitVideoSync = origWaitVideoSync;
+ }
+}
+
+void
+WorkaroundsScreen::preparePaint (int ms)
+{
+ if (optionGetForceSwapBuffers ())
+ cScreen->damageScreen (); // Massive CPU usage here
+
+ cScreen->preparePaint (ms);
+}
+
bool
WorkaroundsScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
const GLMatrix &transform,
@@ -475,6 +511,7 @@ WorkaroundsScreen::optionChanged (CompOption *opt,
if (haveOpenGL)
{
updateParameterFix ();
+ updateVideoSyncFix ();
if (optionGetFglrxXglFix ())
GL::copySubBuffer = NULL;
@@ -595,7 +632,10 @@ WorkaroundsScreen::WorkaroundsScreen (CompScreen *screen) :
{
ScreenInterface::setHandler (screen, false);
if (haveOpenGL)
+ {
+ CompositeScreenInterface::setHandler (cScreen, false);
GLScreenInterface::setHandler (gScreen, false);
+ }
optionSetStickyAlldesktopsNotify (boost::bind (
&WorkaroundsScreen::optionChanged, this,
@@ -611,6 +651,12 @@ WorkaroundsScreen::WorkaroundsScreen (CompScreen *screen) :
optionSetFglrxXglFixNotify (boost::bind (
&WorkaroundsScreen::optionChanged, this,
_1, _2));
+ optionSetForceSwapBuffersNotify (boost::bind (
+ &WorkaroundsScreen::optionChanged, this,
+ _1, _2));
+ optionSetNoWaitForVideoSyncNotify (boost::bind (
+ &WorkaroundsScreen::optionChanged, this,
+ _1, _2));
if (haveOpenGL)
{
@@ -619,7 +665,11 @@ WorkaroundsScreen::WorkaroundsScreen (CompScreen *screen) :
gScreen->getProcAddress ("glProgramEnvParameter4dvARB");
origCopySubBuffer = GL::copySubBuffer;
+ origGetVideoSync = GL::getVideoSync;
+ origWaitVideoSync = GL::waitVideoSync;
+
updateParameterFix ();
+ updateVideoSyncFix ();
}
if (optionGetFglrxXglFix () && haveOpenGL)
diff --git a/src/workarounds.h b/src/workarounds.h
index ff821cc..8f3a665 100644
--- a/src/workarounds.h
+++ b/src/workarounds.h
@@ -45,6 +45,7 @@ class WorkaroundsScreen :
public PluginClassHandler <WorkaroundsScreen, CompScreen>,
public ScreenInterface,
public GLScreenInterface,
+ public CompositeScreenInterface,
public WorkaroundsOptions
{
public:
@@ -61,11 +62,17 @@ class WorkaroundsScreen :
GL::GLProgramParameter4fProc origProgramEnvParameter4f;
GLProgramParameter4dvProc programEnvParameter4dv;
+ GL::GLXGetVideoSyncProc origGetVideoSync;
+ GL::GLXWaitVideoSyncProc origWaitVideoSync;
+
GL::GLXCopySubBufferProc origCopySubBuffer;
void
handleEvent (XEvent *);
+ void
+ preparePaint (int);
+
bool
glPaintOutput (const GLScreenPaintAttrib &,
const GLMatrix &,
@@ -83,6 +90,9 @@ class WorkaroundsScreen :
updateParameterFix ();
void
+ updateVideoSyncFix ();
+
+ void
optionChanged (CompOption *opt,
WorkaroundsOptions::Options num);
diff --git a/workarounds.xml.in b/workarounds.xml.in
index 332959f..aca04b4 100644
--- a/workarounds.xml.in
+++ b/workarounds.xml.in
@@ -67,6 +67,16 @@
<_long>Force synchronization between X and GLX, which may help for window parts not redrawing correctly when using Nvidia drivers, but also may decrease performance.</_long>
<default>false</default>
</option>
+ <option type="bool" name="no_wait_for_video_sync">
+ <_short>Don't wait for video sync</_short>
+ <_long>Don't wait for the next video sync time to redraw</_long>
+ <default>false</default>
+ </option>
+ <option type="bool" name="force_swap_buffers">
+ <_short>Force full screen redraws (buffer swap) on repaint</_short>
+ <_long>Forces the entire screen to redraw every repaint. Use with care, this will cause a massive increase in GPU and CPU usage</_long>
+ <default>false</default>
+ </option>
<subgroup>
<_short>Window stickyness</_short>
<option type="bool" name="sticky_alldesktops">