Bevy on Quest 3S: Performance

Bevy on Quest 3S: Performance

Starting from a low 30 FPS, changing one thing at a time and measuring how much each step saves.

I've been building an experimental MR game with Bevy on Quest. The first time I put it on the headset it ran at 30 to 40 FPS, and it made me a little dizzy. So I spent some time measuring and changing things over and over, and this post is a record of that. It's standalone mixed reality on Quest 3S through Bevy and OpenXR, not PC VR. I'm still learning myself; I'm just writing down the problems I ran into and what I did about them, in the hope that it helps others doing Quest development with Bevy.

Why is it so hard to run well on a headset? Compared with a regular monitor, a few things work against you at once:

  • Everything is drawn twice: one image per eye, one more than a monitor needs.
  • It's a phone chip: a desktop GPU is plugged into the wall and can draw a few hundred watts. A Quest runs on a battery and sits on your head, so it can't get too hot, and it has far less power to work with.
  • Aliasing really shows: the image is magnified right in front of your eyes, so jagged edges stand out. MSAA is close to mandatory, and it isn't cheap.

The short version

  • How to measure: Quest prints a VrApi line to logcat every second. Together with a frame breakdown printed by the game itself, that tells you whether the GPU or the CPU is the one falling behind.
  • The cost wasn't the amount of stuff: a table with nothing but its border wall was already over budget. The main reason was Bevy's PBR1 material, which is too heavy for the Quest's GPU.
  • Switching to a custom Lambert material2 saved about 12 ms and looks very close to PBR.
  • Once the GPU came down, the CPU became the bottleneck: Bevy runs its whole render preparation again every frame.
  • A custom render path (lean): its draw list is rebuilt only when the scene changes, which saves CPU time.
  • Pipelined rendering closed the last gap: it moves the render preparation to another thread, and both the demo scene and my save now hold 72 FPS.
  • Didn't help much: SpaceWarp, lowering the resolution, raising the performance level.
  • Watch out for: on Adreno3, every render pass reads 0 GPU time; and VrApi prints one line for the game and one for the system UI, so filter by pid and read only the game's.

How I measured

Versions: Bevy 0.20.1, with OpenXR through bevy_oxr (currently a fork with the Bevy 0.20 update, rev ce6799d).

All numbers below are from a Quest 3S with a release build. Most use the demo scene (two rooms laid out in advance, the same every time); some use the walls-only scene (just the border wall around the table, no rooms or monsters). The headset's display runs at 72 Hz by default, so it needs 72 images a second, which leaves about 13.9 ms per frame (1000 ms ÷ 72). Go over that and you drop frames.

VrApi

Every second, the Quest system prints two VrApi lines to logcat: one for the game, one for the system UI. Filter by pid and read only the game's.

This command shows them:

adb logcat -s VrApi
FPS=72/72,Prd=28ms,…,Stale=0,…,Fov=0,CPU4/GPU=2/2,1920/456MHz,…,App=3.61ms,…,GPU%=0.38,CPU%=0.42(W0.45),…

There's a lot in there; these are the fields worth watching:

FieldMeaning
FPS=a/bframes actually delivered / the display's refresh rate
App=the app's GPU time per frame; compare it with 13.9 ms
GPU%, CPU%load, as a fraction: 0.93 is 93%
CPU4/GPU=c/gthe performance level the system has set the CPU and GPU to. Higher is faster and uses more power. It is not load.
Stale=how many times the compositor4 had to reuse an old frame because we were late

How to read it:

  • The GPU is holding you back: App= is close to or over 13.9 ms and GPU% is high. Draw less, or draw it more cheaply.
  • The CPU is holding you back: App= is well under budget, yet FPS won't go up and Stale is high. The GPU is waiting on the CPU; the fix is in your systems.

Printing a CPU frame breakdown

VrApi only shows the GPU, not what the CPU is busy with. So the game prints a line every few seconds that splits one frame's CPU time into three parts (in ms, simplified here):

CPU frame 31.4 = wait 12.4 + logic 8.3 + submit 10.7
  • wait: waiting for the headset to say "you can start the next frame".
  • logic: running the game's logic.
  • submit: turning what needs to be drawn into commands and handing them to the GPU.

The three add up to one frame.

How to read it: a large wait means the CPU finished early and is waiting on the GPU, so the GPU is holding things back. A small wait with logic + submit close to 13.9 ms means the CPU is.

Switches

To find out what each feature costs, I added a set of switches to turn one thing off at a time, such as msaa, lights, sward, hand and monsters. You can't set environment variables on the headset, so they're Android system properties, read once when the app starts:

adb shell setprop debug.dungeon.perf msaa,sward

How I ran each measurement

At first the numbers jumped around: the same setting could differ by several ms from one run to the next, so nothing could be compared. In the end I settled on these rules:

  • Three runs per setting: "MSAA off", for example, is measured three times and I take the median, so one unusually high or low run doesn't skew the result.
  • Compare under the same conditions: the headset gets warmer and slower the longer it runs, so A and B are run alternately (A, B, A, B, …) to give both about the same temperature.
  • Skip the first seconds after launch: the numbers are always worse right after the app starts, so I only start recording 15 seconds in.
  • Keep the view the same: the person in the headset sits still and looks at the whole table. A different view gives different numbers.
  • Only compare within one round: the code changed between rounds and the runs happened at different times, so the same setting can read a little differently in another round. Compare numbers within one table only, not across tables.

The measurements, and lean below, were done with help from Claude Code.

Round one: the GPU is stuck

OffFPSApp= ms
nothing4419.6
msaa5017.3
lights4220.7
hand3822.8
monsters4421.8
pipelined5 (on)3522.8

Every row is GPU-bound, with GPU% at 0.95 to 0.97. msaa costs the most; lights, monsters and hand barely matter. Measured separately on my own save, sward came second, at about 2 ms.

Round two: one ring of walls is already over budget, so it isn't the amount of stuff

CaseFPSApp= msNote
walls-only scene3922.5over budget with just one ring of walls
demo scene3723.7only 1 ms more than walls-only
demo scene, wall stones off4220.5about 3 ms; half the triangles
demo scene, PBR unlit6513.2about 10.5 ms
demo scene, resolution 0.84519.036% fewer pixels, only about 4.7 ms saved
demo scene, performance level boost3823.0only the CPU clocks up; the GPU doesn't move

This round was an interesting one:

  • The walls-only scene, with nothing but the border wall, already takes 22.5 ms, over the 13.9 ms budget. So it isn't slow because there's too much on the table; drawing the table itself takes too long.
  • Switching every material to PBR unlit (no lighting at all) draws exactly the same things and saves 10.5 ms. The problem is the lighting: to get realistic light and shade, Bevy's PBR does a lot of work per pixel, and the table, walls and floors cover a large part of the view, which is too much for the Quest's GPU. (PBR unlit is only there to measure what lighting costs. You wouldn't ship it: with no light and shade at all, everything looks flat.)
  • Dropping the resolution to 0.8 removes 36% of the pixels but only about 20% of the time, so the pixel count isn't the only cause.
  • Asking the system for a higher performance level (boost) doesn't help either: the CPU's level goes up, but the GPU stays at level 2. With passthrough on, the Quest 3S GPU is capped at level 2 (Meta docs), and mine was already there.

Round three: a custom material saves 12 ms

Since PBR was too heavy, the static surfaces (table, walls, floors) got a custom Lambert material: only the sun and ambient light, wrapped Lambert6, no normal map, specular, shadows or fog. Rather than extending StandardMaterial, it's a standalone Material, so its bind group is one small uniform, one texture and one sampler. Much leaner.

CaseFPSApp= mswait ms
demo scene, nothing32.526.512.4
demo scene, PBR unlit5216.61.7
demo scene, Lambert5914.10.3
demo scene, Lambert + torch light5515.71.1
demo scene, Lambert + torch light + MSAA 2×6212.40.0
  • Lambert is actually 2.5 ms faster than PBR unlit, and it looks much the same as before. Checked in the headset: the torch light looks fine by day and by night.
  • The torches' diffuse light costs about 1.6 ms. The point lights are found through Bevy's own light clusters7, so there's no need to pass in a separate array of lights.
  • Add MSAA 2× and the GPU is finally under budget! But FPS still doesn't reach 72, because wait drops to 0: now the CPU is the bottleneck, with logic at about 7 ms and submit at about 10 ms.

Watch out on Adreno: Bevy's RenderDiagnosticsPlugin can split GPU time by step so you can see what each one costs. On Quest, though, almost every reading is 0.00. You're left with App= from VrApi.

Round four: a render path just for a small scene

Most of the 10 ms of CPU submit is spent in Bevy's render world: prepare, queue and render8. So, for this small scene, I switched to a custom render path called lean:

  • Each camera runs a single render pass, straight to its output.
  • It replays a draw list that is rebuilt only when the scene changes; the rest of the time there's nothing to do.
  • It has its own shader, with the same Lambert lighting.

The biggest difference between lean and Bevy is how much less work happens every frame:

  • Bevy: re-runs its preparation every frame8, including checking what's visible, sorting and preparing data.
  • lean: the draw list is rebuilt only when something on the table actually changes; every other frame it's just replayed. It also skips visibility checks and draws everything on the table. My table is small and mostly in view from the seat, so drawing a few things off-screen, which the GPU clips anyway, is cheaper than checking every frame.

This time with one build and the same demo scene, the three combinations run alternately, three times each:

Render pathLightingFPSApp= mslogic mswait mssubmit ms
ABevyPBR3326.07.713.69.3
BBevyLambert5714.97.60.59.5
CleanLambert6710.56.61.17.3
  • A → B, lighting only: GPU time drops by 11.2 ms; the CPU hardly changes.
  • B → C, render path only: GPU time drops another 4.4 ms, and the CPU's submit goes from 9.5 to 7.3 ms.
  • The lighting change has the biggest effect, about 70% of the total improvement; lean is about 30%.
  • In B, the monsters and props still use PBR, so a small part of B → C's 4.4 ms comes from that.
  • lean leaves the GPU some headroom; now the CPU is the limit: logic + submit is about 13.9 ms, right at the edge of the budget.

Round five: pipelined rendering closes the last gap

With lean, FPS still sat at 67 to 68, just short of 72, and this time the CPU was the limit.

Splitting the CPU time further showed that most of it is work Bevy does every frame regardless, with little to do with how much is on the table: the walls-only scene and the demo scene differ by only about 0.3 ms. So the point wasn't to put less on the table, but to make that fixed work faster. I tried a few things:

Setupdemo scene FPSsave FPSlogic + submit ms (demo scene)
lean686714.6
lean + pipelined rendering73737.0 (submit on another thread)
lean + single-threaded executor (serial,rserial)737310.0

Pipelined rendering5: render preparation runs at the same time as the next frame's logic, which effectively moves submit to another thread. Back in round one the GPU was the bottleneck and it made no difference; now the CPU is, and it closes the last gap.

Single-threaded executor: by default Bevy spreads systems across several threads. On Quest, though, the work is split very finely, into hundreds of systems, and handing them out and collecting them again costs more than running them in parallel saves. Running everything in order on one thread actually brings logic from 7.0 down to 4.7 ms.

Other small tweaks: turning off light clusters, turning off visibility checks, leaving out plugins I don't use: all of them together saved only 0.9 ms. Not much.

In the end I went with pipelined rendering. I was worried it would make the hand lag a frame behind, so I measured how old the hand's position is by the time it's drawn: about 13.7 ms with it off, and about 12.7 ms with it on, slightly newer. That's because the render preparation thread gets started earlier. Since the hand doesn't lag, pipelined rendering is now on by default on the headset.

The single-threaded executor also holds 72, but how the hands and the hand occluder behave under it still needs more testing.

Didn't help much

Application SpaceWarp9: half as many frames rendered per second, but each one takes twice the GPU time (App= 8.7 → 17.1 ms), so the total GPU work is about the same and nothing is saved. It stays off for now.

Lowering the resolution (also an estimate for fixed foveation10): on lean, dropping the resolution to 0.8 brings App= from 13.1 to 10.8 ms, and FPS from 65 to 68. The CPU time doesn't change and stays at the edge of the budget, so the overall gain is small, and I haven't done fixed foveation for now.

Raising the performance level: with passthrough on, the GPU tops out at level 2, so boost only raises the CPU (see round two).

Hitches when editing

Besides the steady FPS, there was another problem: every time I finished drawing a wall or placed a lair, the picture froze for about half a second. The moment the finger lifted, the whole dungeon seemed to be picked up and set back down.

The reason is that every edit rebuilt the whole dungeon. Measuring it, the rebuild was 80 to 90% of the freeze, and about half of that went into recomputing the navigation grid (the grid of where monsters can walk), which got slower with every floor. Yet most edits, like placing a lair, don't change the navigation grid at all, so there's no need to recompute it.

So I did a few things:

  • Don't recompute what didn't change: on a rebuild, the parts that weren't touched, such as the navigation grid, walls and floors, reuse last time's result.
  • A faster navigation grid: measured on desktop, rebuilding the navigation grid went from 100 to 180 ms down to about 5 ms.
  • Move it to the background: the wall stones and floor paving are now built on another thread and swapped in when ready. On the demo scene, the paving's share of the frame went from 66 ms to 0.5 ms, and it's swapped in about 6 frames later.

Where it stands

lean is now the default render path, and it draws almost everything on the table: monsters, grass, water, text and the hand occluder. Pipelined rendering is on by default on the headset, both the demo scene and my save hold 72 FPS, and it feels smooth in the headset.

References


1

PBR (Physically Based Rendering) computes lighting by rules close to real-world physics. Besides how bright a surface is where light hits it, it also works out reflections, the stronger reflection you see at grazing angles (Fresnel) and more, so metal, plastic and stone all look different, at a higher cost. The term caught on with Matt Pharr and Greg Humphreys' book Physically Based Rendering (2004); the metallic / roughness parameters games use today come from Disney's Burley (2012) and Epic's Karis (2013).

2

Lambert is one of the simplest lighting models, named after the Swiss scientist Johann Heinrich Lambert, who described the cosine law in 1760: a matte surface looks equally bright from any angle, and its brightness depends only on the angle the light comes in at; the more directly the light faces the surface, the brighter it is. In a shader it's a single dot(N, L).

6

Wrapped Lambert is a small variation on Lambert: the light "wraps" a little way round to the side facing away from it, so the line between light and shadow is softer and the unlit side doesn't go straight to black. See wrap lighting in GPU Gems, chapter 16.

8

Every frame, Bevy prepares rendering in a fixed sequence of stages, mainly: Queue (put what needs drawing into lists) → PhaseSort (sort them) → Prepare (get the data the GPU needs ready) → Render (hand the draw commands to the GPU). The stages are defined in RenderSystems. With DefaultPlugins, Bevy's built-in mesh, material, shadow and other systems all run here, again every frame.

3

Adreno is the GPU in Qualcomm's Snapdragon chips, the way NVIDIA's GPUs are called GeForce. Quest 3S uses the Snapdragon XR2 Gen 2, whose GPU is the Adreno 740. It draws the image in small tiles one at a time (tile-based), which saves power.

4

The compositor is the part of the headset system that puts the final picture together. What the app renders doesn't go straight to the display; it goes to the compositor, which layers the game, the real room from passthrough and the system menus, corrects the lens distortion, and shifts the picture slightly to match your head's latest position (reprojection). If the app doesn't deliver a new frame in time, it shifts the previous one and shows it again, so the display never freezes.

5

Pipelined rendering is on by default in Bevy: while one frame's rendering is being prepared, the next frame's logic already starts, so two CPU cores share the work. When a frame doesn't fit in its budget, it can keep the FPS up. At first I worried it would make the hand on screen a frame late and out of line with the real hand, so I turned it off; measuring later showed the hand doesn't lag (see round five), and it's now on by default on the headset.

7

Light clustering is how Bevy quickly finds which lights reach a given spot. It splits the space the camera sees into many small cells and records which lights reach each one. To shade a pixel, it only needs that pixel's cell and the few lights in it, instead of checking every light in the scene.

9

Application SpaceWarp (AppSW) is a Meta feature for Quest that lets an app render only half as many frames a second, 36 instead of 72 for example. The app also hands over motion vectors (where each pixel on screen is moving) and depth, and the system uses them to synthesize the missing frame in between. Like a flipbook where you only draw every other page and the system fills in the rest. Synthesized frames tend to go wrong on translucent things, so it doesn't suit every scene. Source: Meta's Application SpaceWarp docs.

10

Fixed foveated rendering (FFR) is a Meta feature for Quest: the centre of the image stays sharp, and it gets coarser, at a lower resolution, towards the edges. The eye only sees sharply at the very centre and the edges are blurrier anyway, so it's hard to notice, and it saves GPU work. It's "fixed" because the sharp area stays in the middle of the image and doesn't follow your eyes. With very simple shaders, though, it may save less than it costs. Source: Meta's fixed foveated rendering docs.