Expand description
The tile cache: what to ask the source for, what arrived, what is drawn, and what to forget when over budget.
Experimental: may change in any release
(docs/stability.md).
Each frame, for each side shown:
- take what the source delivered (a tile answering a request no longer wanted is dropped, a changed region marks its tiles stale) and upload it, within the upload budget when one is set: the tiles of the visible area first (proxy, then the view’s scale, then other scales), then the others nearest the view’s centre; the rest waits for the next frame, kept when the view moves;
- want the proxy (the whole image at a power of two at or below the
fit scale) and, once the view has settled, the exact tiles of what
is visible at the view’s scale (
min(zoom, 1), so below 100 % one texel lands on one physical pixel); - ask for what is wanted and neither cached nor asked for, cancel what was asked for and is no longer wanted;
- draw the proxy, then the exact tiles over it; stale tiles stay on screen until their replacements arrive;
- evict the least recently drawn tiles past the budget, never one drawn this frame.
Tiles are textures of at most the device’s largest texture side, so an image or a window larger than the GPU’s limit is drawn whole.
Structs§
- Device
- What the device allows, from the GPU path’s install (or egui’s limits on the CPU path).
- Transfers
- Tile pixels copied from the CPU to the GPU, counted where the copy
happens: an egui texture loaded (the CPU path), a GPU path texture
written at the paint. Device tiles are bound in place and count as
bound, with no byte. The draws’ uniforms (a few hundred bytes a frame) are not tile pixels and are not counted. - Upload
Budget - How much a frame uploads at most: tiles and bytes (whichever is
reached first; at least one tile a frame). What is left waits for the
next frame, never dropped.
UploadBudget::DEFAULT(8 MiB a frame) unless the viewport is told otherwise. - Upload
Report - What the uploads of the last frame did.
Constants§
- DEFAULT_
BUDGET - The default texture budget, in bytes.
- DEFAULT_
SETTLE - The default time the view stays still before exact tiles are asked for, in seconds.
- MIN_
PROXY_ SCALE - The coarsest proxy scale.
- TILE_
SIZE - The default side of a tile, in pixels.
Functions§
- exact_
scale - The exact scale of a view: one texel per physical pixel below 100 %, the image’s own pixels above.
- proxy_
scale - The proxy scale for an image in a view: the power of two at or below the fit scale, at most 1.
- scaled_
size - The scaled image’s size at
scale.