Motion-to-Photon

Asynchronous timewarp cuts head-turn lag to about one scan-out, because a fast compositor re-aims the last frame just before vsync. It cannot fix translation.

Learn why a headset has about 20 ms from your head turn to new light on the screen, and how every stage of the frame pipeline spends that budget.

Set the render time to 14 ms, then switch Timewarp on and off. Watch the posts in the lower picture. Then turn Spacewarp on and watch the square. Then we build, piece by piece, each part of the pipeline.

You need a rough idea of what a frame and a refresh rate are (a screen redraws a fixed number of times each second). We build the rest from zero.

Built from primary sources: Michael Abrash on latency (2012), J. M. P. van Waveren, The asynchronous time warp for virtual reality on consumer hardware (VRST 2016), Meta’s timewarp, spacewarp and late latching notes, the OpenXR xrWaitFrame page, and OptoFidelity’s Vision Pro test. Sources are listed in the Field Guide.

Turn your head

14 ms
300 deg/s

A model, not a headset. Rates and the 14 ms render are the lesson’s example. Head speeds are illustrative. The pipeline stages and the 2 ms compositor lead are simplified; the Field Guide says which numbers come from sources. Spacewarp here means a synthetic frame between real ones, at half the app rate.

Chapter 0

The Frame That Repeated

See how one late frame becomes a stutter, and learn the stages that spend your time budget

You put on a headset and look at a virtual table. You turn your head to the left. For one moment the table does not turn with you. It slides a little the wrong way, then snaps back.

Nothing crashed. The program ran fine. A few frames were simply late, and your eyes caught it. This lesson explains why that happens and what a headset does about it.

A frame is a promise to the screen

A screen redraws on a fixed beat. The beat is the refresh rate, counted in hertz (Hz), the number of redraws each second. A headset might run at 72, 90 or 120 Hz.

Each redraw happens at a vsync, the tick when the screen starts to show a new picture. The time between two ticks is the frame budget. Divide 1000 ms by the rate to get it.

1000 / 72 = 13.9 ms    1000 / 90 = 11.1 ms    1000 / 120 = 8.33 ms

The screen does not wait. If the program has no new picture at the tick, the screen shows the old one again. That is a repeated frame. Think of a train that leaves on time whether or not you reached the platform.

The pipeline a head turn travels through

Your head turn is not drawn in one step. It passes through a chain of stages. Each stage uses part of the frame budget, and most of them run on a different chip.

  1. The IMU (inertial measurement unit, a tiny gyroscope and accelerometer) senses the turn.
  2. Tracking code turns the readings into a pose: the head position and the head angles at one instant.
  3. The app’s CPU code reads the pose and decides what the scene looks like.
  4. The GPU draws the scene for that pose. This is the render time.
  5. The compositor, a system program that owns the screen, takes the finished frame and prepares it for the panel.
  6. The panel scans out the picture: it lights its rows one after another.

The total delay from step 1 to the last row lighting up is the motion-to-photon latency. Photon here means light leaving the screen. The name says it all: motion in, light out.

Without any tricks, that chain spans two to three frames. At 90 Hz, three frames is 33 ms. The tricks in this lesson exist to shorten it.

How big can the delay be?

Michael Abrash, then at Valve, wrote in 2012 that more than 20 ms is too much for VR, and especially for AR. He added that research points to 15 ms, or even 7 ms, as the real threshold. The next chapter shows where 20 ms comes from.

Now watch the problem itself. In the device below, an app runs at 90 Hz. Pick how long each frame takes to render. Count the repeated frames.

Count the repeated frames

Top lane: the app renders frames. Bottom lane: what the screen shows at each vsync. Red cells are a repeated frame. Pick a pattern of render times.

A model with one frame in flight: the app starts a frame at the vsync that shows the previous one, and its frame appears at the first vsync after it finishes. The 8 ms and 14 ms times are the lesson’s example at 90 Hz (11.1 ms budget). Half rate means the app runs at 45 fps and the system fills the gaps (Chapter 5).

Look at Always 14 ms. The render needs 14 ms but the budget is 11.1 ms. Every frame finishes after the tick, so it waits for the next one. The screen shows each picture twice. The app delivers 45 new frames per second, half of 90.

Now look at 8 then 14 ms. The average render time is 11 ms, almost exactly the budget. You might expect it to work. It does not. Each slow frame misses its tick, and the screen repeats the old picture. In the model, 4 of 12 ticks repeat.

That is the first lesson of frame budgets. The average does not matter. Each frame must meet its own deadline.

The failure, as symptom, measurement and fix

The symptom is judder: a stutter that you feel mostly when you move your head or when something moves across the view. The measurement is a count of vsyncs that showed an old frame. Runtimes report it as dropped or missed frames.

There are two fixes. One is frame pacing: control when the app starts each frame so that it ends just before the deadline (Chapter 5). The other is to run the app at half rate on purpose and let the system synthesise the frames between (also Chapter 5). A third family hides the problem for head turns: timewarp (Chapter 4).

What the hero at the top is showing

The hero joins every part of this lesson into one toy. It uses the same model. The top shows the lanes you just met. The bottom shows what you see: the dashed posts are where the world should be, and the solid posts are where the headset draws it.

Every number the hero shows comes from a simple model. The Field Guide lists which numbers are measured facts and which are illustrative.

The road

  1. Why latency matters: your eyes expect the world to stay still, and the error is head speed times delay.
  2. Scan-out and persistence: the panel draws rows over time, so there is no single “now”.
  3. Prediction and late latching: guess the pose at the time of display, and read it as late as possible.
  4. Asynchronous timewarp: re-aim the last frame just before vsync. Rotation only.
  5. Spacewarp and frame pacing: synthesise frames, and start each frame at the right moment.
  6. GPU scheduling: the compositor must be able to interrupt the app.
  7. Passthrough: camera to display with a 12 ms budget.
  8. Foveation and wireless: spend pixels where the eye looks, and ship frames over a network.
  9. Field Guide: numbers, a checklist, the core code and the sources.
At 90 Hz, an app renders frames that alternate between 8 ms and 14 ms. What does the screen show?

Chapter 1

Why Latency Is the Sine Qua Non

Work out how many degrees of error a given delay puts on screen, and why one bad frame matters

Hold your thumb up at arm’s length. Turn your head left while you stare at the thumb. The thumb stays sharp and still, even though your head is moving fast. Your eyes did that without you asking.

The trick is the vestibulo-ocular reflex, or VOR. Your inner ear senses the head turn. It tells the eye muscles to rotate the eyes the opposite way at the same speed. The picture on your retina stays put.

A headset has to play along. When your head turns, the whole virtual world must turn the other way by the same angle, right now. If the picture is late, the world seems to drag behind your head. This effect is called world swim.

Two senses that disagree

Your inner ear reports a head turn at once. Your eyes report that the world moved late. The two senses disagree. People often feel this as unease, and for some it grows into nausea.

Abrash called latency the sine qua non of VR and AR, Latin for the thing without which nothing else works. Great optics and fast chips do not help if the picture lags the head. He argued for an upper bound near 20 ms, and the VR industry has used that figure as its target since.

The arithmetic of error

The error is easy to compute. The head keeps turning while the system works. If the picture is built for the pose at the start, the world is behind by the angle the head turned in the meantime.

e
The angle of error, in degrees, between where the world is drawn and where it should be.
ω
How fast the head turns, in degrees per second.
Tmtp
The motion-to-photon latency, in seconds.

Take a quick head turn of 300 degrees per second. The delay is 20 ms, which is 0.02 s. The error is 300 × 0.02 = 6 degrees. At 500 degrees per second the error is 10 degrees. These head speeds are illustrative: people turn faster and slower than this, and a headset must cope with the fast end.

How large is 6 degrees? A modern headset packs roughly 20 pixels into each degree of view. That is an illustrative figure, and it varies by device. Six degrees would then be about 120 pixels. The whole world slides sideways by a hand-width on the screen.

The bound also shows why the target is so hard. At 20 ms and 90 Hz, you have less than two frame budgets for the entire pipeline.

Averages hide the bad frames

Suppose a system reports a mean latency of 18 ms. That sounds good. Now suppose one frame in 200 takes 40 ms. At 90 Hz there are 90 frames each second, so such a frame arrives roughly every 2 seconds.

The mean barely moves, from 18 to about 18.1 ms. But the picture lurches once every 2 seconds, and your vision is tuned to catch a single wrong movement. Play with the device and compare the two modes.

Turn delay into degrees

Top: the dashed posts are the true world, the solid posts are what the headset draws late. Bottom: how long each of 2,000 frames took. Drag the head speed and the mean latency. Then try the spiky mode.

300 deg/s
18 ms

Illustrative: 20 pixels per degree, frame latencies drawn from a seeded normal spread of 1.2 ms around the typical value, and spikes added 22 ms above it (18 + 22 = 40 ms at the default). The error formula is exact for a constant head speed.

With the spikes on, the histogram shows a tiny second bump far to the right. It is only a few frames out of 2,000. At 300 degrees per second, that bump means a 12 degree error on those frames, twice what the typical frame shows.

The failure, as symptom, measurement and fix

The symptom is an occasional hitch that no average explains. The measurement is a per-frame latency histogram, or a plot of latency against time, with the worst frames marked. Report the 99th percentile and the worst frame, not only the mean.

The fix depends on the cause. A spike usually comes from one stage running long: a garbage collection, a thread scheduled late, a GPU job blocking the compositor. Chapters 5 and 6 cover these.

A person turns their head at 400 degrees per second. The system has 25 ms motion-to-photon latency. About how big is the world-swim error?

Chapter 2

Scan-out, Persistence and Predicting to Mid-Frame

Learn why a screen has no single moment of now, and which moment a pose should aim for

Watch a slow-motion video of a phone screen. The picture is not drawn all at once. A bright band sweeps from the top to the bottom. Each row of pixels gets its new colour a little after the row above it.

This sweep is the scan-out. Most panels update in this raster pattern, because the display cable sends the picture one row after another. The panel uses most of the frame budget for it. At 90 Hz the budget is 11.1 ms, and the scan-out can take most of that time.

That means the top row lights up earlier than the bottom row. They are different moments. A head that turns during the scan-out is in a different place for each row.

Which pose should the frame use?

A frame is drawn with one pose. The panel shows it over about 10 ms. Which instant should that pose belong to? You must choose, and each choice puts the error in a different place.

The error for a row is the head speed times the gap between the row’s light-up time and the pose’s time. Let trow be the time that row lights up, and tpose the time the pose is meant for.

erow
The angle of error for one row of the screen, in degrees. Positive means the world lags behind the head.
ω
Head speed, in degrees per second.
trow
The moment that row of pixels lights up.
tpose
The moment the drawn pose was meant to describe.

Set the time zero at the start of the scan-out. At 90 Hz with a scan-out of 90% of the period, the scan-out lasts 10 ms. Then the top row has trow = 0 and the bottom row has 10 ms.

Now try three choices at 300 degrees per second. Aim at the start of scan-out and the bottom row lags 300 × 0.010 = 3 degrees. Aim at the middle (5 ms) and the top row is 1.5 degrees ahead and the bottom 1.5 degrees behind. Aim per row, and every row is right. The worst error is half as large with the middle aim.

Aim the pose, see the tilt

The grey post is the true world. The coloured post is what the panel draws. A tilted post means the rows disagree. Pick an aim time, then switch persistence.

300 deg/s

Illustrative: 90 Hz (11.1 ms), scan-out over 90% of the period (10 ms), 20 pixels per degree, 2 ms for low persistence. The sweep is shown in slow motion. The head moves at a constant speed and the post tilt is drawn at 4 times scale so it stays visible; the numbers are not scaled.

Try Aim at scan-out start. The post tilts: the bottom lags. Switch to Aim at mid scan-out. The tilt stays, but it is balanced around the middle. Switch to Aim per row. The post stands straight.

Persistence: how long a pixel stays lit

There is a second effect. Persistence is how long each pixel stays lit after it is drawn. On a full-persistence panel the pixel shines for the whole frame. Your eye keeps turning while the pixel stays still, so it smears the picture across your retina.

The smear width equals head speed times persistence. At 300 degrees per second and 11.1 ms, the smear is 3.3 degrees, about 67 pixels. A low-persistence panel lights the pixel for only a short flash. With 2 ms, the same head turn smears just 0.6 degrees, about 12 pixels.

This is why predicting well does not fix a full-persistence panel. A perfect pose still gives a blurred picture. VR headsets use low persistence for this reason. The flash is short, so the panel needs to be bright.

The failure, as symptom, measurement and fix

The symptom of aiming at the wrong time is a tilt or a wobble: vertical edges lean during a head turn, or the scene seems to lag at the bottom and lead at the top. The measurement is a high-speed camera pointed at the panel, with a known test pattern, while the head turns on a rotating rig.

The fix is to aim the pose at the right instant. Aim at the middle of the scan-out for a single pose per frame. Better, warp each strip of rows to its own time, which is what Chapter 4’s timewarp can do. And pick a low-persistence panel.

The hero uses the middle of the scan-out: the half-scan-out term of the model is 5 ms at 90 Hz. That is why the timewarp figure there is 7 ms, not 2 ms.

At 300 degrees per second the scan-out lasts 10 ms. You aim one pose at the middle of the scan-out. What is the largest row error?

Chapter 3

Pose Prediction and Late Latching

Predict where the head will be at display time, and read the pose as late as the hardware allows

Imagine catching a ball thrown across a room. You do not reach for where the ball is now. You reach for where it will be when your hand closes. Your brain predicts, using the ball’s speed.

A headset faces the same job. The frame it draws now will be seen 10 to 30 ms from now. The head will be somewhere else by then. The renderer must draw for the future pose, the one the head will have when the light leaves the screen.

The horizon

The gap between the moment the pose was measured and the moment the picture is displayed is the prediction horizon. It is the number the whole pipeline tries to shrink. A pose sampled at the start of a CPU frame, drawn by the GPU in the next frame, and scanned out in the middle of the one after, has a long horizon.

At 90 Hz, with a render that fits one frame, the stages add up like this. The CPU runs one frame ahead: 11.1 ms. The GPU render takes one frame to the next vsync: 11.1 ms. The scan-out reaches mid-screen: 5 ms. That is 27.2 ms of horizon.

The platform helps with the clock. In OpenXR, the call xrWaitFrame returns a predictedDisplayTime, the time when the runtime expects the frame to be shown. The app asks for the head pose at that time, not at the current time. The runtime does the extrapolation.

How to predict

The simplest predictor is constant velocity. Fit a straight line to the last few angle samples and extend it. It is exact if the head turns at a steady speed.

Heads do not turn at a steady speed. They speed up and slow down. A constant acceleration predictor fits a parabola instead. It follows the curve, but it needs more samples to find the bend, and noise hurts it more.

The error of the straight line is easy to estimate. If the true angle has acceleration a, the straight-line guess is off by about half a times the square of the horizon.

e
The prediction error of a straight-line guess, in degrees.
a
How fast the head’s turn speed is changing, in degrees per second squared.
h2
The prediction horizon squared. Double the horizon and the error grows four times.

Take a head that nods back and forth as 40 sin(2π × 1.2 t) degrees. Its top speed is about 300 degrees per second, and its largest acceleration is about 2,270 degrees per second squared. At h = 27 ms the straight line errs by ½ × 2270 × 0.027² = 0.83 degrees at the turning point. At h = 7 ms it errs by 0.06 degrees. The horizon matters more than the predictor.

Predict the head, shrink the horizon

Top: a head nod near its turning point. The pose is measured at the left dot and shown at the right edge. Bottom: how error grows with the horizon. Pick when the pose is read.

0.02 deg

Synthetic data: a 40 degree, 1.2 Hz nod sampled at 1 kHz with seeded Gaussian noise. Straight-line fit: last 12 samples. Parabola fit: last 30 samples. Errors are measured over 230 predictions in a 2 s run. The horizons (27.2, 16.1, 7.0 ms) follow the model of this lesson at 90 Hz; they are illustrative, not measured.

Choose Late latched at GPU start. The horizon drops by one whole frame, from 27.2 to 16.1 ms. Choose Read by the compositor (Chapter 4). The horizon drops to 7 ms. Turn the noise up and watch the parabola lose ground: it needs the slope of the slope, and noise swamps that first.

Late latching

Why is the pose read so early in a normal pipeline? The CPU records the GPU’s drawing commands one frame ahead, so the GPU never waits. Those commands need the pose, so the CPU must read it early.

Late latching fixes this. The CPU does not put the pose inside the commands. It leaves a place for it in a small memory buffer. A side channel keeps updating that buffer with the newest pose. The GPU latches, that is, copies in, the newest value just before it runs the frame’s commands.

Meta’s documentation says late latching can remove up to one frame of latency from head and controller poses. It also notes a cost: the CPU never sees the final view matrix, so any code that uses it must move to the GPU, even into the vertex shader. On Quest the feature needs Multi-View and the Vulkan API.

The failure, as symptom, measurement and fix

The symptom is a consistent lag during head turns even when no frame is missed. The measurement is the difference between each frame’s pose timestamp and its display time, logged per frame. A pose that is 27 ms old at display time is the problem, not a late frame.

The fix is to read the pose later: late latching for the app, a fresh read in the compositor for timewarp. The prediction then needs to look ahead only a short distance, and the error stays small.

The prediction horizon drops from 27 ms to 16 ms. Roughly how does the straight-line prediction error change?

Chapter 4

Asynchronous Timewarp

Re-aim the last finished frame with the newest head rotation, and see why that fixes turning but not moving

You take a photo of a street, then you realise you pointed the camera a little too far left. You cannot take it again. But you can slide the printed photo a few centimetres to the right inside its frame. The scene now lines up with where the camera really points.

That is the whole idea of timewarp. The app has finished a picture drawn for an older head angle. Just before the screen needs it, a system program shifts that picture to match the newest head angle. The shift is cheap compared with drawing a new scene.

Why it is called asynchronous

The word asynchronous means the warp runs on its own clock, not the app’s clock. A separate, high-priority program, the compositor, wakes up shortly before every vsync. It takes the latest frame the app has finished. It reads the newest head rotation. It warps the frame and sends it to the panel.

The app may be late, even absent for a vsync. The compositor still delivers something at every tick: the old frame, re-aimed. So the warp does two jobs. It shortens the latency of rotation, and it hides a missed frame from head turns.

Oculus put this into the Rift with PC SDK 1.3, turned on by default for every app, around the Rift’s consumer launch in March 2016. Their blog states that it needs no code changes and costs the app nothing. J. M. P. van Waveren’s VRST 2016 paper describes the design: warp every frame on a high-priority thread, using the app’s last frame.

Why a rotation needs no depth

Picture the eye as the centre of a sphere with the scene painted on the inside. Turn the head by an angle and every point on that sphere turns by the same angle. All points move together, near or far. So the picture can be shifted as a flat image, with no knowledge of distance.

In maths, a pixel at position p in the old frame maps to a pixel p′ in the new frame through a 3 × 3 matrix.

p′
The pixel position in the warped frame, as a 3-vector (x, y, 1).
K
The camera matrix: it turns a viewing direction into a pixel. It holds the focal length in pixels and the image centre.
R
The rotation between the head pose used for drawing and the newest head pose. A 3 × 3 rotation matrix.
K−1
The inverse of K: it turns a pixel back into a viewing direction.
p
The pixel position in the original frame.

The data flow is short. The input is the finished eye texture (width × height × 4 bytes of colour) and two head orientations, each a unit quaternion of 4 numbers. The output is a new texture of the same shape. Per pixel, the GPU does one matrix multiply and one texture lookup.

A worked number. A head turns 5 degrees between drawing and display. At 20 pixels per degree (illustrative) that is a 100 pixel shift. The warp slides the whole picture 100 pixels, and the sky and the cup on the desk line up again.

Why translation breaks it

Now move your head sideways instead of turning it. Hold a finger close to your face and look at a tree far away. Shift left by 2 cm. The finger seems to jump across the view. The tree barely moves. This difference is parallax: near things shift more than far things.

The size of the shift is the movement divided by the distance. For 2 cm: a cup at 0.5 m shifts by 0.02 / 0.5 = 0.04 radians, which is 2.3 degrees. A mountain at 10 m shifts by 0.11 degrees. A flat warp cannot know each object’s distance, so it cannot do this. The picture is warped by rotation only.

Oculus says the same in its blog: ATW corrects only the rotational change, and any translation since the frame was drawn is ignored. That causes positional judder. If you keep your head still and only look around, the error is small.

Rotate, then move

Dashed marks: where the near cup and far mountain should appear now. Solid marks: where the headset draws them. Set how far your head turned and moved since the frame was drawn, then switch timewarp on.

5 degrees
2 cm

Geometry is exact for small angles: shift in degrees = (sideways move / object distance) × 57.3. The cup is at 0.5 m and the mountain at 10 m (illustrative). The view is drawn at 20 pixels per degree, shrunk to fit.

Set the rotation to 10 degrees and the movement to 0, and toggle the warp. The error goes to zero for both objects. Now set the movement to 10 cm. The cup stays 11 degrees off even with timewarp on, while the mountain is nearly right.

The failure, as symptom, measurement and fix

The symptom is that the world holds still when you turn but shimmers when you walk, lean, or when something in the scene moves. The measurement is the app’s own frame rate. If it is below the refresh rate, timewarp is hiding it from rotation only. Oculus stresses that timewarp is not a substitute for hitting frame rate: apps that fall below 90 fps still show judder in animation and player movement.

The fix for the rest is to hit the frame rate, to add positional reprojection from the depth buffer (which Meta later announced as positional timewarp), or to use spacewarp (Chapter 5). In the hero, the screen row with ATW on marks repeated frames as warped. The posts stay in place, but the small square still steps at 45 updates per second.

An app runs at 45 fps on a 90 Hz headset with timewarp on. You turn your head. A ball rolls across the floor. What do you see?

Chapter 5

Spacewarp and Frame Pacing

Fill the gaps with synthetic frames, and start each frame so that it ends just before its deadline

Timewarp left a gap. When the app is slow, the head turns look right but the animation steps at the app’s own rate. Your hand, a ball, a walking character all update 45 times per second on a 90 Hz screen. Rotation is saved. Motion is not.

Two tools attack that gap from different sides. Spacewarp invents the missing frames. Frame pacing makes the real frames arrive on time. Real headsets use both.

Spacewarp: make a frame from motion

Suppose the app renders only every other frame. Between two real frames, the system must show something. A repeated frame looks like a stutter. A better idea is to guess what the frame would look like.

To guess, the system needs to know how each part of the picture is moving. The answer is a motion vector: for each block of pixels, an arrow that says where it is going between frames. It also helps to know how far away each pixel is, which is the depth buffer. Then the system moves the pixels along their arrows and fills the new frame.

Oculus enabled Asynchronous Spacewarp (ASW) on PC on 10 November 2016, with runtime 1.10. It turns on when a game falls below 90 fps and locks the game to 45 fps, with a synthetic frame between each pair of real ones. It estimates motion from the finished frames.

Application SpaceWarp (AppSW) came to Quest in 2021. Here the app supplies the motion vectors and the depth buffer, so they are more accurate than a guess. The app renders at half the display rate, and Meta lists the pairs: 36 fps for a 72 Hz display, 45 for 90 Hz, 60 for 120 Hz. Meta reports it can give the app up to 70 percent more render time.

The trade is worth stating plainly. The app now gets two frame budgets per real frame: 27.8 ms at 72 Hz, 22.2 ms at 90 Hz, 16.7 ms at 120 Hz. In exchange, half of the frames the eye sees are synthetic, and synthesis has artifacts. Meta lists fast brightness changes, trails behind moving objects, and repeating patterns as trouble spots.

Frame pacing: choose the start

Now the other tool. An app that always starts its frame right when the last one ends finishes early and then waits. The pose it used sits idle while the app waits. Starting later would give a fresher pose. But start too late and the frame misses its tick.

Frame pacing is the art of choosing the start so the frame ends just before the compositor’s deadline. The ideal start is the deadline minus the render time minus a safety margin.

tstart
When the app should begin its frame.
tdeadline
The moment the compositor needs the finished frame, a little before vsync.
R̂
An estimate of the render time. Use the largest of the last several frames, not the mean.
m
A safety margin for noise, in milliseconds.

OpenXR builds this in. The call xrWaitFrame blocks until the right moment to start and returns a predictedDisplayTime. The specification says the runtime can change its throttling based on feedback from xrEndFrame, and may shift the start of the frame interval to reduce GPU contention. The runtime learns from your past frames.

Why use the largest recent render time and not the mean? A deadline is missed by the worst frame, not by the average one. Using the mean would miss every spike.

Find the latest safe start

120 frames with noisy render times. Drag the start delay as late as you can. Later means a fresher pose, but a missed deadline means a repeated frame. Compare with the two policies.

3.0 ms

Illustrative: render time is 0.45 of the frame budget on average with a spread of 0.05, plus a 0.15 jump on 1 frame in 12, seeded so every visit is identical. The compositor needs the frame 1 ms before vsync. Pose age is measured from the app’s pose read to mid-screen scan-out, with late latching. Naive means start at the tick. Adaptive means start at the deadline minus the largest of the last 8 render times, minus 0.3 ms.

The picture shows each frame as a dot: its start offset plus its render time. A dot above the deadline line is a miss. The naive policy never misses but uses a pose that is old by nearly the whole budget. Your slider sits somewhere between a stale pose and a missed deadline. The adaptive policy tracks the noise frame by frame and gets most of the gain without a miss.

Oscillation

A pacing loop can also fight itself. Suppose the app starts later after a quick frame, and the later start makes the next frame miss. The app then starts earlier, which makes the next frame quick, and so on. The result is the 8 ms and 14 ms alternation of Chapter 0.

The symptom is a regular stutter. The measurement is the start time and finish time of each frame, plotted over many frames. Two stripes mean oscillation. The fix is an adaptive start with a margin (above), or running at half rate with AppSW on purpose. When the render cost is near the budget, a steady 45 fps with synthesised frames feels better than an alternating 90 and 45.

A scene needs 15 ms to render on a 90 Hz headset (11.1 ms budget). Which choice keeps motion smooth?

Chapter 6

GPU Scheduling and the Compositor’s Priority

See why timewarp only works if it can interrupt the app, and how one long GPU job breaks it

An ambulance needs to cross a busy junction. The drivers in front must make room. If a long lorry is halfway through the junction and cannot reverse, the ambulance waits. The siren does not help. Priority only works if the others can yield.

Timewarp is the ambulance. It has a hard deadline each frame. The app’s GPU work is the lorry. This chapter is about whether the lorry can make room in time.

Two programs, one GPU

A GPU is built for throughput: do a huge amount of work per second. It is much less well built for preemption, which means pausing the work in progress so that urgent work can run first. A GPU job, such as one large compute dispatch (a command that launches many threads at once), may run for several milliseconds with no pause point.

The Oculus team wrote that modern PC GPU hardware and software were optimised for very high throughput, not for preemption. To make timewarp work on the Rift, Oculus worked with Microsoft, NVIDIA and AMD, who changed the operating system’s GPU scheduling, the command-processor microcode and the kernel driver. The ambulance needed new roads.

The CPU has the same rule. The compositor’s thread must run when it is due. On Linux that means a real-time scheduling class such as SCHED_FIFO, as the real-time Linux lesson explains. A normal-priority thread can be delayed by any other task. GPU priority works the same way, one level down.

The budget of the warp

The warp itself is light, but it has a hard start. Say it needs to start 2 ms before vsync to finish in time, and it can tolerate 1 ms of delay in starting. Call that 1 ms its slack. Any wait longer than the slack means the warp misses vsync, and the panel shows the previous frame again.

The wait depends on the app’s job. Let the job run for L ms and start at a random moment. If it is running when the warp is due, the warp waits until the GPU can switch. If the job has no pause points, the wait is the time left in the job. If the app splits the job into chunks of size g, the wait is at most g.

wmax
The longest the compositor can wait for the GPU, in milliseconds.
L
The length of the app’s GPU job.
g
The size of a chunk. The GPU can switch tasks at the boundary between chunks. An unsplit job has g = L.

A worked case. An app launches one 8 ms compute dispatch every frame at 90 Hz (11.1 ms). The warp must start at 9.1 ms. Whenever the dispatch is running at that moment, the worst wait is 8 ms, far above the 1 ms slack. If the dispatch starts between 2.1 and 9.1 ms into the frame, the wait is above 1 ms and the warp is late. That is 7 of 11.1 ms, or 63% of start times. Split the job into 0.5 ms chunks and the worst wait is 0.5 ms, below the slack, so none miss.

Interrupt the lorry

One frame of GPU time at 90 Hz. The warm bar is the app’s job. The purple bar is the warp, due at the line. Move the job’s start, then change its chunk size and priority.

8 ms
3.0 ms

Illustrative GPU model: one job per frame, 90 Hz, the warp is due at 9.1 ms (2 ms before vsync) and tolerates 1 ms of delay. Without GPU priority the warp waits for the entire job to end. The share of failing start times is computed over 1,000 evenly spaced start times.

Set the job to 8 ms and leave it unsplit. Drag the start through the frame. Most positions turn the warp late. Switch to 0.5 ms chunks and the share drops to nothing. Turn the priority off and chunks stop helping: the warp queues behind everything.

The failure, as symptom, measurement and fix

The symptom is an occasional repeated frame, even though the app seems fast and the average GPU time is low. During a head turn it can look like a double image, because the panel lights the same picture twice at two head positions. The measurement is a GPU timeline: tools such as Nsight Graphics, RenderDoc, and Perfetto’s GPU tracks on Android show each queue’s work over time, so you can see the compositor waiting.

The fix has three parts. Split long dispatches so they can be paused. Give the compositor a high-priority queue. Keep its CPU thread in a real-time class. Then check the timeline again, because a driver update can change the behaviour.

The compositor tolerates 1 ms of delay. The app launches one 6 ms dispatch with no pause points, at a random time each frame. What is the best fix?

Chapter 7

Passthrough: Photon-to-Photon

Follow light from the room, through a camera, to the screen, and count where an ordinary video pipeline loses 30 ms

So far the headset drew a virtual world. Now it must show you the real one. You wear a headset that covers your eyes. Cameras on the front film the room, and the screens show you the video. You reach for a coffee cup. Your hand must arrive where the picture says it is.

This is passthrough. The delay here has a different name: photon-to-photon latency. It is the time from light hitting the camera sensor to light leaving the screen. There is no pose to predict and no scene to render, but there is a camera, which brings new stages.

The chain, stage by stage

  1. Exposure and readout: the sensor collects light, then reads out its rows.
  2. The ISP (image signal processor, the chip that turns raw sensor data into a clean image) fixes colour, noise and distortion.
  3. Transfer: the image moves over a camera link into memory. The first lesson of the camera track, sensor to CSI, covers that link.
  4. Reprojection: the cameras sit in front of your eyes, not at them. The image must be warped to match the view from your eyes.
  5. Compositing: virtual objects and the camera view are merged and sent to the panel.
  6. Scan-out, exactly as in Chapter 2.

Every stage that holds a whole frame before passing it on adds a full frame of delay. A camera at 60 frames per second has a 16.7 ms frame. Two buffers in the path add 33 ms by themselves. That is how a plain video pipeline reaches 30 to 60 ms.

What the measurements say

Apple says its R1 chip streams new images to the displays within 12 ms. The R1 is a separate chip next to the main processor. It receives data from 12 cameras, five sensors and six microphones, according to coverage of Apple’s announcement.

In February 2024 OptoFidelity published a test. They placed an LED in front of the headset and a fast light sensor (100 kHz) behind the lens. They measured the time between the LED lighting up and the screen lighting up. The Vision Pro measured about 11 ms. The HTC Vive XR Elite, Meta Quest 3 and Meta Quest Pro were in the 35 to 40 ms range.

Two honest notes. OptoFidelity reported the minimum latency, not the mean or the median. And on a separate head-motion test, called angular latency, the Meta headsets did better, which the report credits to their use of prediction. Photon-to-photon latency measures the camera view of a still scene against a light flash. It does not capture everything.

The device below uses an illustrative budget for two designs, not measurements of any product. It shows where the milliseconds go.

Build a passthrough budget

Choose a pipeline. The coloured bar adds up its stages. The lower bars are reference values from the published test. Watch what the frame buffers cost.

The stage times are illustrative, chosen to show the effect of buffering at 60 fps camera, 90 Hz display. They are not measurements of any headset. Reference bars: Apple specifies 12 ms; OptoFidelity measured about 11 ms for Vision Pro (minimum value) and 35 to 40 ms for Vive XR Elite, Quest 3 and Quest Pro.

The ordinary pipeline totals 48 ms. Take away the frame queue and the app copy, and the bar falls to 21 ms. A dedicated path that streams rows from the sensor to the display without ever holding a full frame reaches 11 ms. The savings come from structure, not from faster chips.

The failure, as symptom, measurement and fix

The symptom is a clumsy hand. People miss the cup, walk carefully, and feel sick when they move. The measurement is a photon-to-photon rig: a light source and a fast sensor, as above, or a high-speed camera filming a flashing light and the screen. Run it many times and report the distribution, not only the minimum.

The fix is to design the camera path as a real-time path from the start. Stream rows instead of whole frames. Put the camera in the compositor’s reach, with a fixed small buffer. Warp for the eye viewpoint in the same pass that warps for head rotation. A path built as a general video pipeline will not reach 12 ms.

A passthrough path holds one whole frame in the ISP, one in the camera driver and one in the compositor, at 60 frames per second. How much delay do the three buffers add?

Chapter 8

Foveation and Wireless

Spend pixels where the eye looks, and see how a slow eye tracker or a network adds new delays to the budget

Hold your arm out and look at your thumbnail. Everything else in view is soft. Only a tiny patch of the retina, the fovea, sees fine detail. It covers a few degrees of the view. The rest of the picture could be blurry and you would not notice, as long as it stays blurry only where you are not looking.

A headset can use this. Foveated rendering draws a sharp, full-resolution disc where you look and a cheaper, coarser picture everywhere else. The GPU saves a large share of its work. That helps the frame budget of Chapters 0 and 5, since a cheaper render fits more easily.

The catch: the eye moves fast

Your eyes jump from one point to another in quick moves called saccades. During one, the gaze sweeps many degrees in a few tens of milliseconds. You do see a sharp picture when it lands.

The sharp disc must follow the gaze. An eye tracker, a small camera pointed at each eye, reports where you look. Its delay, plus the render and display delay, is the foveation latency. During that time the disc still sits where your eye was.

Work out the cost. Say the eye jumps 20 degrees. A common rule of thumb gives a saccade duration near 2.2 ms per degree plus about 21 ms. That is illustrative, and real saccades vary. For 20 degrees it is about 65 ms. The gaze lands at 65 ms. If the foveation latency is 40 ms, the disc starts to move at 40 ms and is still on its way when the eye lands. The eye sits on a blurry part for a short while.

tblur
How long the eye looks at a blurry area after it lands, in milliseconds. Zero or less means no visible pop.
tarrive
The moment the sharp disc comes within its radius of the new gaze point.
Tsacc
The duration of the saccade.

Two knobs help. A bigger disc means the disc only needs to come close, so it arrives sooner, but more of the picture is expensive. A faster tracker shrinks the latency. Try both below.

Chase the gaze

The teal curve is where you look. The warm curve is the centre of the sharp disc. The band is the disc’s radius around your gaze. Red marks time you spend looking at blur after landing.

20 degrees
40 ms
5 degrees

Illustrative model: the gaze follows a smooth S-curve of duration 2.2 ms per degree plus 21 ms; the disc copies the gaze after the latency. Real saccades, trackers and renderers vary. The sharp disc costs more the bigger it is; the share of the view it covers is not modelled here.

At the defaults the 20-degree jump takes 65 ms. The disc comes within 5 degrees of the target at 84 ms, so you look at blur for 19 ms. Raise the latency to 60 ms and the blur grows to 39 ms. Cut it to 10 ms and the blur falls to nothing. Widen the disc to 15 degrees and the pop also vanishes, but the expensive area grows.

The symptom is a blur that pops into focus just after you look at something. The measurement is the end-to-end foveation latency, from eye movement to the disc moving on screen, tested with a rig. The fix is a faster tracker, a prediction of where the saccade will land (a saccade’s path is highly regular), or a larger disc.

Wireless: a longer pipe

Now cut the cable. In wireless VR a PC renders the frame, encodes it (compresses it as video), sends it over Wi-Fi, and the headset decodes and shows it. The video lesson, low-latency video, covers these stages in depth. Each adds time.

An illustrative case: 8 ms to encode, 8 ms over the air, 6 ms to decode. That is 22 ms added before the headset can show anything. A pipeline with a full-frame encoder buffer adds even more.

The cure for rotation is the same as before. Client timewarp means the headset itself warps the last received frame with its own newest head rotation. The network delay then does not affect how the world turns with the head. It still delays everything else: your hands, moving objects, and the translation of your head. Those are as old as the network round trip.

The fix for the rest is to shrink the pipe. Use low-latency encoder settings with no frame reordering and small buffers. Encode in slices so the decoder can start before the frame ends. Predict hand and head positions farther ahead. Measure the whole chain with the same rig as passthrough.

A wireless headset adds 22 ms of encode, network and decode time and uses client timewarp. What lags by those extra 22 ms?

Chapter 9

The Field Guide

Keep the numbers, the checklist and the core loop on one page, and see where to go next

You can now follow a head turn through the whole pipeline and say what each stage costs. This page holds the short version, with the source of every number.

The one-paragraph summary

A headset must show new light within about 20 ms of a head turn, or the world swims. Each frame has a budget of 1000 divided by the refresh rate, and each frame must meet its own deadline. The pose should be read as late as possible, by late latching, and predicted to the moment the panel shows it. Asynchronous timewarp re-aims the last frame with the newest head rotation, on a high-priority compositor that must be able to interrupt the app on the GPU. It fixes rotation and nothing else. Spacewarp synthesises frames from motion vectors so the app can run at half rate. Frame pacing picks the start of each frame so it ends before the deadline. Passthrough, foveation and wireless add their own stages to the same budget.

The numbers that matter

WhatNumberSource or status
Frame budget at 72, 90, 120 Hz13.9, 11.1, 8.33 ms1000 / Hz, computed
Motion-to-photon target20 ms or less for VR; 15 or 7 ms mentioned for ARAbrash, Latency: the sine qua non of AR and VR (2012); his own hedged figures, not a standard
Rotation errorhead speed × latency: 300 deg/s × 20 ms = 6 degrees; 500 deg/s × 20 ms = 10 degreesArithmetic. The head speeds are illustrative
Timewarp on the RiftOculus PC SDK 1.3, on by default, around the March 2016 launchOculus developer blog; AnandTech launch-day report
Asynchronous Spacewarp (PC)enabled 10 November 2016, runtime 1.10; 45 fps under a 90 fps targetPC Perspective report
Application SpaceWarp (Quest)36, 45, 60 fps at 72, 90, 120 Hz; app supplies motion vectors and depth; up to 70% more render timeMeta, as reported by Road to VR
Late latchingremoves up to 1 frame of pose latency; needs Multi-View and Vulkan on QuestMeta developer documentation
Passthrough, Vision Pro12 ms specified; about 11 ms measured (minimum value)Apple; OptoFidelity test
Passthrough, rivalsVive XR Elite, Quest 3, Quest Pro: 35 to 40 msOptoFidelity test
Lesson model at 90 Hz, 11 ms renderpose horizon 27.2 ms, with late latching 16.1 ms, with timewarp 7.0 msIllustrative model of this page, not a measurement

The terms

The checklist

  1. Log the pose timestamp and the display time of every frame. The gap is your horizon.
  2. Plot the per-frame latency, not the mean. Mark the 99th percentile and the worst frame.
  3. Count repeated frames per minute. If the count is not zero, find the stage that misses.
  4. Check that the compositor has high CPU and GPU priority. Run a GPU timeline and look for waits.
  5. Split any GPU job longer than the compositor’s slack into chunks.
  6. Read the pose late: late latching for the app, a fresh read in the compositor.
  7. Choose the start of the frame from the largest recent render time. Do not use the mean.
  8. If the render cost sits near the budget, run at half rate with spacewarp and test the artifacts.
  9. For passthrough, measure photon to photon with a light and a fast sensor. Count frame buffers.
  10. For foveation and wireless, add the tracker, encoder, network and decoder times to the budget before you promise anything.

The core, as code

First the loop. This is the shape of an OpenXR frame loop in C. It is a sketch: setup and error checks are left out.

cwhile (running) {
    XrFrameState fs = { XR_TYPE_FRAME_STATE };
    xrWaitFrame(session, NULL, &fs);          // blocks: the runtime paces the start of the frame
    xrBeginFrame(session, NULL);

    XrViewLocateInfo li = { XR_TYPE_VIEW_LOCATE_INFO };
    li.viewConfigurationType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO;
    li.displayTime = fs.predictedDisplayTime;   // ask for the pose AT display time, not now
    li.space = local_space;
    XrViewState vs = { XR_TYPE_VIEW_STATE };
    XrView views[2] = { { XR_TYPE_VIEW }, { XR_TYPE_VIEW } };
    uint32_t n;
    xrLocateViews(session, &li, &vs, 2, &n, views);   // 2 poses: position (3 floats) + orientation (4 floats) each

    render_eyes(views);                         // keep every GPU job short enough to preempt

    XrCompositionLayerProjection layer = make_layer(views, swapchains);   // carries the pose used, so the compositor can warp
    end_frame(session, fs.predictedDisplayTime, &layer);                 // xrEndFrame feeds timing back to xrWaitFrame
}

Then the model this page used, in a few lines of Python. Change the arguments and compare with the hero.

pythonimport math

def motion_to_photon(hz, render_ms, late_latch=False, timewarp=False, scan=0.9, warp_lead_ms=2.0):
    p = 1000.0 / hz                                   # frame budget, ms
    n = max(1, math.ceil(render_ms / p))                 # periods the app needs per frame
    half_scan = scan * p / 2                           # time to reach mid-screen
    lead = 0.0 if late_latch else p                      # CPU runs one frame ahead unless the pose is late latched
    app = lead + n * p + half_scan + (n - 1) * p / 2   # pose age, with repeated frames
    rotation = warp_lead_ms + half_scan if timewarp else app
    return app, rotation                              # translation sees app, rotation sees timewarp

print(motion_to_photon(90, 14, timewarp=True))   # (43.9, 7.0): translation lags 43.9 ms, rotation 7.0 ms

On real hardware

You can repeat the central measurement without a lab. Take a Quest or any OpenXR headset with a developer mode. Log predictedDisplayTime and the time your app calls xrEndFrame for 1,000 frames. Plot the slack to the deadline. Then add a deliberate 6 ms GPU dispatch and plot again. Count the repeated frames the runtime reports. This is a small version of the test in Chapter 6.

Where this sits

The head pose that these chapters predict comes from a tracking system. Classical visual-inertial odometry and modern VIO build it from cameras and an IMU, and the Kalman filter is the usual way to fuse the two. The camera link in passthrough starts with the sensor and its CSI bus, and the buffers behind it are the topic of V4L2 and the buffer queue. Wireless streaming builds on low-latency video. Priority and scheduling on the CPU side come from real-time Linux, embedded real-time systems and real-time performance in robotics. The same deadline thinking applies to real-time models.

Keep going

The takeaway. A frame is a deadline, not an average. Read the pose as late as you can, aim it at the moment of light, let a high-priority compositor re-aim the last frame for rotation, and give the app enough time with spacewarp or pacing. Rotation is cheap to fix. Translation and animation are not.
Your headset repeats a frame once a minute. Rotation looks fine but an animated character stutters. Which statement fits best?

Now press Present or Teach and explain one head turn from memory: where the pose is read, how far it is predicted, what timewarp fixes and what it cannot, and why the compositor must be able to interrupt the app. Then go back to the hero, set the render time to 14 ms, and explain why timewarp keeps the posts still but leaves the square stepping.

Motion-to-Photon: Scan-out, Timewarp and Frame Pacing
van Waveren, VRST 2016 · OpenXR xrWaitFrame · Back to embedded real-time