Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 05-22-08, 08:02 AM   #1
Žom
Registered User
 
Join Date: May 2008
Posts: 22
Default Sync to VBlank : doesn't work correctly

Hi,

In nvidia-settings, I have enabled Sync to VBlank :


But there are still vertical synchronisation problems : when I move a window horizontally, I have horizontal lines (typically a vsync problem), same problem while playing videos...

I thought first it was a problem in compiz, but it happens even without compiz (metacity).
Several people have exactly the same problem (see my post in French).

How to make the vsync working ?

My problem in French : http://forum.ubuntu-fr.org/viewtopic.php?id=220393
The problem reported in gnome bug report : http://bugzilla.gnome.org/show_bug.cgi?id=534246
(I don't know if VSync problem comes from nvidia or gnome)
Žom is offline   Reply With Quote
Old 05-22-08, 09:03 AM   #2
Žom
Registered User
 
Join Date: May 2008
Posts: 22
Default Re: Sync to VBlank : doesn't work correctly

Some screenshots of the problem :

WITH COMPIZ:


WITHOUT COMPIZ:
Žom is offline   Reply With Quote
Old 05-22-08, 11:35 AM   #3
AaronP
NVIDIA Corporation
 
AaronP's Avatar
 
Join Date: Mar 2005
Posts: 2,487
Default Re: Sync to VBlank : doesn't work correctly

This is a frequently asked question with compiz. The answer is that
  1. OpenGL sync to vblank doesn't affect non-OpenGL rendering.
  2. Sync to vblank only affects glXSwapBuffers, which compiz doesn't use most of the time.
  3. Screenshot programs often don't wait for blank and can capture partial updates.
  4. Compiz tries to use glXWaitVideoSyncSGI to sync to vblank, but that often doesn't work very well because it stalls the CPU.
AaronP is offline   Reply With Quote
Old 05-22-08, 11:57 AM   #4
apaige
Registered User
 
Join Date: Apr 2008
Posts: 106
Default Re: Sync to VBlank : doesn't work correctly

That leaves the question of 2D rendering though. I've always wondered about that. Any way to have some kind of sync to vblank feature for regular 2D windows?
apaige is offline   Reply With Quote
Old 05-22-08, 12:19 PM   #5
AaronP
NVIDIA Corporation
 
AaronP's Avatar
 
Join Date: Mar 2005
Posts: 2,487
Default Re: Sync to VBlank : doesn't work correctly

The main problem is that the X protocol specifies that rendering requests be processed in the order that they're received by the server. If one client fills the command queue with vblank sync requests, it could hold off rendering of all of your other applications for tens of seconds at a time, which is unacceptable. OpenGL doesn't have this problem because it's spec'd to be asynchronous with respect to the X command stream.
AaronP is offline   Reply With Quote
Old 05-24-08, 04:28 AM   #6
Žom
Registered User
 
Join Date: May 2008
Posts: 22
Default Re: Sync to VBlank : doesn't work correctly

Quote:
Originally Posted by AaronP
Sync to vblank only affects glXSwapBuffers, which compiz doesn't use most of the time.
Do you think compiz should call glXSwapBuffers all the time (not only when rotating)?
Žom is offline   Reply With Quote
Old 05-24-08, 01:31 PM   #7
AaronP
NVIDIA Corporation
 
AaronP's Avatar
 
Join Date: Mar 2005
Posts: 2,487
Default Re: Sync to VBlank : doesn't work correctly

That would indeed solve the problem. There may actually be an option to do that, somewhere. The problem is that doing a buffer swap requires compiz to redraw the entire screen every frame. Compiz tries to be clever about only updating parts of the screen that have changed whenever possible.

One thing they could do would be to copy the contents of the front buffer into the back buffer, update what's changed, and then call glXSwapBuffers. Modern GPUs have enough memory bandwidth that the performance impact should be pretty small. I haven't followed compiz development closely enough to know if anyone's tried that.
AaronP is offline   Reply With Quote
Old 05-24-08, 07:38 PM   #8
bearoso
Registered User
 
Join Date: Sep 2003
Posts: 57
Default Re: Sync to VBlank : doesn't work correctly

Quote:
Originally Posted by AaronP
That would indeed solve the problem. There may actually be an option to do that, somewhere. The problem is that doing a buffer swap requires compiz to redraw the entire screen every frame. Compiz tries to be clever about only updating parts of the screen that have changed whenever possible.
I came up with a hack to do just this a long while ago. For anyone interested, it's posted at *edit: see below for updated patch http://www.nvnews.net/vbulletin/show...1&postcount=14

Quote:
One thing they could do would be to copy the contents of the front buffer into the back buffer, update what's changed, and then call glXSwapBuffers. Modern GPUs have enough memory bandwidth that the performance impact should be pretty small. I haven't followed compiz development closely enough to know if anyone's tried that.
I also tried this, but it was surprisingly less effective. Compiz seems to just redraw all the windows using clipping rectangles, not actually culling obscured or non-overlapping windows. This leaves the fill time as the variable, which increases with this method.

Ideally, I think some sort of "synced dirty-rectangles" gl extension would be good for this. Mesa has a CopySubBuffers extension, which compiz uses, but it doesn't do syncing.

*edit* I've attached a working patch to this post.
Attached Files
File Type: txt patch.diff.txt (978 Bytes, 383 views)
bearoso is offline   Reply With Quote

Old 05-25-08, 05:27 AM   #9
Žom
Registered User
 
Join Date: May 2008
Posts: 22
Default Re: Sync to VBlank : doesn't work correctly

Quote:
Originally Posted by AaronP
[*]OpenGL sync to vblank doesn't affect non-OpenGL rendering.
I wonder why without compiz, video playing has no problem of vsync...?
Žom is offline   Reply With Quote
Old 05-25-08, 05:51 AM   #10
Žom
Registered User
 
Join Date: May 2008
Posts: 22
Default Re: Sync to VBlank : doesn't work correctly

bearoso, I would like to try the patch.

Could you explain how to apply the patch?
For the moment, compiz is installed from ubuntu repositories.

I think I should get the sources, then apply the patch and "make", but I need help
Žom is offline   Reply With Quote
Old 05-25-08, 08:20 AM   #11
Žom
Registered User
 
Join Date: May 2008
Posts: 22
Default Re: Sync to VBlank : doesn't work correctly

Quote:
Originally Posted by AaronP
[*]Compiz tries to use glXWaitVideoSyncSGI to sync to vblank, but that often doesn't work very well because it stalls the CPU.
It works quite good for the "desktop" (when nvidia-settings vsync disabled, compiz "detect refresh rate" disabled, and compiz vsync enabled, without aa and anisotropic at 2x).

But while playing videos, there are still vsync problems.

For the "desktop use", I just tried to force antialiasing at 16x and anisotropic at 16x. In that case, with the same settings (nvidia vsync disabled, compiz vsync enabled), there are vsync problems even during rotating the cube (very visible !).
While if I nvidia vsync enabled and compiz vsync disabled, it works while rotating the cube. But not while moving windows...
Žom is offline   Reply With Quote
Old 05-25-08, 11:05 AM   #12
bearoso
Registered User
 
Join Date: Sep 2003
Posts: 57
Default Re: Sync to VBlank : doesn't work correctly

Quote:
Originally Posted by Žom
It works quite good for the "desktop" (when nvidia-settings vsync disabled, compiz "detect refresh rate" disabled, and compiz vsync enabled, without aa and anisotropic at 2x).

But while playing videos, there are still vsync problems.

For the "desktop use", I just tried to force antialiasing at 16x and anisotropic at 16x. In that case, with the same settings (nvidia vsync disabled, compiz vsync enabled), there are vsync problems even during rotating the cube (very visible !).
While if I nvidia vsync enabled and compiz vsync disabled, it works while rotating the cube. But not while moving windows...
The problem with glXWaitVideoSyncSGI is basically that right after it gets the interrupt for vsync, control goes back to the client program, which is interruptible by the scheduler. If you're doing heavy CPU tasks, like video decoding, or the graphics are taking a while to draw, it's more likely compiz will be interrupted several times before it actually manages to update the graphics. It'll inevitably end up drawing after the blanking period is over.

Quote:
Originally Posted by Žom
bearoso, I would like to try the patch.

Could you explain how to apply the patch?
For the moment, compiz is installed from ubuntu repositories.

I think I should get the sources, then apply the patch and "make", but I need help
Yes. You'll need to patch the sources and rebuild. Extract the compiz source, run "patch -p1 < /wherever/patch/is/patch.diff.txt" in the source directory, then "./configure --prefix=/usr ; make ; sudo make install" should do it. Remember to turn on the nvidia vsync and turn off compiz's.

Honestly, if you need help patching the source, you probably won't want to mess with it. I have no clue how Ubuntu manages its compiz package and a manual installation is liable to screw things up.
bearoso is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiseat X with two cards: used to work, now segfaulting Artefact2 NVIDIA Linux 10 06-26-12 05:22 PM
Sync it up: Hands on with the preview of Windows 8's cloud sync service News Archived News Items 0 06-02-12 08:30 PM
295.40 Does not Work Had to downgrade to 295.33 Archmbc NVIDIA Linux 4 05-03-12 02:38 PM
Need help to get the X to work on my Acer TravelMate 630 knchee NVIDIA Linux 16 09-19-02 10:16 PM

All times are GMT -5. The time now is 05:47 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright Š1998 - 2014, nV News.