<div dir="ltr">More comments!<br><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 31, 2014 at 7:29 AM, Pekka Paalanen <span dir="ltr"><<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Thu, 30 Jan 2014 17:35:17 +0200<br>
Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com">ppaalanen@gmail.com</a>> wrote:<br>
<br>
> The v1 proposal is here:<br>
> <a href="http://lists.freedesktop.org/archives/wayland-devel/2013-October/011496.html" target="_blank">http://lists.freedesktop.org/archives/wayland-devel/2013-October/011496.html</a><br>
><br>
> In v2 the basic idea is the same: you can queue frames with a<br>
> target presentation time, and you can get accurate presentation<br>
> feedback. All the details are new, though. The re-design started<br>
> from the wish to handle resizing better, preferably without<br>
> clearing the buffer queue.<br>
<br>
</div>...<br>
<div><div class="h5"><br>
> <interface name="presentation_feedback" version="1"><br>
> <description summary="presentation time feedback event"><br>
> A presentation_feedback object returns the feedback information<br>
> about a wl_surface content update becoming visible to the user.<br>
> One object corresponds to one content update submission<br>
> (wl_surface.commit), queued or immediate. There are two possible<br>
> outcomes: the content update may be presented to the user, in<br>
> which case the presentation timestamp is delivered. Otherwise,<br>
> the content update is discarded, and the user never had a chance<br>
> to see it before it was superseded or the surface was destroyed.<br>
><br>
> Once a presentation_feedback object has delivered an event, it<br>
> becomes inert, and should be destroyed by the client.<br>
> </description><br>
><br>
> <request name="destroy" type="destructor"><br>
> <description summary="destroy presentation feedback object"><br>
> The object is destroyed. If a feedback event had not been<br>
> delivered yet, it is cancelled.<br>
> </description><br>
> </request><br>
><br>
> <event name="sync_output"><br>
> <description summary="presentation synchronized to this output"><br>
> As presentation can be synchronized to only one output at a<br>
> time, this event tells which output it was. This event is only<br>
> sent prior to the presented event.<br>
><br>
> As clients may bind to the same global wl_output multiple<br>
> times, this event is sent for each bound instance that matches<br>
> the synchronized output. If a client has not bound to the<br>
> right wl_output global at all, this event is not sent.<br>
> </description><br>
><br>
> <arg name="output" type="object" interface="wl_output"<br>
> summary="presentation output"/><br>
> </event><br>
><br>
> <event name="presented"><br>
> <description summary="the content update was displayed"><br>
> The associated content update was displayed to the user at the<br>
> indicated time (tv_sec, tv_nsec). For the interpretation of<br>
> the timestamp, see presentation.clock_id event.<br>
><br>
> The timestamp corresponds to the time when the content update<br>
> turned into light the first time on the surface's main output.<br>
> Compositors may approximate this from the framebuffer flip<br>
> completion events from the system, and the latency of the<br>
> physical display path if known.<br>
><br>
> This event is preceeded by all related sync_output events<br>
> telling which output's refresh cycle the feedback corresponds<br>
> to, i.e. the main output for the surface. Compositors are<br>
> recommended to choose to the output containing the largest<br>
> part of the wl_surface, or keeping the output they previously<br>
> chose. Having a stable presentation output association helps<br>
> clients to predict future output refreshes (vblank).<br>
><br>
> Argument 'refresh' gives the compositor's prediction of how<br>
> many nanoseconds after tv_sec, tv_nsec the very next output<br>
> refresh may occur. This is to further aid clients in<br>
> predicting future refreshes, i.e., estimating the timestamps<br>
> targeting the next few vblanks. If such prediction cannot<br>
> usefully be done, the argument is zero.<br>
><br>
> The 64-bit value combined from seq_hi and seq_lo is the value<br>
> of the output's vertical retrace counter when the content<br>
> update was first scanned out to the display. This value must<br>
> be compatible with the definition of MSC in<br>
> GLX_OML_sync_control specification. Note, that if the display<br>
> path has a non-zero latency, the time instant specified by<br>
> this counter may differ from the timestamp's.<br>
><br>
> If the output does not have a constant refresh rate, explicit<br>
> video mode switches excluded, then the refresh argument must<br>
> be zero.<br>
><br>
> If the output does not have a concept of vertical retrace or a<br>
> refresh cycle, or the output device is self-refreshing without<br>
> a way to query the refresh count, then the arguments seq_hi<br>
> and seq_lo must be zero.<br>
> </description><br>
><br>
> <arg name="tv_sec" type="uint"<br>
> summary="seconds part of the presentation timestamp"/><br>
> <arg name="tv_nsec" type="uint"<br>
> summary="nanoseconds part of the presentation timestamp"/><br>
> <arg name="refresh" type="uint" summary="nanoseconds till next<br>
> refresh"/> <arg name="seq_hi" type="uint"<br>
> summary="high 32 bits of refresh counter"/><br>
> <arg name="seq_lo" type="uint"<br>
> summary="low 32 bits of refresh counter"/><br>
> </event><br>
><br>
> <event name="discarded"><br>
> <description summary="the content update was not displayed"><br>
> The content update was never displayed to the user.<br>
> </description><br>
> </event><br>
> </interface><br>
><br>
> </protocol><br>
<br>
</div></div>No-one else asked anything yet, so let me. ;-)<br>
<br>
When a client starts an animation or video playback from scratch, that<br>
is, after a long pause or the first time on the wl_surface, it has to<br>
present at least one frame before it can get any feedback. Because you<br>
want to start playback ASAP and keep it streaming, you have to post<br>
another frame too, before you have time to receive the feedback, and<br>
use it to adjust the submission target times. IOW, the first few frames<br>
have to be scheduled blind, the only information you have is the *set*<br>
of outputs where the wl_surface is on, and the outputs' default refresh<br>
rates.<br>
<br>
Could we somehow calibrate the client's scheduling loop earlier?<br>
<br>
We might add another request to presentation interface:<br>
<br>
<request name="preroll_feedback"><br>
<div class=""> <arg name="surface" type="object" interface="wl_surface"<br>
summary="target surface"/><br>
<arg name="callback" type="new_id" interface="presentation_feedback"<br>
summary="new feedback object"/><br>
</request><br>
<br>
</div>Yeah, this is a second request that creates a presentation_feedback<br>
object, but since both factory requests are in the same interface,<br>
there should not be versioning issues.<br>
<br>
Preroll_feedback would create a new presentation_feedback object, which<br>
the compositor would trigger immediately, providing the timestamp and<br>
MSC of the latest known display refresh (equivalent to vblank), the<br>
surface's current main output, and the output's current refresh period<br>
length. If the compositor cannot implement this, it could just reply<br>
with presentation_feedback.discarded.<br>
<br>
Obviously using this request requires a roundtrip to get the reply from<br>
the compositor, but having the compositor send a continuous stream of<br>
"vblank-events" would be much much worse.<br>
<br>
Once a client gets the reply for preroll_feedback, it then reads the<br>
current UST with clock_gettime() and decides which coming display<br>
refresh it will target. The start should be more accurately in sync<br>
with the display refresh cycle than otherwise.<br>
<br>
However, there are more downsides than just the roundtrip. Even if the<br>
compositor replies immediately, you probably end up starting the<br>
playback a frame later than if you just started blind. If the<br>
compositor cannot access the requested information directly, e.g. it<br>
has not flipped the framebuffer for some time and the drivers don't<br>
support the query, the compositor might need to wait for the next<br>
vblank before it can reply. Or the compositor might reply with so old<br>
data that it is not useful anymore. Any delays would void the benefit<br>
of achieving early sync.<br>
<br>
A more fundamental problem is, that the wl_surface must be mapped<br>
before this request makes sense. If a surface is not mapped, it does<br>
not have size or position, and the compositor does not know which<br>
output it would be syncing to. Hence it cannot reply.<br>
<br>
Considering all this, would it be worth it to have this kind of request?<br></blockquote><div><br></div><div>It seems to me that the client should be able to just read the clock_id, do an initial sync with the audio clock, call clock_gettime, and throw a few "best try" frames at the server. Since the server will try to present it on time, it shouldn't be that far off. Besides, audio sync probably doesn't matter in the first few frames.<br>
<br></div><div>I'm all for a better solution, but I don't know that creating dummy presentation callbacks is going to gain us enough practical benifit to be worth it. I could be wrong on that point though.<br></div>
<div>--Jason Ekstrand<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
FWIW, I asked on #dri-devel, and it seems that DRM/KMS should be able<br>
to provide the needed info without waiting for the next vblank.<br>
However, it probably depends on the particular driver in use, does the<br>
driver keep vblank irqs running, and does the hardware have convenient<br>
registers to read the necessary information. To me it sounds a lot more<br>
uncertain than just posting a real frame and seeing when it hits the<br>
user.<br>
<br>
OTOH, GLX_OML_sync_control has glXGetSyncValuesOML() and<br>
glXGetMscRateOML() which provide similar information, so this should be<br>
possible at some level.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
Thanks,<br>
pq<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</div></div></blockquote></div><br></div></div></div>