dri3: Track current Present swap mode and adjust buffer counts
authorKeith Packard <keithp@keithp.com>
Mon, 27 Jan 2014 00:14:29 +0000 (16:14 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 31 Jan 2014 01:29:33 +0000 (17:29 -0800)
commit3fbd1b0cb576b46ac8df2697cb388db78f48012d
tree63af9ff419152b770a4d8d6f7440e88033dc1076
parentaea4757eb4caf6f980fdaa2b9345f26329c29d12
dri3: Track current Present swap mode and adjust buffer counts

This automatically adjusts the number of buffers that we want based on
what swapping mode the X server is using and the current swap interval:

        swap mode       interval        buffers
        copy            > 0             1
        copy            0               2
        flip            > 0             2
        flip            0               3

Note that flip with swap interval 0 is currently limited to twice the
underlying refresh rate because of how the kernel manages flipping. Moving
from 3 to 4 buffers would help, but that seems ridiculous.

v2: Just update num_back at the point that the values that change num_back
    change.  This means we'll have the updated value at the point that the
    freeing of old going-to-be-unused backbuffers happens, which might not
    have been the case before (change by anholt, acked by keithp).

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/glx/dri3_glx.c
src/glx/dri3_priv.h