Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XRFrame.predictedDisplayTime #1217

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ When an {{XRSession}} |session| receives updated [=viewer=] state for timestamp
1. Let |now| be the [=current high resolution time=].
1. Let |frame| be |session|'s [=XRSession/animation frame=].
1. Set |frame|'s [=XRFrame/time=] to |frameTime|.
1. Set |frame|'s [predictedDisplayTime] to the timestamp when the [=XR Compositor=] is expected to display content drawn during this [=XR animation frame=].
1. For each |view| in [=XRSession/list of views=], set |view|'s [=view/viewport modifiable=] flag to true.
1. If the [=view/active=] flag of any [=view=] in the [=XRSession/list of views=] has changed since the last [=XR animation frame=], [=update the viewports=].
1. If the frame [=should be rendered=] for |session|:
Expand Down Expand Up @@ -1033,7 +1034,7 @@ window.requestAnimationFrame(onWindowAnimationFrame);

function onXRAnimationFrame(time, xrFrame) {
xrSession.requestAnimationFrame(onXRAnimationFrame);
renderFrame(time, xrFrame);
renderFrame(xrFrame.predictedDisplayTime, xrFrame);
}

function renderFrame(time, xrFrame) {
Expand Down Expand Up @@ -1075,6 +1076,7 @@ An {{XRFrame}} represents a snapshot of the state of all of the tracked objects
<pre class="idl">
[SecureContext, Exposed=Window] interface XRFrame {
[SameObject] readonly attribute XRSession session;
readonly attribute DOMHighResTimeStamp predictedDisplayTime;

XRViewerPose? getViewerPose(XRReferenceSpace referenceSpace);
XRPose? getPose(XRSpace space, XRSpace baseSpace);
Expand All @@ -1085,6 +1087,14 @@ Each {{XRFrame}} has an <dfn for="XRFrame">active</dfn> boolean which is initial

The <dfn attribute for="XRFrame">session</dfn> attribute returns the {{XRSession}} that produced the {{XRFrame}}.

The <dfn attribute for="XRFrame">predictedDisplayTime</dfn> attribute returns the {{DOMHighResTimeStamp}} that represents the point in time at which a rendered frame submitted for this {{XRFrame}} is expected to show up on the devices display.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a bit clearer:
that represents the point in time at which the [=XR Compositor=] expects this {{XRFrame}} to be displayed on the [=XR Device=].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


<div class=note>
The [=XRFrame/predictedDisplayTime=] is intended to allow rendering an animated XR scene in the state that it should be in when the frame is displayed rather than when the {{XRSession/requestAnimationFrame()}} callback was scheduled or when it was executed.

The [=XRFrame/predictedDisplayTime=] is not intended be used to infer how much time the application has for rendering, as the [=XR Compositor=] typically has to do extra processing after the frame is submitted. If the experience assumes that it can process up to [=XRFrame/predictedDisplayTime=], the [=XR Compositor=] will not be able to make use of the submitted frames, and the application would not make target framerate.
</div>

Each {{XRFrame}} represents the state of all tracked objects for a given <dfn for="XRFrame">time</dfn>, and either stores or is able to query concrete information about this state at the [=XRFrame/time=].

<div class="algorithm" data-algorithm="get-viewer-pose">
Expand Down