pub struct BindGroupBuilder<'a> { /* private fields */ }Expand description
Builds a wgpu::BindGroup against layout one binding at a time.
The plain methods (buffer, texture,
sampler, dynamic_buffer)
assign @binding(N) in call order, starting at 0 — the common case,
matching a layout whose entries are numbered the same way. If your
target’s bindings aren’t contiguous from 0 (e.g. looked up by name
against a BindGroupTarget, as
GPUBindingInstance does), use
the _at variants to assign an explicit @binding(N) instead.
let bind_group = BindGroupBuilder::new(&layout)
.label("camera_bind_group")
.buffer(&camera_buffer)
.build(&device);Implementations§
Source§impl<'a> BindGroupBuilder<'a>
impl<'a> BindGroupBuilder<'a>
pub fn new(layout: &'a BindGroupLayout) -> Self
pub fn label(self, label: impl Into<Option<&'a str>>) -> Self
Sourcepub fn buffer(self, buffer: &'a Buffer) -> Self
pub fn buffer(self, buffer: &'a Buffer) -> Self
Binds buffer in its entirety at the next @binding(N) (call order,
starting at 0).
Sourcepub fn buffer_at(self, binding: u32, buffer: &'a Buffer) -> Self
pub fn buffer_at(self, binding: u32, buffer: &'a Buffer) -> Self
Same as buffer but at an explicit @binding(N).
Sourcepub fn dynamic_buffer(self, buffer: &'a Buffer, element_size: u64) -> Self
pub fn dynamic_buffer(self, buffer: &'a Buffer, element_size: u64) -> Self
Binds buffer scoped to one element_size-sized element — not the
whole buffer, since the dynamic offset passed to set_bind_group at
draw/dispatch time is added on top of this base range, and wgpu
validates offset + size <= buffer size — at the next @binding(N),
for a buffer built by DynamicBufferBuilder.
Sourcepub fn dynamic_buffer_at(
self,
binding: u32,
buffer: &'a Buffer,
element_size: u64,
) -> Self
pub fn dynamic_buffer_at( self, binding: u32, buffer: &'a Buffer, element_size: u64, ) -> Self
Same as dynamic_buffer but at an explicit @binding(N).
Sourcepub fn texture(self, view: &'a TextureView) -> Self
pub fn texture(self, view: &'a TextureView) -> Self
Binds view at the next @binding(N).
Sourcepub fn texture_at(self, binding: u32, view: &'a TextureView) -> Self
pub fn texture_at(self, binding: u32, view: &'a TextureView) -> Self
Same as texture but at an explicit @binding(N).
Sourcepub fn sampler_at(self, binding: u32, sampler: &'a Sampler) -> Self
pub fn sampler_at(self, binding: u32, sampler: &'a Sampler) -> Self
Same as sampler but at an explicit @binding(N).
pub fn build(self, device: &Device) -> BindGroup
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for BindGroupBuilder<'a>
impl<'a> !UnwindSafe for BindGroupBuilder<'a>
impl<'a> Freeze for BindGroupBuilder<'a>
impl<'a> Send for BindGroupBuilder<'a>
impl<'a> Sync for BindGroupBuilder<'a>
impl<'a> Unpin for BindGroupBuilder<'a>
impl<'a> UnsafeUnpin for BindGroupBuilder<'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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Component for T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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