All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
To: "Michel Dänzer" <michel-otUistvHUpPR7s880joybQ@public.gmane.org>,
	"Dave Airlie" <airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Hawking Zhang" <Hawking.Zhang-5C7GfCeVMHo@public.gmane.org>
Cc: amd-gfx mailing list
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH] Add freesync ioctl interface
Date: Tue, 9 Aug 2016 12:44:36 +0200	[thread overview]
Message-ID: <0919aff9-cccd-ba2a-2077-3dbd2bea769f@vodafone.de> (raw)
In-Reply-To: <7bdf1ec7-d257-9855-2f24-21f86efa459f-otUistvHUpPR7s880joybQ@public.gmane.org>

Am 09.08.2016 um 12:03 schrieb Michel Dänzer:
> On 09/08/16 06:31 PM, Christian König wrote:
>> Am 09.08.2016 um 10:27 schrieb Michel Dänzer:
>>> On 09/08/16 05:12 PM, Christian König wrote:
>>>> Am 09.08.2016 um 04:44 schrieb Michel Dänzer:
>>>>
>>>>> I was basically thinking out loud that doing this via different modes
>>>>> might be quite natural, *if* games allowed choosing a specific mode.
>>>>> But unfortunately they don't. For the video playback case, how do you
>>>>> envision the video player app communicating the refresh rate of the
>>>>> currently playing video to the kernel?
>>>> Again the kernel doesn't need to know the refresh rate. All the kernel
>>>> needs to know is when to do the page flip.
>>>>
>>>> So coming back to my example of a mode with 1920x1080 and 20-100Hz
>>>> refresh rate a classic modeline would then look something like this:
>>>>
>>>> Modeline "1920x1080_dynamic"  302.50  1920 2072 2280 2640  1080 1083
>>>> 1088 5735 -hsync +vsync
>>>>
>>>> Note the high vertical total scan lines. Those basically reduce the
>>>> refresh rate from 100Hz (which this mode normally would have) down to
>>>> only 20Hz.
>>>>
>>>> Now what userspace does on each page flip is specifying when this flip
>>>> should happen, e.g. when the frame should be started to be scanned out.
>>>> We can either specify this as frame counter + vertical line of the
>>>> previous frame or as something like CLOCK_MONOTONIC (I think I would
>>>> prefer CLOCK_MONOTONIC, but that's not a strong opinion).
>>>>
>>>> In other words you put the whole concept upside down. It's no longer the
>>>> kernel which tells userspace when a vblank happened, but rather
>>>> userspace tells the kernel when it should happen (together with the
>>>> frame that should be displayed then).
>>> I guess that could work. Do video players set the VDPAU presentation
>>> time accurately enough for this?
>> Yes, of course. We actually get a precise time stamp from the
>> application and need to calculate on which vblank to display it from that.
>>
>>> This would require extensive changes across the stack though, when more
>>> or less the same result could be achieved by just letting the kernel
>>> know what the current refresh rate is supposed to be, e.g. via output
>>> properties.
>> The problem is that you don't have a refresh rate any more.
> Maybe not below the video decoding API level, but the video player app
> certainly knows the refresh rate?

Sure, but as I said that isn't a constant refresh rate any more.

E.g. the refresh rate from the video header doesn't need to be a 
multiple of the time a vertical line takes to display.

This results in sightly different display times for each frame. So you 
don't have a constant frame rate any more but rather alternate between 
two (or maybe more) different display times for each frame.

I mean we could of course adjust the frame rate the kernel should 
display with each page flip as well, but that certainly isn't how the 
hardware is working now.

>> Mostly the same applies for games as well, e.g. when you render a frame
>> you usually render it for a certain timestamp.
> I can only find the EGL_ANDROID_presentation_time extension providing
> exactly this functionality. GLX_NV_present_video looks like it covers
> this as well, but it also includes a bunch of other stuff.
>
> I think 0 is a good first approximation of the number of applications
> used by an average Linux desktop user which make use of either of those
> extensions.

Yeah, I agree that we don't have proper support for this on Linux 
desktop at the moment. But this is a chicken and egg problem.

The comment that games render a frame for a certain timestamp was more 
on how games usually work internally.

>> Additional to that are you sure it is such a hassle to implement this? I
>> mean let us sum up what we need:
>> 1. A representation for the new mode attributes, e.g. minimum and
>> maximum vertical refresh rate.
>>
>> This is needed anyway to proper communicate the capabilities of the
>> display device to userspace.
>>
>> 2. An extension to the page flip IOCTL to specify when exactly a flip
>> should happen.
>>
>> As far as I can see that is what your patchset already did. The only
>> difference is that you wanted to specify a certain vertical blank when
>> the flip would happen while I would say we should use a monotonic
>> timestamp (64bit ns since boot) for this.
> Right, the patch series you're referring to isn't directly related to this.
>
>
> 3. Expose this new functionality via the X11 Present extension and/or a
> corresponding Wayland extension.
I unfortunately haven't pushed on this, but I already noted to Keith on 
an earlier version of the present extension that we should use a 
timestamps instead of vertical blank counters.

But double checking the present extension, we indeed already have 
support for PresentOptionUST in it. So this should already be there.

> 4. Make use of 3. in the Gallium video state tracker code.
>
> Now we're done for the video playback case, phew!
>
>
> 5. Make use of 3. to implement EGL_ANDROID_presentation_time and/or
> GLX_NV_present_video.
>
> 6. Make game engines use 5.
>
> (A game engine can know when a frame will be ready for presentation when
> it starts rendering it, so I'm not sure this functionality will be very
> useful for games)
>
>
>>> Also, this doesn't address the case of running (existing) games with
>>> variable refresh rate.
>> Sure it does. For the current stack without any change a freesync
>> capable display device just looks like a normal monitor with a high
>> vertical refresh rate.
> You're saying current userspace would just see the maximum vertical
> refresh rate as the refresh rate?

I think so. I mean the minimum is usually rather low, e.g. between 20 
and 30Hz.

>
>
>> When we add freesync support we just extend vblank_mode with a new enum
>> to enable it optionally for existing applications.
> "Just"... this will only be possible after the first 3 steps above.

Checking the present extension again we already got PresentOptionAsync 
in there as well.

So the whole thing boils down implementing a new vblank_mode enume which 
sets PresentOptionAsync and then doing the right thing on the X side 
with those information.

I'm going to give the UST option a try with VDPAU, let's see how well 
that works and if it is implemented correctly or not.

Regards,
Christian.
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2016-08-09 10:44 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02  2:26 [PATCH] Add freesync ioctl interface Hawking Zhang
     [not found] ` <1470104760-30612-1-git-send-email-Hawking.Zhang-5C7GfCeVMHo@public.gmane.org>
2016-08-02  3:10   ` Michel Dänzer
     [not found]     ` <11f584d2-7d40-4318-7725-672816b9cd9c-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-02  3:12       ` Zhang, Hawking
     [not found]         ` <BN6PR12MB120484B42FE46271D494A73EFC050-/b2+HYfkarSdTuMsQheahAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-08-02  3:32           ` Michel Dänzer
     [not found]             ` <09948c72-7214-5863-5af8-a60dc481371c-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-02  4:14               ` Zhang, Hawking
     [not found]                 ` <BN6PR12MB1204C7FDE82DB11764D57AC3FC050-/b2+HYfkarSdTuMsQheahAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-08-02 13:54                   ` Deucher, Alexander
2016-08-02  3:23       ` Zhang, Hawking
2016-08-03  1:04   ` Dave Airlie
     [not found]     ` <CAPM=9twBgjLJNZ4F5xzoAk6zw-8=7ck7xfTnQOczr1TVNLnMTQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-03 11:16       ` Christian König
2016-08-04  6:41       ` Michel Dänzer
     [not found]         ` <918642dc-f72c-5403-cf38-eead279d4a97-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-04  8:22           ` Christian König
     [not found]             ` <618bb6d0-bca5-e709-227c-08c99bd6843e-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2016-08-08  7:43               ` Michel Dänzer
     [not found]                 ` <a2e669ae-88a3-4734-3e7f-5aceccfc43d7-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-08  9:55                   ` Christian König
     [not found]                     ` <1c54f1c3-130f-f858-e08b-14d70d17817d-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2016-08-09  2:44                       ` Michel Dänzer
     [not found]                         ` <7b758b9a-7ee3-7809-4e23-76828ee23a0c-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-09  8:12                           ` Christian König
     [not found]                             ` <ad9f2301-1d4c-388e-f3c2-d12872f7940a-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2016-08-09  8:27                               ` Michel Dänzer
     [not found]                                 ` <cf663a26-afd2-0878-2822-fe375905fbfc-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-09  9:31                                   ` Christian König
     [not found]                                     ` <7ffe528b-d207-3948-a850-a289bcc76c43-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2016-08-09 10:03                                       ` Michel Dänzer
     [not found]                                         ` <7bdf1ec7-d257-9855-2f24-21f86efa459f-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-09 10:44                                           ` Christian König [this message]
     [not found]                                             ` <0919aff9-cccd-ba2a-2077-3dbd2bea769f-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2016-08-10  3:19                                               ` Michel Dänzer
     [not found]                                                 ` <142d748c-11be-e454-551f-e9098a53a848-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-10  7:49                                                   ` Michel Dänzer
     [not found]                                                     ` <75f1d134-b1f4-c24f-be3f-a886c95e5ced-otUistvHUpPR7s880joybQ@public.gmane.org>
2016-08-10  8:25                                                       ` Ernst Sjöstrand
     [not found]                                                         ` <CAD=4a=U+p+Aza+z-hj03HNrOPp9hC1r=nV0Aw1UjzyRBLxm1yg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-10 21:22                                                           ` Deucher, Alexander
2016-08-10 10:02                                                   ` Christian König

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=0919aff9-cccd-ba2a-2077-3dbd2bea769f@vodafone.de \
    --to=deathsimple-antagkrnahcb1svskn2v4q@public.gmane.org \
    --cc=Hawking.Zhang-5C7GfCeVMHo@public.gmane.org \
    --cc=airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=michel-otUistvHUpPR7s880joybQ@public.gmane.org \
    /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.