Skip to main content

Module bindings

Module bindings 

Source
Expand description

The registry of caller-owned textures a frame’s strip passes sample, and the per-frame batching that binds each of them in turn.

The engine draws two kinds of image. An atlas-backed one lives in the renderer’s own array texture, addressed by layer and rectangle, and every draw of the frame reads it through the same binding. An external one is a texture the host created and still owns — a video frame, a plugin’s import, an offscreen page some other pass rendered — which the engine never copies and never packs. It is bound as a whole texture instead, and the strip shader’s image path reads it through a second binding chosen by the encoded paint’s source-kind bit (see shaders/helpers.wgsl).

One binding, many textures: a frame that draws two different external textures cannot bind both at once, so its instances are split into runs — maximal spans of consecutive instances sharing one texture — and each run is drawn with that texture bound. ExternalRuns assigns the slot numbers the renderer’s pass segments name a run by; the renderer builds one group-1 bind group per slot and sets it between runs.

Nothing here allocates a texture or copies a texel. ExternalTextures is a plain map the host writes through EngineRenderer::bind_texture/unbind_texture, and it is generic over the stored view type — like frust_gpu::TextureRegistry, so its own behaviour stays host-testable with a stand-in value and no GPU device in the loop.

The extent half of the same registry lives on the compiler side, in crate::compile::external::ExternalExtents: the walk needs it to compose a paint transform, while only a pass needs the view. The one call that writes both keeps them in step.

§The strip programs’ one explicit layout

Every strip pipeline — each render-state variant, and each paint-class specialisation of it — is built against ONE explicit wgpu::PipelineLayout, strip_pipeline_layout, rather than the layout wgpu would derive from its module. A derived layout is whatever bindings the module’s entry points statically use, and a class program that no longer reads, say, the atlas array would derive a layout without it; the bind groups built for one class would then not fit another. The explicit layout is exactly the one the whole (Uber) program derives — strip_bind_group_layout_entries restates it entry for entry, and its test holds that restatement to the naga reflection of strip.wgsl — so a bind group built against any strip pipeline binds under every other one.

There is one such layout per program family (crate::gpu::shader_src’s The two program families): the manual family’s (FRUST_ENGINE_IMAGE_SAMPLER=0) is the one above, and the sampler family’s — the default — adds the one sampler its image programs filter the atlas through — group 1, binding 2 — and declares the atlas binding filterable. Every binding before it keeps its number, so the families differ by that one entry, and the four-group WebGL2 ceiling is untouched.

Structs§

ExternalRuns
The distinct external textures one frame draws with, in the order it first names them.
ExternalTextures
Every externally owned texture currently bound, keyed by the SceneTextureId its owner minted.

Constants§

ATLAS_SAMPLER_BINDING
The sampler family’s sampler binding: group 1, after the two image textures.
STRIP_BIND_GROUP_COUNT
How many bind groups the strip programs declare — the WebGL2 ceiling of four, exactly (see crate::gpu::pipelines’s Bind groups).

Functions§

lower_encoded_external
Lower one encoded external texture into the record the strip shader samples.
strip_bind_group_layout_entries
The strip programs’ bind-group layout entries, group by group, exactly as wgpu derives them from the whole (Uber) program of the family image_sampler names — binding, type and visibility.
strip_pipeline_layout
The one explicit pipeline layout every strip pipeline of the family image_sampler names is built against.