Quality tiers, GPU memory (VRAM) and memory pressure, texture streaming, render target cost and loaded content
The device's quality tier: phones, desktops and the defaults between them
Every device is assigned a quality tier at boot ("low", "medium" or
"high", from its GPU, memory and display), and every renderer default a
world's settings leave unstated comes from it: the render scale, the shadows
(how far the sun shadows, its page detail and depth budget, how often its
pages update, the lookup filter and whether local lights cast), the texture
budget and the anisotropy. A desktop is "high", the renderer as it has
always run there; a phone renders the scene below a dense display's
resolution with the UI at full resolution, and bounds its shadows to its
frame budget. renderer.qualityTier() reads it and
renderer.setQualityTier() chooses another, which is a whole graphics setting
on every platform. The graphics-quality guide
(guides { path = "topics/graphics-quality" }) covers the tiers, their
defaults and how each level of override stands over the one before.
What the GPU states of its memory, and standing in for a smaller one
A soak under a smaller GPU runs in this order: the zero lines are bash calls,
and the lines that name renderer. are Luau calls (execute).
# 1. before the limit, one shot
zero profiler memory
# 2. set the limit and read its answer (execute), then wait 2.5 s
# print(renderer.limitDeviceMemory({ megabytes = 4096 }).drawsEveryFrame)
# 3. one shot under the limit
zero profiler memory
# 4. the background series; its header records the limit and the pressure
zero profiler memory --every 30 --span 300 --to /source/tmp/soak.txt &
# 5. while the series runs, move the measured view far from a surface until
# its row's demandedLevel rises, then back near, one execute call per move,
# reading renderer.textureStreaming().textures after each:
# local body = layers.active.players.localPlayer.avatar
# body.position = { x = farX, y = 2, z = farZ } -- far, then near again
# or, in edit or play, with a camera standing far:
# camera.setEditorOverride(farCamera.id) -- far
# camera.setEditorOverride(nil) -- near again
# a still view, or a walk at room or street distance, records no hold
# 6. read the file: the readings so far, ending with `series done`
cat /source/tmp/soak.txt
zero logs search "pressure source"
# 7. lift the limit and read its answer (execute)
# print(renderer.limitDeviceMemory().limited) -- false
The series runs as a background job: the call returns at once, other calls go
on while it takes its readings, and --to writes each reading's lines to the
file, as plain text, as the reading is taken.
The series' held rows record the hold only while the view is far and when it
comes back, so step 5 runs while the series runs. In play, the local player's
body is layers.active.players.localPlayer.avatar (re-resolve it after each
play start), and writing its position moves the measured view; a body moved
off the ground falls until its position is written again. A far camera is an
entity with a Camera component standing where the view should be:
local farCamera = entity.spawn("farView", { temporary = true })
farCamera.position = { x = 0, y = 15, z = 612 }
farCamera.component.add("Camera", { priority = -10 })
farCamera.component.get("Camera"):lookAt({ 0, 15, 12 })
In play a camera added with the default priority takes the viewport by itself
and priority = -10 leaves the viewport to camera.setEditorOverride.
The texture streaming plan keeps each texture's mip levels within a texture budget, and when the GPU runs short of memory (memory pressure) it evicts the levels the view does not sample and takes no finer level while the pressure stands. This section reads that budget and that pressure, and stands in for a GPU with less VRAM than the one the engine runs on.
zero profiler memory, the profiler toolbox's memory tool run from the
engine's bash, prints the GPU's heaps with any limit held to a smaller figure,
every pressure source, then the engine's memory, so a reading before and after
a change is one call. For a reading over minutes it takes a series: zero profiler memory --every 30 --span 300 takes a reading every 30 seconds for 5
minutes. It opens with the GPU's heaps and every pressure source, as the one-shot
prints them, so a series started under a limit records the state it ran under;
then it prints one row per reading (the GPU's held figure against its limit,
the strongest pressure level and its source, the texture budget in force with
the starved and parked counts), then the first and the last side by side.
Under a row, a part of the graphics device (gpu.textures, gpu.compute,
gpu.unclaimed, as the one-shot report prints them under "graphics device")
whose bytes moved by 16 MB or more since the first reading whose allocator ledger was read after the series began prints
as device grew: gpu.textures +3412.0 MB, the largest move first. A line under each row
(and in the one-shot, under "graphics device") divides gpu.textures: the
textures the frame streams, the textures scripts made with the three owners
holding the most of them (the component, its entity, the texture count and the
bytes), and the rest, which neither of the two states; when the script-made
share is what grew, the device grew: line names it. renderer.gpuMemory().allocator.byLabel
names the allocations of a part. One line per texture held coarser than its surfaces ask for gives
its key, residentLevel/demandedLevel and heldBy, and the first and last
reading count the held rows by heldBy. The pressure source level changes the
log recorded since the previous reading print as log lines before its row.
A source of pressure changing level is logged once, as rose or eased from
the old level to the new one, with its held figure against its limit: zero logs search "pressure source" lists each change. The levels run mildest first,
normal < moderate < low < critical, so a change from moderate to low
is the pressure rising.
renderer.limitDeviceMemory makes the world run as it would on a GPU with that
much memory. An engine that draws only on request (a headless engine, an
agent's own sub-client) draws only for what reads its frames, so the limit holds
draw-every-frame on while it stands, and the answer's drawsEveryFrame says
so. The limit takes effect within two seconds. Three calls read what it did:
renderer.deviceMemory() (limitedBy, limitBytes),
renderer.memoryPressure().sources, and the textures rows of
renderer.textureStreaming() (each row's key, residentLevel,
demandedLevel and, while something holds the texture coarser than it asks for,
heldBy).
local held = renderer.limitDeviceMemory({ megabytes = 4096 })
print(held.drawsEveryFrame) -- true where the engine draws only on request
task.wait(2.5) -- the reading takes the limit within two seconds
local dm = renderer.deviceMemory()
print(dm.limitedBy, dm.limitBytes)
for _, source in renderer.memoryPressure().sources do
print(source.name, source.level, source.heldBytes, source.limitBytes)
end
for _, row in renderer.textureStreaming().textures do
print(row.key, row.residentLevel, row.demandedLevel, row.heldBy)
end
-- The limit holds for the world session until it is lifted.
local lifted = renderer.limitDeviceMemory()
print(lifted.limited) -- false
renderer.deviceMemory() reports the memory the GPU allocates from, as the
device states it, read every two seconds. heaps has one row per memory heap:
deviceLocal (the GPU's own memory, or the memory an integrated GPU shares
with the CPU), its sizeBytes, and, where the device states them, the
budgetBytes the operating system lets this process hold in that heap right
now and the usageBytes the process holds. The budget is the system's
statement: on a card other programs share it can sit far below the heap's size,
and usage can stand above it. source names who stated the figures,
heapsCounted which heaps the pressure share counts ("deviceLocal", or
"every" on a GPU that draws from the system's RAM), heldBy the figure the
share reads ("device", the usage the device states, or "engine accounting", the bytes the engine's own count says it holds on the device),
and system the RAM the system states (totalBytes, availableBytes, and
addressableBytes, the part of it the process can address). A browser states
no GPU memory figure: the report then reads available = false with its
reason.
local dm = renderer.deviceMemory()
if dm.available then
for _, heap in dm.heaps do
if heap.deviceLocal and heap.budgetBytes and heap.usageBytes then
print(("%.0f of %.0f MiB held"):format(heap.usageBytes / 1048576, heap.budgetBytes / 1048576))
end
end
end
renderer.limitDeviceMemory({ megabytes = 512 }) holds the GPU memory the
engine reads to 512 MiB for the world session, so the world runs as it would on
a GPU with that much: the device pressure source reads the bytes the counted
heaps hold against 512 MiB, and renderer.deviceMemory() reads the limit back
as limitedBy = "script" and limitBytes, beside each heap's usageBytes. The
limit takes effect at the next reading, within two seconds, and leaving or
swapping the world ends it; renderer.limitDeviceMemory() lifts it at once. The limit also holds the texture budget the device's own
rule gives to the one a device with that much memory gets (a quarter of it, at
least 256 MiB, never above the device's own budget), which
renderer.textureStreaming() reports as deviceBudgetBytes and
memoryBudgetBytes and the residency plan applies; a
renderer.setTextureBudget override still stands over it, and budgetRule
stays the rule the device's own budget came from. The system's RAM, the
process's own memory and the budgets that are shares of the system's RAM are
the machine's. An engine that draws only on request (a headless engine, an
agent's own sub-client) holds the textures nothing reads at their floor
(renderer.textureStreaming().unread), so the limit holds draw-every-frame on
while it stands and the residency it measures is read on drawn frames. A
script's own renderer.setDrawEveryFrame call while the limit stands is
honoured, and the limit then stops holding draws on; renderer.limitDeviceMemory()
gives back the setting the engine had before, or leaves it as the script set
it.
renderer.textureStreaming() measures one view: the camera that holds the
viewport (camera.viewData()), at the viewport's pixel size. In edit that camera
is the EditorCamera; in play it is the scene's active camera (CameraRig in a
scene with the default setup, which follows the player's body), and
camera.active() names it in either mode. Each of its textures rows'
demandedLevel, screenPx and sampledPx follow where that camera stands, so
moving the player in play moves the measured view. A capture rendered from
another pose (source = "position") draws with the levels the plan holds for
the viewport's measurements and adds nothing to the demand, so a capture
standing close to a surface shows the level the viewport's own distance asked
for, and the textures rows do not move for it. To drive the plan from a chosen
pose, in edit or in play, give the viewport a camera standing there with
camera.setEditorOverride(cameraEntityId): camera.viewData() and the plan
follow it. Wait for drawn frames and read the textures rows;
camera.setEditorOverride(nil) gives the viewport back.
The rows describe the view of the engine you call, from the client you call it
in: an agent working in its own client (a sub-client) reads that client's camera
and the player it moves there, and the engine's primary client holds its own
plan from its own camera at the same moment. A surface that repeats its texture
(a material's uvScale above 1) keeps asking for the finest level until one
repeat covers few enough pixels: the level asked for is the coarsest one that
still has at least one texel per pixel across one repeat (sampledPx). A 1024
by 1024 texture repeated 8 times across a wall that fills the view, in a 1920 by
1080 viewport, reads demandedLevel = 0 at 5 m, 25 m and 100 m from the wall
(sampledPx about 13200, 2600 and 660), first reads above 0 at about 130 m
(sampledPx about 509) and reads 2 at 400 m. That distance follows the texture,
the repeat count, the surface and the viewport, so read sampledPx and
demandedLevel from the row rather than a distance. A tiled surface keeps
asking for its finest level until one repeat covers no more pixels than half its
texels (509 against 1024 above), so a player walking at room or street
distances, tens of metres, leaves its demandedLevel at 0 and starved at 0.
To see the hold under a standing level, move the measured view as far as the
row's demandedLevel needs to rise (read the row to confirm it rose; the
texture goes coarser with it), with camera.setEditorOverride on a far camera
or by moving the player that far, then back near.
renderer.memoryPressure().sources says which source of pressure stands and
why. Each row is one source, by name: bound (the memory bound the engine's
process tree runs under), device (the share of the counted heaps' budget the
process holds), system (on Android, the share of the memory the system leaves
to apps that is in use, which reads critical when the system reports itself low)
and allocation (what stands after the device reported an out-of-memory
error). A row carries its level, what it reads
(scope) and the heldBytes against its limitBytes, and where it reads
nothing, why. A source holds the engine at its level for as long as it holds that
share of its limit: 80% moderate, 90% low, 95% critical. The strongest standing level (normal < moderate < low < critical) is the
pressure in force, and it
reaches the textures: from "moderate" the residency plan holds every texture
at the level its surfaces sample and takes no finer level, so a texture that
reads blurry while a level stands is held there, and at "critical" the texture
budget in force is halved. renderer.textureStreaming() shows both:
budgetBytes is the budget in force (the device's own, whole at "normal",
"moderate" and "low" and halved at "critical"), and heldBudgetBytes is
what streaming may hold now, a different figure: equal to budgetBytes while no
pressure stands and, from "moderate" up, what the textures already hold (it
can read a few MiB beside a budgetBytes of hundreds). budgetRule names the
rule the device's own budget came from.
While a level stands, a texture still goes coarser when its view asks for less
of it, and takes no finer level. A texture already at the level its view asks
for reads starved = 0, so a view that stays near a surface keeps reading it
sharp. The hold shows on a texture that went coarser while the level stood,
once the view asks for more of it again: move the measured view far from the
surface, where its row's demandedLevel and residentLevel rise together,
then back near, and the row reads residentLevel above demandedLevel (a
larger level is a coarser one) and heldBy = "pressure", and starved counts
it. A surface the view turns away from keeps its last measurement and its level.
A row says what holds it coarser than it asks for in heldBy: "pressure", a
standing pressure level refuses it a finer level; "budget", the budget took it
coarser; "unread", nothing reads the view, so the texture sits at its floor
until a frame is drawn for a reader. starved counts the rows held by pressure
or the budget, and parked counts the rows held by "unread", so an engine that
draws only on request reads starved = 0 and parked above zero until
renderer.setDrawEveryFrame(true), a renderer.limitDeviceMemory limit or a
wait on drawn frames lifts it. A row
that holds the level it asks for, or a finer one, and a row still stepping
toward its level, carry no heldBy.
What the render targets cost
renderer.renderTargets() measures every target the renderer owns from the
texture that is allocated: the scene depth, the G-buffer, each shadow map, the
reflection-probe cubes, the transparency buffers, the post-process chain's
ping-pong pair, the game viewport's own set, and the scratch the draws into a
render target have needed — those rows are named camera[<handle>] after the
texture drawn into: depth and motion vectors under any rasterized pass, and the
occlusion, reflection and colour-history channels, the scene copies and the
G-buffer under a camera's scene render. That scratch is built by the draw that
needs it, or taken from a released target of the same size. It is released to
the next target of its size when no live camera names the target and when the
target is destroyed or resized, and freed once sixty frames pass without a
draw, so a target nothing draws into holds its colour texture and nothing else.
Released scratch waits as
released_scratch[<width>x<height>] rows for the next target of that size
(newest first, within 64 MiB, for sixty frames), so a burst of captures, each
into a target of its own, builds its scratch once per size. The colour texture
a destroyed or resized target drew into waits the same way, as a
released_scratch[<width>x<height>].color row, for the next target made at
its size and format, which starts from it cleared to transparent black.
allocations counts the render-target allocations made since the renderer was
built, the colour textures of the live targets included, each on the first frame
whose report holds it. A target taken back at a
size it held before is the same allocation and adds nothing, so two readings
around a piece of work say how many targets that work allocated.
local rt = renderer.renderTargets()
print(("%.1f MiB over %d targets"):format(rt.totalBytes / 1048576, rt.residentCount))
for _, t in rt.targets do
print(t.name, t.resident, t.bytes, t.width .. "x" .. t.height, t.layers)
end
A row marked onDemand exists only while something needs it, and reads
resident = false, bytes = 0 the rest of the time. The weighted-blended
transparency buffers hold nothing at all until a pass accumulates into them —
the clear and composite that bracket the accumulation are skipped for those
frames too, since a composite over a buffer nothing wrote reproduces the image
underneath it. The reflection-probe cube array holds one cube slot until probes
need more of it, so a scene with no probe pays 2.10 MB rather than the 18.87 MB
of eight probe slots plus the sky fallback's. The shadow page pool is held
while any light casts — the sun, or a spot, area or point light — and released
while none does, and a frame drawn with shadows or lighting off has no light
cast. A
camera rendering into a texture brings its own depth, motion vectors, occlusion
and G-buffer with it, and takes them away again with the camera.
So the total moves with what the scene does, and comparing two scenes' totals says what the second one's content costs in render-target memory. The colour image a render-texture camera draws into is the one thing absent from the report: it lives in the shared texture cache and is sampled by guid like any other texture, so the camera is one of its holders rather than its owner.
What the engine holds for content, and why an asset will not load
renderer.renderTargets() above measures the targets the renderer owns.
asset.observe() answers the other question — every texture and mesh the
device is holding for content, with the bytes each costs:
local r = asset.observe()
for _, t in r.textures do print(t.identity or t.key, t.bytes, t.width .. "x" .. t.height) end
for _, m in r.meshes do print(m.identity or m.guid, m.bytes) end
print(r.totals.textureBytes, r.totals.meshBytes, r.totals.cpuCount)
The pools are named because they are different pools. textures and
meshes are the device's; cpu is the set a live script-component context
holds, which is what warms an asset's bytes into memory; offDevice is every
mesh nothing displays, whose GPU buffers were given back. An asset can be in one
and not the others. A row carrying an identity reached the device through that
asset; a row without one is held under a guid no asset claims: a camera's own
render target, a glyph atlas a script built.
An offDevice row says what the engine keeps to put that mesh back on the
device the next time something displays it, and what it costs. held is
"source" for a .mesh asset whose stored file holds exactly the definition
the engine had: the engine keeps only that file's path (source), costs no CPU
memory for the mesh (bytes is 0), and reads the file again on the next bind.
held is "definition" for every other mesh: a mesh renderer.mesh.create
built, an asset mesh edited live away from its file, and the engine's built-in
primitive shapes (@builtin::meshes.cube, sphere, plane, cylinder,
capsule, cone and octahedron), whose definitions the engine generates
rather than reads from their files. The engine keeps that whole CPU
definition, and bytes is what it costs. totals.offDeviceBytes sums them.
for _, m in asset.observe().offDevice do print(m.identity or m.guid, m.held, m.bytes) end
totals carries the aggregates the rows sum to, so the listing reconciles
against renderer.textureMemory() and the meshes category of
renderer.gpuMemory() exactly. renderer.texture.list() and
renderer.mesh.list() report the same resources from the renderer's side, with
the script registry's origin and owner alongside.
renderer.references(kind, guid) answers the other question about one of those
rows — what is still holding it, named consumer by consumer — and
renderer.collect() releases every runtime texture, material, mesh and render
feature that nothing holds, which is also what a root scene load runs once the
new scene stands. The core/resource-model guide states the ownership rule both
of them read. devicePublished and
cpuPublished say whether the engine can answer at all, which reads differently
from an engine answering with nothing resident.
The same reading is served at /zero/runtime/residency for a reader outside
Luau, with textures, meshes, cpu, offDevice and totals readable on
their own.
Compute's own GPU resources are a separate pool again, and the compute
category of renderer.gpuMemory() is what they cost. compute.observe() lists
them one row per resource — every storage and uniform buffer, every 3D texture,
storage target, history pair and sampler — each with its bytes, the shader that
made it and the frame it was created on, summing to that category exactly.
compute.diagnose(key) answers the other half: when a resource key names
nothing, which of the states the inventory distinguishes it is in. Both are
covered at guides { path: "types/computeShader" }, and the reading is served
at /zero/runtime/compute.
Why one asset will not load — which file its type's declared primary
resolved to, whether the bytes decode, and the reason when it cannot be used —
is asset.diagnose(ref), covered in the asset-system guide.