pub struct RenderPassInstance<'a> {
pub label: String,
/* private fields */
}Expand description
RAII wrapper over wgpu::RenderPass with guard rails to prevent draws without required
state (pipeline + vertex/index buffers).
§Example
use wde_wgpu::{
buffer::Buffer,
render_pass::RenderPass,
render_pipeline::RenderPipeline,
};
let mut pass = RenderPassInstance::new("example", render_pass);
pass
.set_pipeline(pipeline).unwrap()
.set_vertex_buffer(0, vbo)
.set_index_buffer(ibo)
.draw_indexed(0..36, 0..1)
.unwrap();Supported operations include standard draws, indexed draws, and indirect versions of both. Errors are returned if mandatory state (pipeline, vertex/index buffers) is missing.
Fields§
§label: StringImplementations§
Source§impl<'a> RenderPassInstance<'a>
impl<'a> RenderPassInstance<'a>
Sourcepub fn new(label: &str, render_pass: RenderPass<'a>) -> Self
pub fn new(label: &str, render_pass: RenderPass<'a>) -> Self
Create a new render pass.
§Arguments
label- The label of the render pass.render_pass- The render pass to create.
Sourcepub fn set_pipeline(
&mut self,
pipeline: &'a RenderPipeline,
) -> Result<&mut Self, RenderError>
pub fn set_pipeline( &mut self, pipeline: &'a RenderPipeline, ) -> Result<&mut Self, RenderError>
Sourcepub fn set_vertex_buffer(
&mut self,
binding: u32,
buffer: &'a Buffer,
) -> &mut Self
pub fn set_vertex_buffer( &mut self, binding: u32, buffer: &'a Buffer, ) -> &mut Self
Set a vertex buffer of the render pass.
§Arguments
binding- The binding of the vertex buffer.buffer- The buffer to set.
Sourcepub fn set_index_buffer(&mut self, buffer: &'a Buffer) -> &mut Self
pub fn set_index_buffer(&mut self, buffer: &'a Buffer) -> &mut Self
Sourcepub fn set_scissor_rect(
&mut self,
x: u32,
y: u32,
width: u32,
height: u32,
) -> &mut Self
pub fn set_scissor_rect( &mut self, x: u32, y: u32, width: u32, height: u32, ) -> &mut Self
Set the scissor rect of the render pass.
§Arguments
x- X coordinate of the scissor rect.y- Y coordinate of the scissor rect.width- Width of the scissor rect.height- Height of the scissor rect.
Sourcepub fn set_push_constants(
&mut self,
stages: ShaderStages,
data: &[u8],
) -> &mut Self
pub fn set_push_constants( &mut self, stages: ShaderStages, data: &[u8], ) -> &mut Self
Set push constants of the render pass.
§Arguments
stages- The shader stages to set the push constants for.data- The data to set.
Sourcepub fn set_bind_group(
&mut self,
binding: u32,
bind_group: &'a BindGroup,
) -> &mut Self
pub fn set_bind_group( &mut self, binding: u32, bind_group: &'a BindGroup, ) -> &mut Self
Set a bind group of the render pass at a binding.
§Arguments
binding- The binding of the bind group.bind_group- The bind group to set.
Sourcepub fn draw(
&mut self,
vertices: Range<u32>,
instances: Range<u32>,
) -> Result<(), RenderError>
pub fn draw( &mut self, vertices: Range<u32>, instances: Range<u32>, ) -> Result<(), RenderError>
Sourcepub fn draw_indexed(
&mut self,
indices: Range<u32>,
instance_index: Range<u32>,
) -> Result<(), RenderError>
pub fn draw_indexed( &mut self, indices: Range<u32>, instance_index: Range<u32>, ) -> Result<(), RenderError>
Sourcepub fn multi_draw_indirect(
&mut self,
buffer: &'a Buffer,
offset: BufferAddress,
count: u32,
) -> Result<(), RenderError>
pub fn multi_draw_indirect( &mut self, buffer: &'a Buffer, offset: BufferAddress, count: u32, ) -> Result<(), RenderError>
Draws primitives from the active vertex buffers. The draw is indirect, meaning the draw arguments are read from a buffer.
§Arguments
buffer- The buffer to read the draw arguments from.offset- The first draw argument to read.count- The number of draw arguments to read.
§Errors
RenderError::PipelineNotSet- The pipeline is not set.RenderError::MissingVertexBuffer- The vertex buffer is not set.
Sourcepub fn multi_draw_indexed_indirect(
&mut self,
buffer: &'a Buffer,
offset: BufferAddress,
count: u32,
) -> Result<(), RenderError>
pub fn multi_draw_indexed_indirect( &mut self, buffer: &'a Buffer, offset: BufferAddress, count: u32, ) -> Result<(), RenderError>
Draws primitives from the active vertex buffers as indexed triangles. The draw is indirect, meaning the draw arguments are read from a buffer.
§Arguments
buffer- The buffer to read the draw arguments from.offset- The first draw argument to read.count- The number of draw arguments to read.
§Errors
RenderError::PipelineNotSet- The pipeline is not set.RenderError::MissingVertexBuffer- The vertex buffer is not set.RenderError::MissingIndexBuffer- The index buffer is not set.
Sourcepub fn forget_lifetime(self) -> RenderPassInstance<'static>
pub fn forget_lifetime(self) -> RenderPassInstance<'static>
Forgets the lifetime of the render pass.
This is used to return the inner wgpu::RenderPass when needed.
Sourcepub fn into_inner(self) -> RenderPass<'a>
pub fn into_inner(self) -> RenderPass<'a>
Consumes the render pass and returns the inner wgpu::RenderPass.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for RenderPassInstance<'a>
impl<'a> !RefUnwindSafe for RenderPassInstance<'a>
impl<'a> Send for RenderPassInstance<'a>
impl<'a> Sync for RenderPassInstance<'a>
impl<'a> Unpin for RenderPassInstance<'a>
impl<'a> !UnwindSafe for RenderPassInstance<'a>
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§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