Skip to main content

Module tiles

Module tiles 

Source
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:

  1. 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;
  2. 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);
  3. ask for what is wanted and neither cached nor asked for, cancel what was asked for and is no longer wanted;
  4. draw the proxy, then the exact tiles over it; stale tiles stay on screen until their replacements arrive;
  5. 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.
UploadBudget
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.
UploadReport
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.