All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cyr, Aric" <Aric.Cyr@amd.com>
To: "Haehnle, Nicolai" <Nicolai.Haehnle@amd.com>,
	"Michel Dänzer" <michel@daenzer.net>,
	"Koenig, Christian" <Christian.Koenig@amd.com>,
	"Wentland, Harry" <Harry.Wentland@amd.com>,
	"Manasi Navare" <manasi.d.navare@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	"Daenzer, Michel" <Michel.Daenzer@amd.com>,
	amd-gfx mailing list <amd-gfx@lists.freedesktop.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Koo, Anthony" <Anthony.Koo@amd.com>
Subject: RE: RFC for a render API to support adaptive sync and VRR
Date: Tue, 10 Apr 2018 21:45:41 +0000	[thread overview]
Message-ID: <MWHPR12MB18374597F3FC9BFEB6763ED082BE0@MWHPR12MB1837.namprd12.prod.outlook.com> (raw)
In-Reply-To: <f85e3590-b283-843b-12d0-5f6f0c4c0952@amd.com>

> From: Haehnle, Nicolai
> Sent: Tuesday, April 10, 2018 13:48
> On 10.04.2018 19:25, Cyr, Aric wrote:
> >> -----Original Message-----
> >> From: Michel Dänzer [mailto:michel@daenzer.net]
> >> Sent: Tuesday, April 10, 2018 13:16
> >>
> >> On 2018-04-10 07:13 PM, Cyr, Aric wrote:
> >>>> -----Original Message-----
> >>>> From: Michel Dänzer [mailto:michel@daenzer.net]
> >>>> Sent: Tuesday, April 10, 2018 13:06
> >>>> On 2018-04-10 06:26 PM, Cyr, Aric wrote:
> >>>>> From: Koenig, Christian Sent: Tuesday, April 10, 2018 11:43
> >>>>>
> >>>>>> For video games we have a similar situation where a frame is rendered
> >>>>>> for a certain world time and in the ideal case we would actually
> >>>>>> display the frame at this world time.
> >>>>>
> >>>>> That seems like it would be a poorly written game that flips like
> >>>>> that, unless they are explicitly trying to throttle the framerate for
> >>>>> some reason.  When a game presents a completed frame, they’d like
> >>>>> that to happen as soon as possible.
> >>>>
> >>>> What you're describing is what most games have been doing traditionally.
> >>>> Croteam's research shows that this results in micro-stuttering, because
> >>>> frames may be presented too early. To avoid that, they want to
> >>>> explicitly time each presentation as described by Christian.
> >>>
> >>> Yes, I agree completely.  However that's only truly relevant for fixed
> >>> refreshed rate displays.
> >>
> >> No, it also affects variable refresh; possibly even more in some cases,
> >> because the presentation time is less predictable.
> >
> > Yes, and that's why you don't want to do it when you have variable refresh.  The hardware in the monitor and GPU will do it for you,
> so why bother?
> 
> I think Michel's point is that the monitor and GPU hardware *cannot*
> really do this, because there's synchronization with audio to take into
> account, which the GPU or monitor don't know about.

How does it work fine today given that all kernel seems to know is 'current' or 'current+1' vsyncs.  
Presumably the applications somehow schedule all this just fine.
If this works without variable refresh for 60Hz, will it not work for a fixed-rate "48Hz" monitor (assuming a 24Hz video)?

> Also, as I wrote separately, there's the case of synchronizing multiple
> monitors.

For multimonitor to work with VRR, they'll have to be timing and flip synchronized.
This is impossible for an application to manage, it needs driver/HW control or you end up with one display flipping before the other and it looks terrible.
And definitely forget about multiGPU without professional workstation-type support needed to sync the displays across adapters.

> > The input to their algorithms will be noisy causing worst estimations.  If you just present as fast as you can, it'll just work (within
> reason).
> > The majority of gamers want maximum FPS for their games, and there's quite frequently outrage at a particular game when they are
> limited to something lower that what their monitor could otherwise support (i.e. I don't want my game limited to 30Hz if I have a shiny
> 144Hz gaming display I paid good money for).   Of course, there's always exceptions... but in our experience those are few and far
> between.
> 
> I agree that games most likely shouldn't try to be smart. I'm curious
> about the Croteam findings, but even if they did a really clever thing
> that works better than just telling the display driver "display ASAP
> please", chances are that *most* developers won't do that. And they'll
> most likely get it wrong, so our guidance should really be "games should
> ask for ASAP presentation, and nothing else".

Right, I think this is the 'easy' case and is covered in Harry's initial proposal when target_frame_duration_ns = 0.

> However, there *are* legitimate use cases for requesting a specific
> presentation time, and there *is* precedent of APIs that expose such
> features.
>
> Are there any real problems with exposing an absolute target present time?

Realistically, how far into the future are you requesting a presentation time? Won't it almost always be something like current_time+1000/video_frame_rate?
If so, why not just tell the driver to set 1000/video_frame_rate and have the GPU/monitor create nicely spaced VSYNCs for you that match the source content?

In fact, you probably wouldn't even need to change your video player at all, other than having it pass the target_frame_duration_ns.  You could consider this a 'hint' as you suggested, since it's cannot be guaranteed in cases your driver or HW doesn't support variable refresh.  If the target_frame_duration_ns hint is supported/applied, then the video app should have nothing extra to do that it wouldn't already do for any arbitrary fixed-refresh rate display.  If not supported (say the drm_atomic_check fails with -EINVAL or something), the video app falls can stop requesting a fixed target_frame_duration_ns.

A fundamental problem I have with a target present time though is how to accommodate present times that are larger than one VSYNC time?  If my monitor has a 40Hz-60Hz variable refresh, it's easy to translate "my content is 24Hz, repeat this next frame an integer multiple number of times so that it lands within the monitor range".  Driver fixes display to an even 48Hz and everything good (no worse than a 30Hz clip on a traditional 60Hz display anyways).  This frame-doubling is all hardware based and doesn't require any polling.  

Now if you change that to "show my content in at least X nanoseconds" it can work on all displays, but the intent of the app is gone and driver/GPU/display cannot optimize.  For example, the HDMI VRR spec defines a "CinemaVRR" mode where target refresh rate error is accounted for based on 0.1% deviation from requested and the v_total lines are incremented/decremented to compensate.  If we don't know the target rate, we will not be able to comply to this industry standard specification.

Also, how would you manage an absolute target present time in kernel?  I guess app and driver need to use a common system clock or tick count, but when would you know to 'wake up' and execute the flip?  If you wait for VSYNC then you'll always timeout out on v_total_max (i.e. minimum refresh rate), check your time and see "yup, need to present now" and then flip.  Now your monitor just jumped from lowest refresh rate to something else which can cause other problems.  If you use some timer, then you're burning needless power polling some counter and still wouldn't have the same accuracy you could achieve with a fixed duration.

Regards,
  Aric
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-04-10 21:45 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09 19:56 RFC for a render API to support adaptive sync and VRR Harry Wentland
     [not found] ` <c79421ce-9408-5cd6-5de3-0fa521146e4b-5C7GfCeVMHo@public.gmane.org>
2018-04-09 20:00   ` Harry Wentland
     [not found]     ` <435ebd04-0435-5a6a-9f1e-e4c4fc629aa9-5C7GfCeVMHo@public.gmane.org>
2018-04-09 21:45       ` Manasi Navare
     [not found]         ` <20180409214554.GB13967-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-04-10  6:45           ` Christian König
2018-04-10  7:37             ` Michel Dänzer
     [not found]               ` <b75e31f7-ce59-de97-5445-cb4c03ff7336-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-04-10 15:08                 ` Harry Wentland
     [not found]                   ` <ae9992e5-43ab-9636-13e1-8a5c692480b5-5C7GfCeVMHo@public.gmane.org>
2018-04-10 15:28                     ` Christian König
2018-04-10 15:35                     ` Cyr, Aric
2018-04-10 15:43                       ` Christian König
     [not found]                         ` <fc53ce53-f02c-891d-4aa5-e9a11cbe3007-5C7GfCeVMHo@public.gmane.org>
2018-04-10 16:26                           ` Cyr, Aric
     [not found]                             ` <MWHPR12MB1837488A047C03E955282A4182BE0-Gy0DoCVfaSXe1Hf+mWOIywdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-04-10 16:37                               ` Nicolai Hähnle
     [not found]                                 ` <54baa87e-33a9-bd69-a309-d61176eb4e8d-5C7GfCeVMHo@public.gmane.org>
2018-04-10 17:52                                   ` Harry Wentland
     [not found]                             ` <063d6dff-2b97-ef01-12bb-8a24125a58ec@daenzer.net>
2018-04-10 17:13                               ` Cyr, Aric
     [not found]                                 ` <65006f34-39b9-5aca-e0c0-77a591b69c3a@daenzer.net>
     [not found]                                   ` <65006f34-39b9-5aca-e0c0-77a591b69c3a-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-04-10 17:25                                     ` Cyr, Aric
     [not found]                                       ` <f85e3590-b283-843b-12d0-5f6f0c4c0952@amd.com>
2018-04-10 21:45                                         ` Cyr, Aric [this message]
2018-04-11  6:57                                           ` Nicolai Hähnle
     [not found]                                             ` <72c1d357-db72-b181-9421-04f99b3bbf2f-5C7GfCeVMHo@public.gmane.org>
2018-04-11  9:50                                               ` Michel Dänzer
     [not found]                                                 ` <2005817c-09c0-aebe-bb96-9e22d6f16df5-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-04-11 23:30                                                   ` Cyr, Aric
     [not found]                                                     ` <MWHPR12MB1837F8120B126FA3A4CE899982BD0-Gy0DoCVfaSXe1Hf+mWOIywdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-04-12  8:48                                                       ` Michel Dänzer
2018-04-12 11:39                                                     ` Nicolai Hähnle
     [not found]                                                       ` <a5b5c31f-e7c5-8ae0-1239-06bfa86b939b-5C7GfCeVMHo@public.gmane.org>
2018-04-12 14:57                                                         ` Michel Dänzer
2018-04-12 17:39                                                         ` Harry Wentland
2018-04-11 10:28                                       ` Michel Dänzer
2018-04-11 15:45                             ` Michel Dänzer
     [not found]                       ` <MWHPR12MB1837C57016A470A5199E855282BE0-Gy0DoCVfaSXe1Hf+mWOIywdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-04-10 17:13                         ` Michel Dänzer
2018-04-12 21:38                 ` Stéphane Marchesin
2018-04-13 19:24                   ` Harry Wentland
2018-04-18  3:58                 ` Keith Packard
2018-04-18  7:39                   ` Daniel Vetter
2018-04-20 20:32                     ` Manasi Navare
     [not found]                       ` <20180420203240.GA9472-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-04-21 10:30                         ` Daniel Stone
2018-04-23 14:40                         ` Harry Wentland
2018-04-23 21:19                           ` Manasi Navare
     [not found]                             ` <20180423211944.GC9472-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2018-04-24 12:09                               ` Daniel Vetter
2018-04-24 14:20                                 ` Cyr, Aric
     [not found]                                 ` <20180424120946.GW31310-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-04-24 14:28                                   ` Harry Wentland
     [not found]                                     ` <b9c33eeb-1db8-f782-cfbe-411d94fecb67-5C7GfCeVMHo@public.gmane.org>
2018-04-24 21:57                                       ` Daniel Vetter
     [not found]                                         ` <CAKMK7uHzLRUwZSFbMb4qDzXBODVSQVTTw6BxgmvJdES4gJmBDg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-08-17 10:20                                           ` Ernst Sjöstrand
2018-04-10 15:03           ` Harry Wentland
2018-04-10 21:36             ` Manasi Navare
2018-04-10 22:00               ` Cyr, Aric
2018-04-13 16:04       ` Daniel Vetter
     [not found]         ` <20180413160453.GC31310-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-04-13 19:20           ` Harry Wentland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MWHPR12MB18374597F3FC9BFEB6763ED082BE0@MWHPR12MB1837.namprd12.prod.outlook.com \
    --to=aric.cyr@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Anthony.Koo@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Harry.Wentland@amd.com \
    --cc=Michel.Daenzer@amd.com \
    --cc=Nicolai.Haehnle@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=manasi.d.navare@intel.com \
    --cc=michel@daenzer.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.