Expand description
Sprite (§5) GPU pipeline.
Renders one textured quad per active sprite into render_texture,
between the custom-shape pass and the borders pass. Two pipelines
cover the two blend modes the engine emits (SpriteBlendKind —
alpha or additive). Each sprite draw owns its own bind group
recreated per frame so we can bind a different texture per draw
without an atlas (sprites in the wild are few, ~handful per
frame, so per-draw bind groups are cheap).
The renderer drives this through SpritePipeline::record, which
takes a slice of SpriteDrawCmd produced by
[crate::sprite_pipeline::SpritePool::build_draw_commands]. The
pool resolves the engine-side texture_index to a real
[wgpu::TextureView], applies aspect ratio correction, and packs
the per-sprite uniform.
Structs§
- Sprite
Draw Cmd - One sprite ready to draw. The renderer assembles these from the
engine’s
SpriteFramelist + the spriteSpritePool. - Sprite
Frame - One per-frame sprite the engine asks the renderer to draw. POD —
no GPU resources, just numbers. The renderer resolves the
texture_indexthrough itsSpritePooland builds theSpriteDrawCmdinternally each frame. - Sprite
Pipeline - Sprite GPU pipeline. Owns two
RenderPipelines (alpha + additive) and a per-slot uniform buffer; the renderer constructs / drives it once per chain. - Sprite
Pool - Sprite texture pool: one texture per sprite def, in load order.
Engine-side
SpriteRenderInstance::texture_indexindexes intotexturesdirectly. Missing / undecodable files get a 1×1 transparent fallback so the bind group always populates. - Sprite
Texture - One GPU-resident sprite texture.
- Sprite
Uniform - Per-sprite uniform pushed to the GPU each draw. 48 bytes; the
pipeline allocates
MAX_ACTIVE_SPRITES * 256 Btotal uniform storage so each draw can dynamic-offset into its own slot.
Enums§
- Sprite
Blend Kind - Which of the two GPU pipelines to use for a given sprite. Mirrors
onedrop_engine::SpriteBlendMode; kept independent so the renderer compiles without an engine-side dep cycle.
Constants§
- MAX_
ACTIVE_ SPRITES - Hard cap on simultaneously active sprites. The active list is pruned every tick so this only matters during a key-mash spawn burst; 64 is well above MD2’s practical limit (~5-10).
Functions§
- build_
sprite_ uniform - Build a
SpriteUniformfrom raw engine-side numbers + texture dimensions + render aspect ratio. Pulled out so the renderer’supdate_spritesstep can produce a single contiguous list of uniforms for upload + the matching draw-cmd list without recomputing aspect ratios per call. - default_
sprite_ dirs - Default search paths for sprite assets. The engine extends this with config-driven dirs.
- load_
sprite_ 🔒file - make_
fallback 🔒 - pick_
first_ existing - Pick the first existing directory from a search-path list.
- upload_
sprite_ 🔒rgba8