Expand description
Device tiles (feature wgpu): a tile that already lives on the
render device, handed to the viewport with no copy through the CPU.
A source that renders on the GPU (an engine running on the device
eframe opened) answers a request with a DeviceTile through
TileSink::deliver_device:
- a texture (
DeviceTile::texture): any 2D float-sampled format (Rgba16Float,Rgba32Float,Rgba8Unorm,Rgba8UnormSrgb…), withTEXTURE_BINDINGusage, read texel by texel; - a storage buffer (
DeviceTile::buffer):f32values, one to four channels a pixel, rowsrow_floatsapart (BufferLayout), withSTORAGEusage, read in place (the GPU path binds the rows the tile covers, nothing is copied).
Its values are scene-referred (Encoding::Scene, as
Pixels::Scene: the display stage runs on them in the shader, as for
uploaded tiles) or display-ready (Encoding::Display, as
Pixels::Display: sRGB-encoded, shown as they are). Alpha is not
drawn: the image is opaque, as on the GPU path’s uploaded tiles.
The resource must have been created on the render state’s device (the
one gpu::install was given), and the work
writing it submitted to that device’s queue before the hand-over. A
tile from another device, or one that does not fit, is refused with a
DeviceTileError: the source’s fallback (DeviceTile::fallback),
when it offers one, then gives CPU pixels that take the usual path.
The fallback runs on the thread that delivers the tile, never on the
interface thread: a tile refused when the interface takes it in (the
render device changed in between) is dropped and asked for again.
What the producer needs alive while the tile is shown (its image, with
the charge it carries in the producer’s memory accounting) rides with
the tile (DeviceTile::keep): the viewport holds it exactly as long
as it holds the tile, and drops it when the tile is replaced, evicted
or refused, or the viewport’s state is dropped.
The viewport’s upload counters
(ViewportState::transfers) count
device tiles as bound, with no byte copied.
Structs§
- Buffer
Layout - Where a tile’s pixels are in a storage buffer of
f32values: pixel(x, y)of the image starts at floatoffset / 4 + y * row_floats + x * channels. - Device
Tile - A tile on the render device: the resource, the device it was created on, what its values are, and where the tile starts in it.
- Render
Device - The render device the GPU path draws with, as device tiles are checked against it.
Enums§
- Device
Tile Error - Why a device tile was refused.
- Encoding
- What a device tile’s values are, as
Pixelssays for CPU tiles. - Resource
- The resource a device tile reads.