nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   NVIDIA Linux (http://www.nvnews.net/vbulletin/forumdisplay.php?f=14)
-   -   VSYNC <-> tearing: summary of the situation ? (http://www.nvnews.net/vbulletin/showthread.php?t=85301)

cdufour 01-30-07 05:41 AM

VSYNC <-> tearing: summary of the situation ?
 
Hello,

Like others, I'm experiencing the "tearing" problem (horizontal "split" lines on high-motion video, including fast moving-around of windows) with my 7600GS and 1.0.9746 drivers (under FC6, Xorg 7.1.1 and KDE 3.5.5, to 1024x768 LCD VGA-conntected (non-DVI) projector).

Now, extensively going through the docs, Google, and this forum, I'm completely at a loss at what to do when/how...

To summarize it all:
- there is an environment variable __GL_SYNC_TO_VBLANK that affects nVidia driver...
- that may not be desirable to set in some situation (like when using "compositors"; i.e. Option "Composite" ??? )...
- which may be overriden with some XV_SYNC_TO_VBLANK variables set by some player (e.g. Mplayer/Xine)...
- or by nvidia-settings...
- but not knowing which X extensions (Xv, XvMC, OpenGL) gets affected by it...
I'M LOST !!!
(I'm currently at the point of trying all the possible combinations of this various settings, until I find the one that solves this "tearing" issue)

Is there any place I can find a "summary of the situation" (or "anti-tearing" howto), pouring light into my clouded thoughts ? :-D

Or could someone help (me) writing this kind of "howto" (by pointing me in the right direction in regards on how this entire Sync-to-VBlank works with nVidia drivers; see above "summary") ?

Maybe a list of short questions (and their answers) could help us:
- has the choice of the driver/extension used (Xv, XvMC, OpenGL, etc) any importance in regards with Sync-to-VBlank ? (I *would* say it should not, if I want to get rid of "tearing" when moving anything around in the Window manager)
- does the __GL_SYNC_TO_VBLANK environment variable affects all video rendering from the nVidia driver ? Or does it require to use the OpenGL driver/extension ?
- should 'nvidia-settings' then be used to enable Xv's Sync-to-VBlank (and does it affect XvMC) ?
- has the Xorg's "Composite" extension any influence on whether to enable Sync-to-Vblank or not ?
- AaronP mentions that "9629 and the new beta should now ignore sync-to-vblank for redirected windows." (http://www.nvnews.net/vbulletin/show...light=tearing). Does that mean that we should be able to rely on __GL_SYNC_... and 'nvidia-settings' ?
- Any other clue ?

Thank you for your answers ;-)

Cheers to all (and thank you for supporting the Linux community as well as you do) !

Cédric

cdufour 01-31-07 05:31 AM

Re: VSYNC <-> tearing: summary of the situation !!!
 
Hello again,

After much playing around overnight, here are some clues for those who experience "tearing".

OpenGL perspective
The __GL_SYNC_TO_VBLANK environment variable affects "opengl" drivers/extensions only. Every OpenGL application launched AFTER it has been set (export __GL_SYNC_TO_VBLANK=1) will VSYNC to the chosen "screen". In other words, FPS (Frames per second) will equal the screen's refresh rate.

Troubleshoot/verify:
Use 'glxgears'. This tiny executable displays OpenGL-achieved rotating gears in a window, while showing the achieved FPS in the terminal window. On my machine, 'glxgears' achieves FPS between 1500 and 7000 (depending of the display window size) if VSYNC is disabled... and 60 FPS (equal to my LCD's 60Hz refresh rate) when VSYNC is enabled (I'll explain the 60Hz refresh rate later)

XVideo perspective
The 'nvidia-settings' allows to configure the nVidia driver and affects all applications/extensions launched AFTER the changes are made.
Launching 'nvidia-settings' with no arguments allows to configure the driver using a nice GUI (including nice helping tooltips). In the XVideo section, we are interested in the two 'Sync to Vblank' checkboxes. You changes will be saved/committed to the driver when exiting the application. Note that you will need include some 'nvidia-settings --load-config-only' command somewhere in your personal start-up script in order to customize the nVidia driver according to YOUR needs (changes are discarded/re-initalized every time you log-out/-in).

Troubleshoot/verify:
Use 'mplayer -benchmark -nosound -frames 1234 -vo xv <some_MRL>'. The '-benchmark' and '-nosound' option tells 'mplayer' to play the video as fast as possible, with no respect with sound synchronization. Calculating the achieved FPS here is a little tricky; the method given below only approximates the FPS (but should allow to find out if VSYNC is enabled or not).

Once the above command executed (on a NON-VSYNC-able machine; old ATI card):
- look at the benchmark results (in the line: BENCHMARKs: VC: 1.529s VO: 1.534s A: 0.000s Sys: 0.279s = 3.341s -> BENCH_TIME = 3.341
- the quantity of played frame is 1234 (you can change this ;-) ) -> COUNT_FRAMES = 1234
The achieved "rendered" FPS is (very approximately):
- FPS = COUNT_FRAMES / BENCH_TIME ( = 369 FPS in our example case)

Now, on my nVidia (VSYNC-able) machine; several scenarios:
1. NO "Composite" X extension
'mplayer -benchmark -nosound -frames 1234 -vo xv <some_MRL>' -> 72 FPS (mplayer's benchmark makes a poor job of trying to VSync... but at least it shows it tries)
2. "Composite" X extension ENABLED (but NOT used)
'mplayer -benchmark -nosound -frames 1234 -vo xv <some_MRL>' -> 72 FPS
3. "Composite" X extension ENABLED (and USED, with KDE Translucency "compositor")
'mplayer -benchmark -nosound -frames 1234 -vo xv <some_MRL>' -> 769 FPS ('mplayer' cannot VSync because of the "compositor")
4. In all cases, compared with OpenGL driver/extension:
'mplayer -benchmark -nosound -frames 1234 -vo gl2 <some_MRL>' -> 60 FPS ( :D )
NOTE: whatever your 'nvidia-settings', 'mplayer' (1.0rc1-rpm.livna.org-4.1.1) ALWAYS enable XV_SYNC_TO_VBLANK (see 'xvinfo' output before and after starting 'mplayer')

LCD/CRT/whatever-screen perspective
Now comes the part that made me tear my hair off...
In my first Xorg settings, I let Xorg take the maximum refresh rate compatible with my LCD projector's specifications -> 85Hz.
Now, though achieved ("rendered") FPS (both OpenGL and XVideo) were perfectly in sync with the Xorg/GPU's refresh rate (85Hz <-> 85 FPS), I still experienced the "tearing" effect (even from a "bare" X windows + mplayer - no KDE/Gnome/whatever - perspective)... Grrrr!!!
Then came to my mind the fact that my old (1999) LCD projector (like many current LCD panels by the way) was designed to work at a 60Hz frequency... and I was feeding him 85Hz... thus having the same "tearing"-causing discrepancy between FPS and refresh rate... but from my LCD's internal video circuits perspective.
I then forced Xorg to feed 60Hz to my LCD (see 'xorg.conf' below)... and guess what... all tearing disappeared !!!
Conlusion: if you are using somehow-fixed-refresh-rate video equipment (and I *would* think this is very often the case, except when using plain old CRTs), make sure to use the proper refresh rate! Now, recent material maybe implements VSync internally (while my old stuff didn't seem to)... but better have the entire video chain be synchronized if you want "perfect" quality ;)

Conclusion
I've been able to watch "Space Cowboys" yesterday evening with total satisfaction :D
Please correct me wherever I'm wrong or unclear !

Cheers to all

My 'xorg.conf'
Code:

Section "Monitor"
    Identifier    "Monitor0"
    ModelName      "LCD Panel 1024x768"
    HorizSync      23.0 - 80.0
    VertRefresh    50.0 - 101.0
    Option        "dpms"
EndSection

Section "Device"
    Identifier    "Videocard0"
    Driver        "nvidia"
    Option        "NoLogo" "true"
    Option        "IgnoreDisplayDevices" "DFP, TV"
    Option        "ConnectedMonitor" "CRT"
    Option        "UseEDID" "false"
    Option        "DPI" "75 x 75"
    Option        "DynamicTwinView" "false"
    Option        "RandRRotation" "false"
#    Option        "XvmcUsesTextures" "true"
    Option        "TripleBuffer" "true"
EndSection

Section "Screen"
    Identifier    "Screen0"
    Device        "Videocard0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection    "Display"
        Viewport    0 0
        Depth      24
        Modes      "1024x768_60" "800x600_60" "640x480_60"
    EndSubSection
EndSection

Section "Extensions"
    Option        "Composite" "Enable" # If enabled (and used), use OpenGL to VSync
EndSection

My '/etc/bashrc'
Code:

if [ "${DISPLAY:0:1}" == ":" ]; then
  export __GL_SYNC_TO_VBLANK=1
  if [ -x /usr/bin/nvidia-settings ]; then
    if [ -r ~/.nvidia-settings-rc ]; then
      /usr/bin/nvidia-settings --load-config-only --config=~/.nvidia-settings-rc 2> /dev/null
    elif [ -r /etc/X11/nvidia-settings-rc ]; then
      /usr/bin/nvidia-settings --load-config-only --config=/etc/X11/nvidia-settings-rc 2> /dev/null
    fi
  fi
fi



All times are GMT -5. The time now is 10:09 PM.

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