I'm using glXGetVideoSyncSGI right after glXWaitVideoSyncSGI and that way the vblank counter is always correct.
I did notice that glXWaitVideoSyncSGI doesn't wait anymore when you change the displaymode through randr, as a workaround you can detach and attach the gl context when the vblank counter doesn't update after a call to glXWaitVideoSyncSGI.
You can see my code here starting on line 431:
http://xbmc.svn.sourceforge.net/view...55&view=markup