Redo timing of next painting with vsync used, try harder not to miss
every other sync just by a small time. svn path=/trunk/KDE/kdebase/workspace/; revision=806443
This commit is contained in:
parent
8eb8c8c08f
commit
9bd87cb271
2 changed files with 18 additions and 13 deletions
|
@ -175,8 +175,7 @@ void Workspace::setupCompositing()
|
||||||
if( rate <= 0 )
|
if( rate <= 0 )
|
||||||
rate = 50;
|
rate = 50;
|
||||||
// QTimer gives us 1msec (1000Hz) at best, so we ignore anything higher;
|
// QTimer gives us 1msec (1000Hz) at best, so we ignore anything higher;
|
||||||
// however, since compositing is limited to no more than once per 5msec,
|
// however, additional throttling makes prevents very high rates from taking place anyway
|
||||||
// 200Hz to 1000Hz are effectively identical
|
|
||||||
else if( rate > 1000 )
|
else if( rate > 1000 )
|
||||||
rate = 1000;
|
rate = 1000;
|
||||||
kDebug( 1212 ) << "Refresh rate " << rate << "Hz";
|
kDebug( 1212 ) << "Refresh rate " << rate << "Hz";
|
||||||
|
@ -318,15 +317,12 @@ void Workspace::performCompositing()
|
||||||
// clear all repaints, so that post-pass can add repaints for the next repaint
|
// clear all repaints, so that post-pass can add repaints for the next repaint
|
||||||
repaints_region = QRegion();
|
repaints_region = QRegion();
|
||||||
scene->paint( repaints, windows );
|
scene->paint( repaints, windows );
|
||||||
if( scene->waitSyncAvailable() && options->glVSync )
|
if( scene->waitSyncAvailable())
|
||||||
{ // if we're using vsync, then time the next paint pass to
|
{
|
||||||
// before the next available sync
|
// if vsync is used, schedule the next repaint slightly in advance of the next sync,
|
||||||
int paintTime = ( lastCompositePaint.elapsed() % compositeRate ) +
|
// so that there is still time for the drawing to take place
|
||||||
( compositeRate / 2 );
|
int untilNextSync = compositeRate - ( lastCompositePaint.elapsed() % compositeRate );
|
||||||
if( paintTime >= compositeRate )
|
compositeTimer.start( qMax( 1, untilNextSync - 10 )); // 10 ms in advance - TODO maybe less?
|
||||||
compositeTimer.start( paintTime );
|
|
||||||
else if( paintTime < compositeRate )
|
|
||||||
compositeTimer.start( compositeRate - paintTime );
|
|
||||||
}
|
}
|
||||||
lastCompositePaint.start();
|
lastCompositePaint.start();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -145,7 +145,16 @@ SceneOpenGL::SceneOpenGL( Workspace* ws )
|
||||||
if( db )
|
if( db )
|
||||||
glDrawBuffer( GL_BACK );
|
glDrawBuffer( GL_BACK );
|
||||||
// Check whether certain features are supported
|
// Check whether certain features are supported
|
||||||
has_waitSync = glXGetVideoSync ? true : false;
|
has_waitSync = false;
|
||||||
|
if( glXGetVideoSync && glXIsDirect( display(), ctxbuffer ) && options->glVSync )
|
||||||
|
{
|
||||||
|
unsigned int sync;
|
||||||
|
if( glXGetVideoSync( &sync ) == 0 )
|
||||||
|
{
|
||||||
|
if( glXWaitVideoSync( 1, 0, &sync ) == 0 )
|
||||||
|
has_waitSync = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// OpenGL scene setup
|
// OpenGL scene setup
|
||||||
glMatrixMode( GL_PROJECTION );
|
glMatrixMode( GL_PROJECTION );
|
||||||
|
@ -625,7 +634,7 @@ void SceneOpenGL::paint( QRegion damage, ToplevelList toplevels )
|
||||||
// wait for vblank signal before painting
|
// wait for vblank signal before painting
|
||||||
void SceneOpenGL::waitSync()
|
void SceneOpenGL::waitSync()
|
||||||
{ // NOTE that vsync has no effect with indirect rendering
|
{ // NOTE that vsync has no effect with indirect rendering
|
||||||
if( waitSyncAvailable() && options->glVSync )
|
if( waitSyncAvailable())
|
||||||
{
|
{
|
||||||
unsigned int sync;
|
unsigned int sync;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue