pub struct DrawEntry {
pub pipeline: RenderPipeline,
pub bind_groups: ArrayVec<BindGroupBinding, MAX_BIND_GROUPS>,
pub vertex_buffers: ArrayVec<VertexBufferBinding, MAX_VERTEX_BUFFERS>,
pub index_buffer: Option<(Buffer, Range<u64>, IndexFormat)>,
pub scissor: Option<ScissorRect>,
pub stencil_reference: u32,
pub order: DrawOrder,
pub range: DrawRange,
}Expand description
One draw: the pipeline and every resource it binds, followed by what to draw.
A draw carries the union of the bind groups the pipeline, its material and the mesh need, at the slots they name. The renderer’s built-in pipeline expects three or four vertex buffers — position, optional joints and weights, UV and vertex color, and the per-instance model matrix and base color — but the shape is generic, so custom pipelines can bind whatever they declare.
All slots are inline: a draw never allocates, so a whole scene can be rebuilt each frame without touching the allocator.
Fields§
§pipeline: RenderPipelineThe render pipeline to bind.
bind_groups: ArrayVec<BindGroupBinding, MAX_BIND_GROUPS>Bind groups, bound at the slots they name. The built-in pipeline uses index 0 for the camera, frame globals and mesh metadata, index 1 for the material, and any remaining slots for mesh-level groups.
vertex_buffers: ArrayVec<VertexBufferBinding, MAX_VERTEX_BUFFERS>Vertex buffers, bound at the slots they name.
index_buffer: Option<(Buffer, Range<u64>, IndexFormat)>Index buffer, the byte range read from it and its format, when the draw is indexed.
scissor: Option<ScissorRect>Pixels outside this rectangle are discarded.
A draw that sets it clips in the rasterizer instead of in the geometry.
None means “leave whatever the pass already has”, not “cover the
whole target”: wgpu’s scissor is pass state with no reset call, so
once a draw sets one it stays set for every later draw in the pass —
ordering a clipped draw last is the caller’s job, which in a composite
is what DrawOrder::After is for.
stencil_reference: u32The stencil reference value the draw tests against.
Set on every draw (defaulting to 0, the pass’s own default), so a
draw that does not name one resets a value an earlier draw left behind.
order: DrawOrderWhere the draw sits in the composite of a pass’s scenes.
Scene::record ignores it. Scene::record_composited groups
its scenes’ draws by it; the default, DrawOrder::Before, keeps
the draw where its scene listed it.
range: DrawRangeWhat to draw.
Implementations§
Source§impl DrawEntry
impl DrawEntry
Sourcepub fn new(pipeline: &RenderPipeline, range: DrawRange) -> Self
pub fn new(pipeline: &RenderPipeline, range: DrawRange) -> Self
A draw of range with the given pipeline, no bind groups, no vertex
buffers, no index buffer, no scissor and a zero stencil reference; fill
in the fields the pipeline needs.
Sourcepub fn with_bind_group(self, index: u32, bind_group: &BindGroup) -> Self
pub fn with_bind_group(self, index: u32, bind_group: &BindGroup) -> Self
Bind bind_group at index.
Sourcepub fn with_vertex_buffer(self, slot: u32, buffer: &Buffer) -> Self
pub fn with_vertex_buffer(self, slot: u32, buffer: &Buffer) -> Self
Bind buffer whole at vertex-buffer slot.
Sourcepub fn with_vertex_buffer_range(
self,
slot: u32,
buffer: &Buffer,
range: Range<u64>,
) -> Self
pub fn with_vertex_buffer_range( self, slot: u32, buffer: &Buffer, range: Range<u64>, ) -> Self
Bind range of buffer at vertex-buffer slot.
Sourcepub fn with_scissor(self, scissor: ScissorRect) -> Self
pub fn with_scissor(self, scissor: ScissorRect) -> Self
Discard fragments outside scissor. It stays set for every draw after
this one in the pass, so see DrawEntry::scissor.
Sourcepub fn with_index_buffer(self, buffer: &Buffer, format: IndexFormat) -> Self
pub fn with_index_buffer(self, buffer: &Buffer, format: IndexFormat) -> Self
Bind buffer as the index buffer, reading all of it.
Sourcepub fn with_order(self, order: DrawOrder) -> Self
pub fn with_order(self, order: DrawOrder) -> Self
Place the draw in the composite of a pass’s scenes; see DrawOrder.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DrawEntry
impl !UnwindSafe for DrawEntry
impl Forget for DrawEntry
impl Freeze for DrawEntry
impl Send for DrawEntry
impl Sync for DrawEntry
impl Unpin for DrawEntry
impl UnsafeUnpin for DrawEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more