pub struct BatchDraw {
pub first_index: u32,
pub index_count: u32,
pub material: Material,
pub filter: ColorFilter,
pub blend: BlendMode,
pub clip: Option<Scissor>,
pub stencil: ClipState,
pub tint_blend: BlendMode,
pub paint_at_texture_coords: bool,
}Expand description
One draw within a batch.
Fields§
§first_index: u32§index_count: u32§material: Material§filter: ColorFilterA function applied to the material’s color before the blend.
Beside the material rather than inside it, for the same reason the blend mode is: it applies to every kind of material equally and belongs to none of them. It is packed into the same uniform the material is, because the shader reads one block per draw.
blend: BlendMode§clip: Option<Scissor>The region of the target this draw may write to.
None is the whole target. It is distinct from a rectangle that happens
to cover the target so a backend can tell “this draw was never clipped”
from “this draw’s clip works out to everything”, and skip the state
change in the first case without having to know the target’s size.
Independent of Self::stencil, and both apply. An axis-aligned clip
stays here even where a stencil is already in play, because a scissor is
exact and costs nothing while a stencil pass costs a draw.
stencil: ClipStateWhat this draw does with the stencil buffer.
tint_blend: BlendModeHow a color the caller attached to a vertex or a sprite combines with what the material produced.
BlendMode::Modulate multiplies them, which is what every draw did
before this existed and is what a paint with no per-vertex color wants:
white is the identity under it. Distinct from Self::blend, which is
how the result then reaches the target – these two colors are both in
the shader, so this one needs no extension and every mode is available.
paint_at_texture_coords: boolRead the paint at this draw’s texture coordinates rather than at the position of the fragment.
A property of the geometry rather than of the material, which is why it is here: a mesh that states a coordinate per vertex has said where each one sits in the paint’s space, and there is nothing left to derive. An image already worked this way and had its own material for it; this is what lets a gradient or a caller’s program do the same.
False everywhere else, and it costs those draws nothing: the flag lands in a slot no material that could set it uses, and the shader’s select is one instruction on a value it has already computed.
Implementations§
Source§impl BatchDraw
impl BatchDraw
Sourcepub fn to_uniform(&self, target: PixelFormat) -> [f32; 64]
pub fn to_uniform(&self, target: PixelFormat) -> [f32; 64]
The uniform block this draw’s shader reads.
The material and the filter are packed together because the shader
takes one block per draw, and separately here because they are separate
things: a filter applies to any material, and a material knows nothing
about being filtered.
target is the format this draw is about to be written into, which
only the backend knows: a recording is built without one, and the same
recording is drawn into an eight-bit surface and a float one. It decides
the dither, and nothing else here.