Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofmodule renderer.module·originates fromworld 07158574-5…

frameStats

What each frame submitted (culling, draws, skinning, morphs, uploads) and how the frames are paced: the frame pacing and activity readings, frames in flight, the present mode, the spectator mode, local layers and the frame-rate cap.

by◐lumi·posted 5d ago
What it does

renderer.frameStats

What each frame submitted (culling, draws, skinning, morphs, uploads) and how the frames are paced: the frame pacing and activity readings, frames in flight, the present mode, the spectator mode, local layers and the frame-rate cap.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

module renderer.frameStats global renderer What each frame submitted and how the frames are paced.

cullStats( ) →

What the last completed frame decided to draw. `total` renderables went into the frustum test, `culled` fell outside it and `visible` survived. Of those, occlusion culling measured `occlusionTested` against the depth pyramid and proved `occlusionCulled` were entirely behind other geometry — both 0 while `renderer.occlusionCulling()` is false. A renderable the pyramid has no say over — one that laid no depth in the visibility raster, one whose bounds were never recorded, one straddling the near plane — is measured against nothing and counted in neither, so the gap between `visible` and `occlusionTested` reads how much of the frame the test could speak for. The two are read back from the GPU for a reader: every call asks for them, the two rendered frames after each call read them back, and otherwise one rendered frame in 60 does. So a script reading them each frame reads each frame's counts, a frame or two behind as the readback lands, and a read after a pause answers counts at most as old as the pause and never more than 60 rendered frames, with the frames after it answering fresh. This answers for the main camera. What the shadow page cull did with the frame's casters for each light is on that light's row in `renderer.shadowViews()`. `views` is the engine cull's own count, one row per camera view that rendered: `view` is `"main"` for the main camera and the camera's entity id for an offscreen one, `kind` says which, and `frame` is the frame the counts describe. The main view's row is first. `drawn` is whether a render drew the view in that frame: a frame the renderer declined still ran the cull's first test, so its row carries that test's counts and no second one, for a picture nothing rasterized. The counts are read back from the GPU and handed out oldest first, one frame per render, so a script reading once a frame reads the frames in the order they ran. A frame's counts wait at most two renders to be handed out: a row describes a frame as many frames back as the read took and at most two more, and when more frames' counts come back at once than that lets wait, the oldest of them are the frames a script does not read. `instancesTested` renderables were tested; `instancesCulled` breaks the rejections down by reason (`hidden`, `layer`, `range`, `frustum`, `screenSize`, `occludedPass1`/`occludedPass2` for occlusion against the depth of the frame that last drew the view and then this frame's, and `rasterShaded` for the renderables the view shades on the legacy lane, as `renderer.setRasterShading` describes); `instancesRecovered` came back in the second test. Then the clusters of the survivors: `clustersTested`, rejected by the level-of-detail cut (`clustersLodRejected`), the frustum (`clustersFrustumCulled`), facing away (`clustersConeCulled`) or occlusion (`clustersOccludedPass1`, of which `clustersRecovered` came back), and `clustersDrawn` / `trianglesDrawn`. `binsPending` counts material pipelines still compiling, whose clusters wait a frame; `overflow` counts clusters that did not fit the view's lists. `total`/`culled`/`visible` and `occlusionTested`/`occlusionCulled` above are the main view's count for the renderables drawn outside the cluster lists.

examples

local s = renderer.cullStats(); print(s.visible - s.occlusionCulled, "drawn")
for _, v in renderer.cullStats().views do if v.view == "main" then print(v.clustersDrawn, "clusters,", v.instancesCulled.frustum, "outside the frustum") end end

drawStats( ) →

What the last completed frame actually submitted. `draws` counts every geometry draw call the frame issued — the camera's passes, each shadow view a shadow-casting light adds, and whatever a render feature draws — and `instances` counts the instances those draws covered. The pair is what separates one draw carrying five hundred instances from five hundred draws carrying one each, so it reads how well the scene batches rather than how many objects are in it. `compacted` is how many of those instances the frame planned through draws whose instance count the GPU decides: the culler's own per-object answers packed into a dense run, so an object it rejects is absent from the draw instead of collapsing to nothing in the vertex stage. `compactedDrawn` is how many of them survived, counted on the GPU as it packed them — a pass that then skips a whole draw over its own layer or visibility answer leaves that draw's instances in both numbers. The plan is made over the populations the frame draws, and the tests answer which of their instances the packing keeps. That packing runs before any pass has resolved the depth occlusion culling is tested against, so on its own it reads the frustum and screen-size answers alone. With `setOcclusionCulling` armed the frame packs the same plan a second time once the test has answered, and `compactedDrawn` then counts what came through occlusion as well. `compactedDrawn` comes back from the buffer the GPU wrote, so it describes a frame that has finished while `compacted` describes the most recent plan, and it holds the last count the GPU wrote until another arrives — a frame that compacts nothing reads `compacted` 0 beside the count from the last frame that did. In a scene standing still the gap between the two is the front-end work culling removed. It is read back for a reader the way `cullStats().occlusionTested` is: on the two rendered frames after each call, and one rendered frame in 60 otherwise. `materialBinds` is how many times the frame's geometry passes set a **material group's** textures (group 1), and `materialBindsElided` how many times a pass reached that decision and found the group already bound. On the bindless backend every material group binds the one texture group of the frame, so a pass binds it once; on buckets a pass binds once per group it draws (see `renderer.materialTable().groups`). Their sum is how many times the decision was reached — once per unit of geometry submitted, which sits at or below `draws`, since a mesh of several primitives draws once per primitive under one set of binds. `materialExtraBinds` and `materialExtraBindsElided` are the same pair for group 2, the storage buffers a shader declares, bound per distinct buffer set, which only the shaders that declare them ever bind. `pipelineBinds` and `pipelineBindsElided` are the same pair for the pipeline itself: how many times the frame's geometry passes set one, and how many times a pass reached that decision and found the pipeline it wanted already bound. Which pipeline a unit needs follows its shader, its material's render state and its mesh's vertex layout together, so a scene whose units share all three costs one set for the run of them, while units differing in any one of the three each pay their own. Their sum is how many units reached the pipeline decision, which sits at or above what the material pair reports: a unit the pass settles a pipeline for and then abandons — one whose material group resolved to nothing — counts here and never reaches the material decision. Every figure here is the whole frame's. `renderer.shadowViews()` carries the main camera's own share of `compacted` and `compactedDrawn`. `clusters` and `clusterTriangles` are the clusters and triangles the camera views drew from the cluster lists, from the GPU's own count. `drawsByPass` splits `draws` by the part of the frame that submitted them — `visibility` (the id raster: one draw per raster bin per Hi-Z phase in each camera view, submitted whether or not the GPU cull left anything in the bin), `resolve` (one draw per resolve draw in each camera view: one per shader, and on the array-bucket backend one per shader and material group), `legacy` (geometry drawn outside cluster storage: skinned, morphed and compute-written meshes, line topology, shaders that write their own vertex stage), `blended`, `exception` (opaque materials whose depth state the visibility buffer cannot express), `featureGeometry`, `featureDraw`, `shadow` and `splat` (one draw per splat buffer a render feature draws) — and the nine sum to `draws`. `instances` counts instances named by draws whose size the CPU decided; the visibility raster's work is `clusters` and `clusterTriangles`, which the GPU decided. `pixelsResolved` is how many pixels the resolve shaded, summed over camera views, and `pixelsByShader` the same split by shader. `clusters`, `clusterTriangles`, `pixelsResolved` and `pixelsByShader` come back from the GPU and describe the frame numbered `frame`, which is earlier than the frame `draws` describes. A frame counts them, and reads them back, for a reader: the two rendered frames after each `drawStats()` read, and one frame in 60 otherwise, so a read after a pause answers a frame at most as old as the pause and never more than 60 rendered frames, and a script reading every frame reads every frame's. `frame` is the renderer's own frame number, counted from 0 when the renderer was built (again after a device loss), a count of its own that compares only with another `drawStats().frame`.

examples

local d = renderer.drawStats(); print(d.instances / math.max(d.draws, 1), "instances per draw")
print(renderer.drawStats().compactedDrawn, "of", renderer.drawStats().compacted, "survived the cull")
local d = renderer.drawStats(); print(d.materialBinds, "material group binds over", d.materialBinds + d.materialBindsElided, "units")
local d = renderer.drawStats(); print(d.pipelineBinds, "pipeline sets over", d.pipelineBinds + d.pipelineBindsElided, "units")
local d = renderer.drawStats(); print(d.clusters, "clusters,", d.clusterTriangles, "triangles from the cluster lists")
local d = renderer.drawStats(); print(d.drawsByPass.visibility, "id-raster draws,", d.drawsByPass.resolve, "resolve draws")
local d = renderer.drawStats(); for shader, px in d.pixelsByShader do print(shader, px) end

skinningStats( ) →

What the last frame's deformed instances cost. A skinned instance is posed by a compute pass that writes its vertices into a shared pool, and instances holding the same pose read one slice of that pool and the single dispatch that fills it. The same pass writes the vertices of a renderable whose mesh a morph blend deforms and no skin poses (`renderer.morphStats`), each blend a pose of its own, shared by the renderables drawing one mesh at one blend. `instances` is how many were posed, `poses` how many distinct poses they held, and `dispatches` how many of those poses this frame wrote (a skin's pose is a dispatch of its own; the blend-only poses whose meshes share a vertex buffer are written together, by one) — so a crowd whose members move together costs what its poses cost rather than what its head count does, while members at different animation times each hold their own pose and pay for it. `held` is how many of the frame's poses cost no dispatch at all. The pass produces a slice from what the pose is made of, so a slice an earlier frame filled already holds what running it again would write, and a pose still wearing that slice is read as it stands. Skinning is paid for by the poses that CHANGED: a cast standing still reads `dispatches` 0 beside a `held` equal to its `poses`, and the two add up to `poses` in any frame. A slice counts as filled once a render carrying its dispatch has been drawn: the frame's own view, or a render of the scene into a target, such as a camera drawing into its render texture. A frame whose view the renderer declines (a headless one nothing is consuming, a browser behind its GPU) and that renders the scene into no target records nothing, so a pose that arrives over such frames is counted in `dispatches` on each of them and reads as `held` from the frame after the first one that records it. A wait for a crowd to settle is therefore counted in drawn frames (`task.waitDrawnFrames`). `reusedSlices` is how many of the frame's poses took a slice the pool already held — one a retired pose gave back, or one a pose nothing has asked for this frame was holding — rather than one cut from pool the engine had never used. A scene whose poses keep changing reads a non-zero count beside a `poolBytes` that stays where it was. `liveBytes` is what the slices holding this frame's poses occupy, against `unsharedBytes` — what the same instances would occupy with a slice each. `poolBytes` is what the pool holds; a previous-position buffer of the same size rides alongside it so skinned deformation reaches motion vectors. The same pass draws a soft body's model through the body's elements (its cage). `cages` is how many soft bodies it draws that way, `cageBytes` what their buffers occupy, and `cageUploads` how many of them wrote their elements' maps to the GPU this frame: a soft body at rest writes nothing, and a removed one takes its cage with it.

examples

local s = renderer.skinningStats()
print(("%d instances over %d poses"):format(s.instances, s.poses))
print(("%d poses dispatched, %d read as they stood"):format(s.dispatches, s.held))
print(("skinned vertex storage: %d B of an unshared %d B"):format(s.liveBytes, s.unsharedBytes))

morphStats( ) →

The morph state the last frame drew with. A mesh carries the shapes it can blend towards and an entity carries how strongly each is blended (`ecs.MorphWeights`); where both are present, the deform pre-pass adds the weighted deltas to the base geometry and every pass draws the vertices it wrote (`renderer.skinningStats` counts its work). `instances` is how many render slots that happened at, and `blends` how many single-target blends those slots carry between them: a slot contributes one per target its weights move, or that they moved the frame before, so the number of targets a mesh can be given is bounded by the buffer the blends live in. `meshes` is how many meshes hold a delta block and `targets` how many targets those blocks cover between them; `deltaBytes` is what the shared buffer they are appended into holds, and `deltaBufferBytes` the size of that buffer, which the deform pre-pass binds whole. `deltaBudgetBytes` is the most that buffer may hold on this device: the largest storage buffer the device binds at once (128 MiB on many mobile browsers). A block costs 32 bytes per vertex per target, over every vertex of the mesh. A mesh whose block would take the resident blocks past the budget is refused by name in the engine log and draws in its base shape, and `refusedMeshes` counts the meshes refused that way; the refusal holds until the mesh is uploaded again. A morph-target mesh whose weights are all zero reads a `meshes` above zero beside an `instances` and `blends` of zero.

examples

local m = renderer.morphStats()
print(("%d instances carrying %d blends over %d meshes"):format(m.instances, m.blends, m.meshes))

uploadStats( ) →

What the last frame the renderer drew spent re-describing its renderables to the GPU, counted from the frame it drew before that, so a read after `task.waitDrawnFrames` describes the frame waited for even where the frame pacer declines frames between two drawn ones. Every renderable owns a slot in the per-instance data a draw reads (its world matrix, the bounds the culler tests it by, and the flags that decide which passes and which culling stages see it), and a frame uploads only the slots whose contents changed. A `renderer.mesh.drawInstanced` population's slots are filled by copies from its own buffers, counted the same way: a frame that copies a population's transforms or shader data counts one write per copy and the bytes it moved. `bytes` is what those uploads and copies carried, `fullBytes` what re-sending every slot would have cost, and `writes` how many buffer writes carried it. The three numbers cover that per-renderable data alone, so a scene standing still reads `bytes = 0` against a `fullBytes` that grows with the scene, and the ratio says how much of it the scene's own churn, rather than its size, is paying for.

examples

local u = renderer.uploadStats()
print(("instance upload: %d B of %d B in %d writes"):format(u.bytes, u.fullBytes, u.writes))

framePacing( ) → FramePacing

How far the CPU is allowed to run ahead of the GPU, and what holding it there cost the frame just finished. Submitting work to the GPU returns before the GPU has done it, and everything that submission holds — its staging allocations, its bind groups, its command buffer — stays alive until it completes. A frame that asks for more work than the GPU finishes in a frame's time therefore leaves that behind it, and unbounded that is memory growth rather than a lower frame rate. `framesInFlight` is how many submitted frames have not reported done through the queue's completion signal, held under `maxFramesInFlight`: a device that keeps up reads under the bound, one that is behind reads at it. A frame the renderer declines is counted there too when its systems put work on the queue (a compute batch, a transform compose, an offscreen render), so a headless engine nothing reads frames from reads the GPU work it keeps in flight. It counts submissions, which is its own quantity — how many presented images the swapchain permits in flight is a separate setting. `mechanism` names how that bound is enforced here: `submission-wait` waits for the frame that many frames back and reports the wait in `waitMs`, so a paced frame costs latency and still draws; `submitted-work-done` counts outstanding frames off the queue's completion signal and declines to start a frame while the bound is met, counting those in `pacedFrames` and leaving the last presented image up. `submittedFrames` counts the frames that were admitted and submitted, so it rises for as long as the renderer is producing frames — which is what tells a renderer running slowly under a tight bound from one that has stopped. `stalled` reads true while the pacer has given the bound up rather than hold the image indefinitely, on either mechanism: the counting one stands down when the completion signal goes quiet across a whole run of declined frames, and the waiting one when a wait on a frame reaches its ceiling with the GPU still holding it. Both clear on the first word the GPU sends after that. A signal that is merely late — a GPU finishing frames more slowly than the loop asks for them — keeps the bound, so `stalled` answers for a GPU that went silent. `standDowns` counts those over the session, which is how a session that lost the signal and got it back (`stalled = false` with `standDowns` above zero) reads apart from one that never lost it. `producing` is whether the renderer drew the last frame. A headless renderer draws into an offscreen framebuffer that nothing presents, so its image reaches a reader only through something that copies it out: it draws while a consumer is asking — a capture, a wait on drawn frames, a queued texture readback, a recording, a frame-egress session — and declines the frames between two asks. A renderer presenting to a display draws while what is on screen changes, and for a short settling run after the last change, and declines the frames of a still picture, which stays on screen; whatever else moves (the gameplay clock, a task owed the next frame, held input, a tool call) keeps running at the display's rate meanwhile, and an engine with nothing moving waits instead (`engineStill`, below). Both count the frames they declined in `idleSkippedFrames`. Every other renderer stat answers with the last frame that drew, so `producing` is what separates a live reading from a frozen one. A change of the UI alone (a hover, a tooltip, a panel's text) leaves the scene's picture as it was. A presenting renderer draws the frame that carries it, and while a viewport panel holds the scene's last picture it draws that frame as the UI over the picture without drawing the scene again: `uiOnlyFrames` counts those frames, which `time.drawnFrameCount()` leaves out. `pictureReady` is whether a frame drawn now is the picture a reader comes for. A headless renderer nothing has read for its interval (10 s) lets go of what it draws with (its view-sized targets, its shadow page pool, its cull scratch); while it does, and while it brings them back for a reader until the shadow pages the view asks for are drawn again, it reads false. It reads false as well while the waits on drawn frames a headless engine in play held while nothing observed it catch up (`task.waitDrawnFrames`): until a frame passes with no such wait asking, so a capture of the sky that fell behind has captured the sky again, or until they have been drawn 90 frames while they kept asking. A capture waits for it. `drawPolicy` names the rule the last frame was decided under: `consumers` (headless), `changes` (presenting to a display) or `every_frame` (content asked for every frame with `renderer.setDrawEveryFrame(true)`, or a limit from `renderer.limitDeviceMemory` holds draws on in an engine that draws only on request; `drawEveryFrame` reads the same). `pictureChanges` counts, per source, the frames on which something changed what the next frame draws: `ui` (a new UI layout or UI texture), `camera` (the viewport camera, the viewport, a frame setting or a renderer setting a script states: the projection offset, the shadow configuration, the render path), `scene` (a renderable added, removed, moved, shown or re-described), `material` (a material created, removed or given new properties, textures or a new shader), `lighting` (a light, the ambient term or the sky), `surface` (its size, format or present mode), `arrivals` (a pipeline, texture or material row still landing), `world` (a component written, an entity spawned or removed), `clock` (something drawn with a shader that reads the frame clock, while the clock runs), `compute` (a compute buffer written or dispatched over), `window` (the platform asked for the window to be drawn again), `texture` (a texture's contents replaced from the CPU, a video frame among them) and `content` (a script's command reached the engine: a post-process effect, a sky, an environment, a render feature). Every renderer counts them, a headless one included. Every change names its owner, what within its source changed the picture: a `ui` change the reason its UI pass ran and the screens it laid out (`tree: hud`, `pointer_motion`, `repaint_due`, `viewport ui: ...` for the UI painted into the scene), a `world` change the component and the entity it was written on (`Transform on crate-1 'Crate'`; eight of them a frame, taken in turn from frame to frame when more changed), a `content` change the command it applied or the render pass that differs, a `clock` change the program that reads the clock, a `camera`, `scene`, `surface` or `lighting` change the part that moved (`frame settings`, `placement`, `size`, `sun`), a `compute` or `texture` change the buffer or texture written, an `arrivals` change the kinds of work still landing, a `window` change the platform event. `lastPictureChange` names the source of the latest and `lastPictureChangeDetail` its owner; `pictureChangeDetails` holds, per source, the owner its latest change named. `redrawReasons` lists the owners that changed the picture, the most changes over the last 5 to 10 seconds first (`recent`), each with its `source`, `owner`, `recent`, its `total` over the session and `agoMs` since its last change: every owner the renderer keeps apart, at most 64, a new one taking the place of the one with the fewest recent changes. Read it on a renderer that keeps drawing a picture that looks still: the owner at the top is what keeps it redrawing. `renderer.activity()` puts the top of it beside the frame rate and the CPU the engine spends. `presentMode` is what the surface presents with and `presentModes` what it offers; both are empty of meaning on a headless renderer, which never presents. A desktop presents `mailbox` unless told otherwise, and Android presents `fifo`, which shows each frame on a vsync of the panel and makes no frame the panel never shows. The rest describe the rate frames run at. `displayRefreshHz` is the refresh rate of the display the frames are shown on, where the platform reads it: the phone's panel, the monitor a desktop window is on, the cadence of a browser's animation frames. A headless engine presents to no display and states none. `frameRateCap` is the cap `renderer.setFrameRateCap` set, absent while none is. `frameRateMode` is how the rate is chosen (`renderer.setFrameRateMode`), `chosenFps` the rate the frame loop chose and `frameRateReason` why: `cap` (the highest rate the cap delivers), `display` (the display's highest rate, with no cap), `frame_time` (a lower even rate, because frames did not hold the faster one) or `uncapped` (no target: a surface that shows a frame the moment it is ready, `immediate` or `auto_no_vsync`, a display whose refresh rate is not read, or no display, with no cap). On a `mailbox` surface a frame that takes longer than a refresh runs as soon as it is ready. `targetFps` is the rate the chosen one delivers on the mode the display runs in now and `refreshesPerFrame` the refreshes each frame stays on screen there; these and `chosenFps` are absent while no target is in force. `frameWorkMs` is the 90th percentile of the time recent drawn frames took, the time the rate is chosen from. `lateFrames` counts the drawn frames the loop came back to later than the vsync each was due for, `missedPresents` those the compositor showed later than one interval after the frame before them (a judder; 0 where the surface reports no present times), and `rateStepsDown` / `rateRaises` the times the chosen rate went down and up, all since the rates to choose from last changed (a new cap, mode or display). Each change is also one `[frame rate]` line in the engine log naming what decided it. `displayVote` names the platform call that tells the display the rate (`none` where there is none, and frames are held to the display by pacing alone) and `displayVoteFps` the display mode it last asked for. `deliveredFps` is the rate the frame loop has run frames at over about the last twenty frames. The last describe whether the engine runs frames at all. An engine with nothing to draw, its gameplay clock stopped, no deferred task or settled promise to resume, no commands waiting to be applied, no tool call in flight, no background shell job at work and no input held is still (a playing sound keeps sounding through it, the audio output feeding itself on its own clock), and its loop runs a frame at once when something reaches the engine, else when the earliest wait a task holds comes due, with frames at least a quarter of a second and at most a second apart. `engineStill` is whether the engine stated itself still at the end of its last frame (a reading taken inside a tool call reads false, since the call is in flight) and `movingBecause` names what kept it moving otherwise: `picture`, `gameplay`, `boot`, `tasks`, `input`, `recording`, `calls` (a tool call is in flight, or a background shell job is at work), `replay` (a physics replay plays) or `runAhead` (the game runs ahead of the wall clock, `engine.fastForward`). `stillWaits` counts the frames the loop held back for a still engine, `framesAfterStill` the frames run after such a wait, `wokenFrames` those of them an arrival started (a frame a task's wait or the longest gap ran is in `wokenBy` and absent from `wokenFrames`, so `wokenBy` is the count that names every still frame), and `stillSeconds` the seconds spent waiting. `wokenBy` names what ran each frame the loop ran after a frame at whose end the engine stated itself still, the most frames over the last 5 to 10 seconds first, each with its `source`, `owner`, `recent`, `total` over the session and `agoMs` since it last ran one, and for a task's wait the `site` (`source:line`) the task waits at, each site counted apart and a frame several tasks' waits owe counted against each of them, and for a message what it `carried` (its kind: `PropertyBatch`, `Snapshot`, `AvatarState`), each kind counted apart. A frame that ran before its still wait came due is counted against the first arrival since the frame before (for a loop whose frames present nothing and reach no reader, the first other than a picture change, which leaves its wait held), under its kind: `input` (`keyboard`, `pointer`, `touch`, `gamepad`, `file drop`, `focus lost`, `remote input`, `page input`), `call` (`tool call`, over any transport, the engine's bridge socket among them: a reading taken through a tool call is one; `shell job`, a background job a shell started), `route` (`route request`), `reader` (`frame reader`), `picture` (`picture change`, `renderer warm-up`), `promise` (a `promise`, `worker job`, `http response`, `file pick`, `file save`, `sign-in answer`, `tool result` or `agent result` settled on another thread, or a `socket state`: a websocket a script waits on opened, failed to open, closed or failed), `request` (a script's `websocket request`, `http request`, `content request`, `shell request`, `tool request`, `code to run`, `av command`, `window capture`, `plugin gpu request`, `plugin entity request`, `plugin events` or `script command` queued for the engine thread), `file` (`file loaded`, `library loaded`, `file transfer`), `write` (`file written`), `message` (`stream message`, `datagram`: a message a frame acts on, the relay's answer to a clock request running none; `socket message`: a frame landing on a websocket a script holds), `job` (`off-frame job`, `pipeline built`) or `platform` (`window`, `app presence`, `motion preference`, `notification`, `background work`, `page message`, `world request`). A frame whose wait came due is counted against what set the wait's end, under `schedule`: `task waits on frames` (a task waiting on frames or on a timer already due), `task timer`, `task waits at its rate` (a wait that names the frames a second it asks for, `{ wake = 30 }`), `longest gap` (nothing due) or `hidden gap` (a loop whose frames present nothing); one the renderer owed with nothing arriving under `picture` as `draw owed`. The cause at the top of a reading taken while an idle engine keeps running frames is what keeps it running them. `stillFrames` counts the frames after which the engine stated itself still and `movingFrames` those after which it stated itself moving, per reason, so the reason a still scene keeps running frames is the count that grows between two readings. An engine whose frames reach nobody unless something asks for them (a headless engine: an agent's sub-client, or a primary engine started without a window) runs its gameplay at a lower rate while nothing observes it: no tool call in flight, no input held, nothing reading its frames. `unobservedGapMs` is the gap the engine stated its loop may then leave between two frames (absent while something observes it), `unobservedWaits` counts the frames the loop held back for it, `framesAfterUnobserved` the frames run after such a wait and `unobservedSeconds` the seconds spent waiting. An editor whose picture alone moves (a material reading the frame clock, clouds, content moving in `editorUpdate`) and that nobody has attended for three seconds (no input, nothing reading its frames, no change of its UI, window or surface) draws that motion at its preview rate. An agent's call is not a person attending: a tool call runs its own frames at the full rate and the preview rate holds again once it is answered. `previewFps` is that rate (`edit_preview_rate` under `[render]`, 15 unless the world states another; absent while it is 0, which draws such motion at the full rate), `previewGapMs` the gap the engine stated its loop may then leave between two frames (absent while something attends it or anything else moves it), `previewWaits` counts the frames the loop held back for it, `framesAfterPreview` the frames run after such a wait and `previewSeconds` the seconds spent waiting. While its window holds no input focus (another window has it, the browser page is blurred or hidden, the Android activity lost its window focus) the preview runs at no more than 2 frames a second (`previewFps` reads the rate in force and `windowFocused` the focus), and the window taking the focus back or any input runs the next frame at once.

examples

local p = renderer.framePacing()
print(("%d of %d frames in flight, paced by %s"):format(p.framesInFlight, p.maxFramesInFlight, p.mechanism))

activity( ) → Activity

Why this engine is busy, in one reading. `fps` is the rate its loop ran frames at and `drawnFps` the rate its renderer drew them at, and `cpuPercent` the CPU its process spent as a percentage of one core (absent where the platform states none, as in a browser), each over the last ten seconds (`spanMs`, longer when the loop ran no frame inside them). `still` is whether the engine stated itself still at the end of its last frame and `movingBecause` what moves it otherwise (the names `renderer.framePacing().movingBecause` takes: `picture`, `gameplay`, `tasks`, `input`, `calls`, ...). `wokenBy` names what ran the frames the engine ran while still over the last 5 to 10 seconds, at most 5, the most frames first, each with its `source`, `owner`, `recent`, `total` and `agoMs`, as `renderer.framePacing().wokenBy` lists them: an arrival (`input` / `pointer`, `write` / `file written`, `message` / `datagram`, ...) or the `schedule` its tasks set (`task waits on frames`, `task timer`, `task waits at its rate`, `longest gap`). `redrawReasons` names the owners whose changes moved the picture in the last 5 to 10 seconds, at most 5, the most changes first, each with its `source`, `owner`, `recent`, `total` and `agoMs`, as `renderer.framePacing().redrawReasons` lists them: the screen a UI pass laid out, the component and entity a world write changed, the program reading the clock. `busyJobs` names the kinds of job the engine's worker pools ran over the last 5 to 10 seconds, at most 3, the most busy time over that span first, each with its `pool`, `kind` (the name a job gave itself, else the place in the engine's source that handed it over), `recentJobs` and `recentBusyMs` (the jobs of the kind that ended over that span and the time they spent running), `jobs` and `busyMs` (the same over the session) and `sinceLastMs`. The engine's `GET /engine/status` carries the same reading under `activity`, which the proxy's `list_instances` and `instance_health` print for every engine.

examples

local a = renderer.activity()
print(a.fps, a.cpuPercent, a.movingBecause, a.redrawReasons[1] and a.redrawReasons[1].owner)

setMaxFramesInFlight(frames: number) → number

Set how many frames of GPU work may be outstanding before the renderer stops running ahead. One is the least overlap this can express — a frame's work is waited for as soon as the next frame has been submitted — which is the lowest latency and the lowest throughput; higher values let a slow frame build a longer backlog, and that backlog is memory. Takes effect on the next frame. Answers the bound after clamping to [1, 8], so asking for more than the renderer honours reports what you actually got.

argtypedescription
framesnumbernumber Frames of GPU work that may be outstanding, 1 through 8.

examples

renderer.setMaxFramesInFlight(1) -- lowest latency
print(renderer.setMaxFramesInFlight(99), "was clamped")

setPresentMode(mode: string) → string

Set how a presented frame reaches the display. `fifo` queues every frame and shows it on a vertical blank, which never tears and never drops one; `mailbox` replaces the queued frame with the newest, which does not tear and never blocks the frame loop, which makes its frames at the display's refresh rate (or the cap) and a frame that takes longer as soon as it is ready; `immediate` presents as soon as a frame is ready and can tear; `fifo_relaxed` is `fifo` that tears rather than stall when a frame misses its blank; `auto_vsync` and `auto_no_vsync` leave the choice to the backend. Under `immediate` and `auto_no_vsync` the frame loop runs every frame it is ready for unless a cap holds it, whichever mode the backend picks for `auto_no_vsync`, so they are the modes for measuring how fast frames can run: a surface that does not offer `immediate` presents `fifo` in its place, and every surface takes `auto_no_vsync`. A surface that does not offer the mode presents `fifo` instead, so read `renderer.framePacing().presentMode` for what took effect and `.presentModes` for what this surface offers. Takes effect on the next frame.

argtypedescription
modestringstring One of "fifo", "fifo_relaxed", "mailbox", "immediate", "auto_vsync", "auto_no_vsync".

examples

renderer.setPresentMode("mailbox")
print(renderer.framePacing().presentMode, "is what the surface took")

setSpectatorMode(mode: string) → string

Choose what the desktop window shows while an XR session serves frames. `mirror` shows the left eye's picture, copied from the target the headset's frame already drew, so the window costs no second scene render. `off` draws nothing to the window: no scene render, no UI layout and no present. `editor` draws the desktop editor beside the session, with its panels and its own viewport camera, which renders the scene a second time. With no XR session the window is the ordinary desktop window whatever the mode. The engine boots in `mirror`; `--xr-spectator <mode>` names the mode a boot starts in. Takes effect on the next frame; the mode in force is the `spectator` field of `/zero/runtime/observations/xr`.

argtypedescription
modestringstring One of "off", "mirror", "editor".

examples

renderer.setSpectatorMode("editor") -- the desktop editor beside the headset
renderer.setSpectatorMode("off") -- the window draws nothing

setLocalLayers(target: any, layers: string?) → void

Draw an entity's meshes on the render layers named in `layers`, in this engine only. The entity's own `RenderLayer` is untouched, so what other peers draw it on does not change and nothing is saved. The layers replace the entity's own for every camera of this engine, so a camera draws the entity when its include set holds one of them. Only the entity's own meshes are affected, not its descendants'. Pass nil to draw it on its own layers again.

argtypedescription
targetanyThe entity, as an id or a proxy.
layersstring?A space-separated list of layer names, or nil.

examples

renderer.setLocalLayers(hat, "xrSelf") -- the hat draws on `xrSelf` here and nowhere else
renderer.setLocalLayers(hat, nil)

localLayers( ) →

The entities this engine draws on layers of their own, by entity id, with the layer mask each is drawn on (`renderer.setLocalLayers`).

examples

for id, mask in renderer.localLayers() do print(id, mask) end

spectatorMode( ) → string

The spectator mode that has been asked for: "off", "mirror" or "editor". An XR session applies it to the desktop window; with no session serving frames the window is the ordinary desktop window.

examples

print(renderer.spectatorMode())

setFrameRateCap(fps: number?) → number

Hold the engine to at most `fps` frames per second, or lift the cap with 0 or nil. The whole frame waits for its turn: scripts, physics, audio mixing and networking run once a frame as the drawing does, so a game capped at 30 runs at 30, and a phone spends no battery on frames past it. Frames come due on an even grid. Where the display's refresh rate is known (a phone's panel, a desktop window's monitor, a browser's animation frames), the grid is a whole number of refreshes, the fewest whose rate stays inside the cap, so every frame stays on screen for the same number of vsyncs: on a 120 Hz display a cap of 30 shows each frame for 4 refreshes and 60 for 2, and a cap the refresh rate does not divide evenly delivers the next rate below it (50 on a 120 Hz display delivers 40). On Android the system compositor is told the rate as well, so a panel with more than one refresh rate can run at one the cap divides. On a display that shows frames on its vsync the cap is the highest rate the engine chooses (`renderer.setFrameRateMode`): frames that cannot hold it run at the next even rate below. Read `renderer.framePacing()` for the effect: `targetFps` is the rate the cap delivers, `refreshesPerFrame` the refreshes each frame holds, `displayRefreshHz` the display it was worked out against, and `deliveredFps` the rate frames actually ran at. Takes effect on the next frame. `frame_rate_cap` under `[render]` in the world's `.world_settings` seeds it (0 for no cap), so a world states its cap once and every session opens under it; a call here stays in force until that value changes.

argtypedescription
fpsnumber?number? Frames per second, 1 through 1000; 0 or nil lifts the cap.

examples

renderer.setFrameRateCap(30) -- a steady 30 on any display 30 divides
print(renderer.framePacing().targetFps, "fps delivered under the cap")
renderer.setFrameRateCap(nil) -- every frame the display shows

setFrameRateMode(mode: string) → string

Choose how the engine picks the frame rate it runs at on a display that shows each frame on a vsync (`presentMode` fifo, fifo_relaxed or auto_vsync: a phone, a browser tab, a desktop window set to fifo). `adaptive`, the default, runs at the highest rate the display shows evenly that the frames sustain, at most the cap (`renderer.setFrameRateCap`; the display's highest refresh rate without one). A frame that cannot hold 120 on a 120 Hz panel runs at an even 60 rather than at 60 to 67, one that cannot hold 60 at 40, never below 30, and the rate goes back up once the frames hold a faster one again (in one step after a load). `fixed` holds the cap's rate (the display's highest rate without a cap) whatever the frames take, for content that needs one set rate. In both modes every frame is due on its own vsync, so the engine makes no frame the display has no refresh to show. On Android the display is asked for the lowest of its modes the chosen rate divides into whole refreshes, so a panel whose frames come at 60 can run at 60 Hz and spend less power; a desktop window and a browser hold frames to their display by pacing alone. On a `mailbox` surface the loop is held to the cap, or with none to one frame per refresh of the mode the display runs in now, and a frame that takes longer runs as soon as it is ready; under `immediate` or `auto_no_vsync`, or with no display, the cap alone holds the loop. `renderer.framePacing()` reports the mode (`frameRateMode`), the rate chosen (`chosenFps`), why (`frameRateReason`), the time frames take (`frameWorkMs`) and what the display was told (`displayVote`, `displayVoteFps`). Takes effect on the next frame. `frame_rate_mode` under `[render]` in the world's `.world_settings` seeds it; a call here stays in force until that value changes.

argtypedescription
modestringstring "adaptive" or "fixed".

examples

renderer.setFrameRateCap(120) -- a game that wants 120 where frames hold it
renderer.setFrameRateMode("adaptive")
print(renderer.framePacing().chosenFps, renderer.framePacing().frameRateReason)
renderer.setFrameRateMode("fixed") -- hold the cap's rate whatever frames take

setDrawEveryFrame(everyFrame: boolean) → boolean

Draw every frame continuously (`true`), or redraw only while there is something new to show (`false`, the default), so an idle screen whose picture stands still is not redrawn. By default a renderer presenting to a display draws while what is on screen changes (the UI, the camera, a renderable, a material, a light, an animation, a texture, the window) and for a short settling run after the last change, then declines the frames of a still picture, which stays on screen. While anything else moves (the gameplay clock, a task owed the next frame, held input, a tool call in flight) the frames keep running at the display's rate while it declines, and an engine that is still waits for the next arrival or timer instead (`renderer.framePacing().engineStill`); the next change is drawn on the frame after it. On a phone that is the GPU work, the heat and the battery of every frame an idle menu or a paused editor would otherwise redraw. A headless renderer draws while something reads its frames. `true` draws every frame on every renderer, for content whose picture changes in a way the engine does not see, or that is measured frame by frame. `renderer.framePacing()` reports the rule in force (`drawPolicy`), whether the last frame was drawn (`producing`), the frames declined (`idleSkippedFrames`) and what woke the renderer (`pictureChanges`, `lastPictureChange`). Takes effect on the next frame. `draw_every_frame` under `[render]` in the world's `.world_settings` seeds it, so a world states it once; a call here stays in force until that value changes.

argtypedescription
everyFramebooleanboolean true to draw every frame, false to draw only frames that show something new.

examples

renderer.setDrawEveryFrame(true) -- a benchmark measures every frame
print(renderer.framePacing().drawPolicy) --> every_frame
renderer.setDrawEveryFrame(false) -- back to drawing changes only

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.