Skip to main content

Module config

Module config 

Source
Expand description

The Config uniform every strip shader binds.

Named GpuConfig rather than Config because the crate root already owns a config module of process-wide kill switches (crate::config); this one is the GPU-side uniform buffer’s layout and nothing else.

Field order and size are part of the shader contract — see the module header of super.

§The width shifts are the source of truth

The strip program addresses its resource textures by shift and mask alone: a flat texel index i in a texture 1 << bits wide is the texel (i & ((1 << bits) - 1), i >> bits). It never asks a texture for its own width (textureDimensions per fragment was measurably not free on a mobile GPU), so the two shifts here are the only statement of those widths the GPU sees, and three textures depend on them:

resource_widths_agree is that rule as a check: a debug_assert! at the one site that builds the surface config from the resource textures (renderer’s config upload); the pooled-page configs are built from the same dim in the same frame and are not re-checked, and a release build checks nothing. The one pass with a narrower stand-in — the glyph-atlas replay, whose encoded-paint texture is a one-texel placeholder — draws solid instances only, which read neither the paint texture nor the LUT, so its config’s paint shift addresses nothing.

Structs§

GpuConfig
The uniform block the strip shaders read once per draw.

Functions§

resource_widths_agree
Whether a frame’s three strip resource textures are exactly as wide as the config built for dim says — the precondition of the strip program’s shift-and-mask addressing (see the module doc).
tex_width_bits
log2 of a resource texture’s width in texels.