[Mesa-dev] [PATCH] st/dri: decrease input lag by syncing sooner in SwapBuffers

Marek Olšák maraeo at gmail.com
Fri Apr 26 18:22:18 UTC 2019


On Fri, Apr 26, 2019 at 4:08 AM Michel Dänzer <michel at daenzer.net> wrote:

> On 2019-04-26 4:06 a.m., Marek Olšák wrote:
> > From: Marek Olšák <marek.olsak at amd.com>
> >
> > It's done by:
> > - decrease the number of frames in flight by 1
> > - flush before throttling in SwapBuffers
> >   (instead of wait-then-flush, do flush-then-wait)
> >
> > The improvement is apparent with Unigine Heaven.
> >
> > Previously:
> >     draw frame 2
> >     wait frame 0
> >     flush frame 2
> >     present frame 2
> >
> >     The input lag is 2 frames.
> >
> > Now:
> >     draw frame 2
> >     flush frame 2
> >     wait frame 1
> >     present frame 2
> >
> >     The input lag is 1 frame. Flushing is done before waiting, because
> >     otherwise the device would be idle after waiting.
>
> Nice idea. Not sure offhand about all ramifications, but certainly worth
> a go.
>
>
> > Nine is affected because it also uses the pipe cap.
> > ---
> >  src/gallium/auxiliary/util/u_screen.c         |  2 +-
> >  src/gallium/state_trackers/dri/dri_drawable.c | 20 +++++++++----------
> >  2 files changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/src/gallium/auxiliary/util/u_screen.c
> b/src/gallium/auxiliary/util/u_screen.c
> > index 27f51e0898e..410f17421e6 100644
> > --- a/src/gallium/auxiliary/util/u_screen.c
> > +++ b/src/gallium/auxiliary/util/u_screen.c
> > @@ -349,21 +349,21 @@ u_pipe_screen_get_param_defaults(struct
> pipe_screen *pscreen,
> >     case PIPE_CAP_MAX_VARYINGS:
> >        return 8;
> >
> >     case PIPE_CAP_COMPUTE_GRID_INFO_LAST_BLOCK:
> >        return 0;
> >
> >     case PIPE_CAP_COMPUTE_SHADER_DERIVATIVES:
> >        return 0;
> >
> >     case PIPE_CAP_MAX_FRAMES_IN_FLIGHT:
> > -      return 2;
> > +      return 1;
>
> This might be slightly misleading, as there can still be two frames in
> flight (on the GPU) at the same time. Might be better to leave this at 2
> (so Nine isn't affected) and adjust its treatment in
> src/gallium/state_trackers/dri/dri_drawable.c .
>

When dri_flush is waiting, there can be at most 2 frames submitted and not
finished (that's why it's waiting). When dri_flush is done, there is at
most 1 frame submitted and not finished. The CAP is enforced by dri_flush.

Marek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190426/6c47b916/attachment-0001.html>


More information about the mesa-dev mailing list