pub struct RenderPipeline {
pub label: String,
/* private fields */
}Expand description
Stores a render pipeline.
§Example
use wde_wgpu::render_pipeline::{DepthStencilDescriptor, RenderPipeline, RenderTopology, ShaderStages};
let mut pipeline = RenderPipeline::new("gbuffer");
pipeline
.set_shader(include_str!("../../../res/pbr/gbuffer_vert.wgsl"), ShaderStages::VERTEX)
.set_shader(include_str!("../../../res/pbr/gbuffer_frag.wgsl"), ShaderStages::FRAGMENT)
.set_topology(RenderTopology::TriangleList)
.set_depth(DepthStencilDescriptor { enabled: true, write: true, compare: wgpu::CompareFunction::Less })
.set_bind_groups(layouts)
.add_push_constant(ShaderStages::VERTEX, 0, 64)
.init(instance)
.expect("shaders validated");
assert!(pipeline.is_initialized());
let _wgpu_pipeline = pipeline.get_pipeline().unwrap();Fields§
§label: StringImplementations§
Source§impl RenderPipeline
impl RenderPipeline
Sourcepub fn new(label: &str) -> Self
pub fn new(label: &str) -> Self
Create a new render pipeline.
By default, the render pipeline does not have a depth or stencil.
By default, the primitive topology is Topology::TriangleList.
By default, the cull mode is Some(Face::Back).
By default, the sample count is 1.
By default, this pipeline expects a vertex buffer to be used.
§Arguments
label- Label of the render pipeline for debugging.
Sourcepub fn set_shader(
&mut self,
shader: &str,
shader_type: ShaderStages,
) -> &mut Self
pub fn set_shader( &mut self, shader: &str, shader_type: ShaderStages, ) -> &mut Self
Sourcepub fn set_topology(&mut self, topology: RenderTopology) -> &mut Self
pub fn set_topology(&mut self, topology: RenderTopology) -> &mut Self
Sourcepub fn set_depth(&mut self, depth: DepthDescriptor) -> &mut Self
pub fn set_depth(&mut self, depth: DepthDescriptor) -> &mut Self
Set the configuration of the depth/stencil attachment.
Sourcepub fn set_cull_mode(&mut self, cull_mode: Option<Face>) -> &mut Self
pub fn set_cull_mode(&mut self, cull_mode: Option<Face>) -> &mut Self
Set the cull mode. None means no culling.
Sourcepub fn set_bind_groups(&mut self, layout: Vec<BindGroupLayout>) -> &mut Self
pub fn set_bind_groups(&mut self, layout: Vec<BindGroupLayout>) -> &mut Self
Add a set of bind groups via its layout to the render pipeline. Note that the order of the bind groups will be the same as the order of the bindings in the shaders.
§Arguments
layout- The bind group layout.
Sourcepub fn set_render_targets(&mut self, targets: Vec<TextureFormat>) -> &mut Self
pub fn set_render_targets(&mut self, targets: Vec<TextureFormat>) -> &mut Self
Sourcepub fn set_sample_count(&mut self, count: u32) -> &mut Self
pub fn set_sample_count(&mut self, count: u32) -> &mut Self
Sourcepub fn set_use_vertices_buffer(&mut self, use_buffer: bool) -> &mut Self
pub fn set_use_vertices_buffer(&mut self, use_buffer: bool) -> &mut Self
Set whether the pipeline uses a vertex buffer.
§Arguments
use_buffer- Whether to use a vertex buffer.
Sourcepub fn set_fragment_blend(&mut self, blend: Option<BlendState>) -> &mut Self
pub fn set_fragment_blend(&mut self, blend: Option<BlendState>) -> &mut Self
Sourcepub fn add_push_constant(
&mut self,
stages: ShaderStages,
offset: u32,
size: u32,
)
pub fn add_push_constant( &mut self, stages: ShaderStages, offset: u32, size: u32, )
Add a push constant to the render pipeline.
§Arguments
stages- The shader stages.offset- The offset of the push constant.size- The size of the push constant.
Sourcepub fn init(
&mut self,
instance: &RenderInstanceData<'_>,
) -> Result<(), RenderError>
pub fn init( &mut self, instance: &RenderInstanceData<'_>, ) -> Result<(), RenderError>
Sourcepub fn get_pipeline(&self) -> Option<&RenderPipeline>
pub fn get_pipeline(&self) -> Option<&RenderPipeline>
Sourcepub fn get_layout(&self) -> Option<&PipelineLayout>
pub fn get_layout(&self) -> Option<&PipelineLayout>
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the render pipeline is initialized.
§Returns
bool- True if the render pipeline is initialized, false otherwise.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RenderPipeline
impl !RefUnwindSafe for RenderPipeline
impl Send for RenderPipeline
impl Sync for RenderPipeline
impl Unpin for RenderPipeline
impl !UnwindSafe for RenderPipeline
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
Mutably borrows from an owned value. Read more
§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>
Converts
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>
Converts
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)
Converts
&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)
Converts
&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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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>
Converts
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>
Converts
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§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.