Skip to main content

BatchDraw

Struct BatchDraw 

Source
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: ColorFilter

A 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: ClipState

What this draw does with the stencil buffer.

§tint_blend: BlendMode

How 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: bool

Read 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

Source

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.

Trait Implementations§

Source§

impl Clone for BatchDraw

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BatchDraw

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.