Skip to main content

Module draw

Module draw 

Source
Expand description

What a layer draws with: the other half of the layer contract.

A layer makes its GPU objects through the Resources its hooks get and keeps their handles: VertexBuffers of #[repr(C)] vertices, which a mesh reads as the attributes of a layout (VertexBinding, Vertex), IndexBuffers and Textures; Meshes, which draw a program over them (MeshDesc), a DrawRange in each draw call; and Targets, textures of the layer’s own that its draws draw into ahead of the frame and that its other draws sample. Meshes share the buffers and textures they read. An object goes once its last handle drops and the GPU is done with it.

Each frame, a layer pushes its draws into its Draws: into its main Group, which draws at its place in the layers’ order and depth, and into the groups of its targets. A Draw of a mesh says where it is among the group’s draws, whether it may draw in the opaque pass, how it tests depth (Depth) and whether it clips to its tile, and comes with the values of its program’s blocks of each draw and, for a draw of a tile, the tile’s projection (projection). The engine writes the blocks once for the group, uploads the meshes, and draws the group in the frame’s passes.

A layer sees its frame as a LayerFrame: the map’s, or a drape’s. A layer that draws with the backend’s own commands asks the frame to lend them (Draws::lend), at a time in the frame (LendAt), and gets them with the frame and where it draws the map (Lent). What it makes with them, the engine doesn’t know of: the layer frees it once the GPU is done with it, through work it queues for after the GPU (AfterGpu).

The objects and their handles belong to the renderer’s thread.

Inside the engine, the renderer’s graphics state over its backend’s Gpu (context) keeps the stores of what draws share, and the queue that releases it in order.

Modules§

globe
The grid of a tile on the globe, which a layer that draws whole tiles draws there, and the rows of the poles’ vertices.
ground
What a program of a layer that stands on terrain or hides behind it declares. A program of a layer whose type stands on terrain (OnTerrain::Stands) declares the attribute GROUND_HEIGHT, which the engine fills, for a draw of its terrain variant, with the height of the ground under each of the draw’s points; one whose type hides behind the ground in front of it declares the texture GROUND_DEPTH, which the engine binds to the depth of the frame’s ground.
projection
Where a layer’s draws of a tile put its geometry, worked out on the CPU as the shaders work it out: the tile’s ProjectionData in a frame (tile_projection), the block that programs read it from (ProjectionData::ubo), the scale of extrusions on the globe (globe_extrude_scale), and the clip depth of 3D layers on OpenGL (zero_to_one_clip_z).

Structs§

AfterGpu
Where a layer queues work that waits for the GPU: what runs once the GPU finished the work that the renderer gave it so far, or once the renderer’s graphics objects are lost, such as the freeing of what a layer made with the commands a frame lent it (Lent).
Composite
How a draw group’s draws composite onto the frame, after they draw into a texture of their own.
Draw
How a draw of a mesh draws: its place among its group’s draws, its pass, its depth and whether it clips.
DrawRange
What one draw call of a mesh draws: index_count of the mesh’s indexes from first_index, each counted from the vertex base_vertex, for instance_count instances from first_instance. A range without indexes draws nothing.
Draws
A layer’s draws of a frame, the map’s or a drape’s, which the engine keeps between frames: its main group, which takes a place in the layers’ order and depth from the first frame that the layer has something to draw in, even with no draws; a group of draws into each target of the layer’s that the frame draws into (target); and where the frame lends the layer the backend’s commands (lend).
Group
A layer’s draws of a frame in one place in the layers’ order and depth, which the engine writes, uploads and draws in each of the frame’s passes, and what they share.
LayerFrame
The frame a layer makes its draws for, as it reads it: the camera, the target’s size and scale, the light and ground, and what it draws into.
Lent
What a frame lends a layer (Layer::lend).
Mesh
A handle of a mesh, the GPU objects of what a draw draws (DrawObjects), which the context’s store keeps while a clone of the handle lasts (Context::mesh). A layer keeps its meshes’ handles, in its tile values or its own state, and the draws it pushes name them (Group::push), so that the engine uploads and draws them after the layer made its draws. Clones of a handle are the same mesh. A mesh changes through the Resources that the methods here take.
MeshDesc
What a mesh is made of (Resources::mesh): vertex_count vertices that its vertices bindings read, the attributes of each instance that its instances bindings read, for a draw of instances, and the primitives of mode that its ranges draw of indexes, drawn with shader in color_mode and cull_face_mode, binding textures. An attribute the shader reads that no binding has reads its default value.
RenderPass
The render passes a layer draws in. A bitmask (OPAQUE | TRANSLUCENT is a valid value), so a newtype rather than a Rust enum.
RenderTile
A tile of a source that the frame draws: its id, its projection, and what of its contents the layers draw.
Resources
The renderer’s GPU resources, as a layer’s hooks make and read them: the vertex and index buffers and the textures of its meshes, the meshes it draws (mesh), and the targets its draws draw into (target). What it makes stays while the layer keeps a handle to it, and the buffers and textures while a mesh reads them.
Target
A texture that a layer’s draws draw into ahead of the frame, which its other draws sample: a handle of the target in the context’s store, which stays while a clone of the handle does.
Uniforms
The paint properties a draw reads from their uniforms instead, by name.
VertexAttribute
An attribute of a vertex layout: the program attribute name, read as format at offset bytes into each vertex.
VertexBinding
A vertex buffer a mesh reads, and how: its vertices of stride bytes, from the vertex first_vertex on, as attributes. Clones read the same buffer, which meshes share.
VertexBuffer
A buffer of vertices that meshes read (VertexBinding), with their count. It stays while a clone does; clones are the same buffer, and handles are equal where they are.

Enums§

Depth
How a draw tests and writes depth.
GpuEnd
How the GPU’s work that a piece of work after it waited for ended.
LendAt
When a frame lends a layer the backend’s commands (Draws::lend).

Constants§

POS
The attribute pos, a vertex’s position: two 16-bit integers, in tile units for a vertex of a tile.

Traits§

Vertex
A #[repr(C)] vertex type, and the attributes a program reads of it. vertex_attributes! declares them.

Functions§

refresh_paint_attributes
Binds again in mesh the vertices of its bucket’s paint values that refresh makes, where changes says feature state rewrote them: a layer’s prepare calls it with what its tile’s entry took (TileEntry::take_changes).

Type Aliases§

EvaluatedLight
The style’s light, evaluated for the frame.
IndexBuffer
Indexes of the context’s store.
Texture
A texture of the context’s store.
Textures
The textures a draw binds, by the slots of its program’s textures.