How do I wait for vertical retrace?

Jesse Barnes jbarnes at virtuousgeek.org
Tue May 6 22:32:20 PDT 2008


On Tuesday, May 06, 2008 7:10 pm Carsten Haitzler wrote:
> > In most cases, it would be better to have a mechanism to tell the
> > server to delay execution until the beginning of the next blanking
> > interval. Actually, delaying execution until the refresh passes a
> > certain scan line (i.e. the bottom of the modified region) would be
> > better, as that allows more time.
>
> i'd even much prefer that. then with a little tuning the app can figure out
> its latency. i.e. i have 1600x1200. i do some tuning and know that if i get
> an interrupt on scanline 930, i can get the "line 930 reached" event,
> respond and copy from a backbuffer to the screen by the time vblank (line
> 0) gets hit. as copies work down the screen (normally) the final writes to
> the bottom of the screen will not be an issue as scanning has passed by
> there by the time i write to it.
>
> wonderful... in theory. in practice a lot of hardware ONLY provides a
> vblank interrupt. no interrupt for line X. :(

>
> so as such i'd rather just have this work for a local client - be able to
> get the vblank (or line 0 reached) event then respond asap. for remote
> clients - game over anyway :(

This won't work in general though unless you use realtime scheduling and are 
very careful.  It's much better (if possible) to queue up buffer swap or blt 
commands to occur at interrupt time, in interrupt context.  That way you're 
not relying on getting scheduled in time to avoid tearing...

The i915 DRM driver has this mechanism, and most other devices are capable of 
supporting it too.

Jesse





More information about the xorg mailing list