Bevy on Quest 3S: Performance
Starting from a low 30 FPS, changing one thing at a time and measuring how much each step saves.
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:
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.VrApi prints one line for the game and one for the system UI, so filter by pid and read only the game's.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.
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:
| Field | Meaning |
|---|---|
FPS=a/b | frames 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/g | the 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:
App= is close to or over 13.9 ms and GPU% is high. Draw less, or draw it more cheaply.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.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.
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
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:
The measurements, and lean below, were done with help from Claude Code.
| Off | FPS | App= ms |
|---|---|---|
| nothing | 44 | 19.6 |
| msaa | 50 | 17.3 |
| lights | 42 | 20.7 |
| hand | 38 | 22.8 |
| monsters | 44 | 21.8 |
| pipelined5 (on) | 35 | 22.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.
| Case | FPS | App= ms | Note |
|---|---|---|---|
| walls-only scene | 39 | 22.5 | over budget with just one ring of walls |
| demo scene | 37 | 23.7 | only 1 ms more than walls-only |
| demo scene, wall stones off | 42 | 20.5 | about 3 ms; half the triangles |
| demo scene, PBR unlit | 65 | 13.2 | about 10.5 ms |
| demo scene, resolution 0.8 | 45 | 19.0 | 36% fewer pixels, only about 4.7 ms saved |
| demo scene, performance level boost | 38 | 23.0 | only the CPU clocks up; the GPU doesn't move |
This round was an interesting one:
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.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.
| Case | FPS | App= ms | wait ms |
|---|---|---|---|
| demo scene, nothing | 32.5 | 26.5 | 12.4 |
| demo scene, PBR unlit | 52 | 16.6 | 1.7 |
| demo scene, Lambert | 59 | 14.1 | 0.3 |
| demo scene, Lambert + torch light | 55 | 15.7 | 1.1 |
| demo scene, Lambert + torch light + MSAA 2× | 62 | 12.4 | 0.0 |
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.
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:
The biggest difference between lean and Bevy is how much less work happens every frame:
This time with one build and the same demo scene, the three combinations run alternately, three times each:
| Render path | Lighting | FPS | App= ms | logic ms | wait ms | submit ms | |
|---|---|---|---|---|---|---|---|
| A | Bevy | PBR | 33 | 26.0 | 7.7 | 13.6 | 9.3 |
| B | Bevy | Lambert | 57 | 14.9 | 7.6 | 0.5 | 9.5 |
| C | lean | Lambert | 67 | 10.5 | 6.6 | 1.1 | 7.3 |
submit goes from 9.5 to 7.3 ms.logic + submit is about 13.9 ms, right at the edge of the budget.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:
| Setup | demo scene FPS | save FPS | logic + submit ms (demo scene) |
|---|---|---|---|
| lean | 68 | 67 | 14.6 |
| lean + pipelined rendering | 73 | 73 | 7.0 (submit on another thread) |
lean + single-threaded executor (serial,rserial) | 73 | 73 | 10.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.
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).
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:
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.
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).
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).
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.
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.
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.
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.
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.
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.
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.
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.