Drawables graphics backend

Author: birkskyumCreated Aug 5, 2024Updated Sep 23, 2026

The current renderer is immediate mode: every frame, each draw_*.ts function walks its tiles, looks up buckets, sets up to dozens of individual uniforms per draw call, rebinds textures, and issues the draw, then forgets everything. The next frame does it all again, even when nothing moved.

A drawables renderer is retained mode. A Drawable is a persistent object holding what one draw call needs: geometry, shader, textures, pipeline state and its uniform buffers. It lives as long as its tile is needed. Per frame, a tweaker writes the values into the uniform buffers, and only buffers whose bytes changed are uploaded, so a static camera uploads almost nothing.

This is the architecture MapLibre Native adopted in its render modularization (gfx::Drawable, LayerTweaker, uniform buffers). Besides speed, it is the groundwork for WebGPU, which needs every draw described up front with its shader values in uniform buffers.

What changes for each layer type: its draw function is split into preparing drawables and drawing them, and its shader uniforms move into std140 uniform buffers. Each PR replaces the old path directly, with the render tests covering every layer type. Custom layers keep their current API.

Milestones are tracked in #7640 (Phase 3). Phase 2 there moved the shared projection, terrain and per-frame state into uniform buffers first, since every layer's drawables read them.