pub enum BindingKind {
Texture {
visibility: ShaderStages,
sample_type: TextureSampleType,
view_dimension: TextureViewDimension,
multisampled: bool,
},
StorageTexture {
visibility: ShaderStages,
format: TextureFormat,
access: StorageTextureAccess,
view_dimension: TextureViewDimension,
},
Sampler {
visibility: ShaderStages,
},
ComparisonSampler {
visibility: ShaderStages,
},
UniformBuffer {
visibility: ShaderStages,
has_dynamic_offset: bool,
min_binding_size: Option<BufferSize>,
},
StorageBufferReadOnly {
visibility: ShaderStages,
has_dynamic_offset: bool,
min_binding_size: Option<BufferSize>,
},
StorageBufferReadWrite {
visibility: ShaderStages,
has_dynamic_offset: bool,
min_binding_size: Option<BufferSize>,
},
}Expand description
What kind of resource a single BindingEntry binds, the wgpu binding
parameters that go with it, and which shader stage(s) can see it.
Construct via the texture_*/*_buffer/sampler/storage_texture
associated functions rather than the variants directly — they fill in
the usual defaults (filterable float textures, non-dynamic buffers) so
only the cases that actually differ need spelling out.
Variants§
Texture
A sampled texture (texture_2d<f32> and friends in WGSL).
StorageTexture
A texture bound for direct read/write access (textureStore/
textureLoad in WGSL) rather than sampling.
Fields
visibility: ShaderStagesformat: TextureFormataccess: StorageTextureAccessview_dimension: TextureViewDimensionSampler
A filtering sampler.
Fields
visibility: ShaderStagesComparisonSampler
A comparison sampler (e.g. for shadow-map textureSampleCompare).
Fields
visibility: ShaderStagesUniformBuffer
A uniform buffer.
StorageBufferReadOnly
A read-only storage buffer.
StorageBufferReadWrite
A read-write storage buffer.
Implementations§
Source§impl BindingKind
impl BindingKind
Sourcepub fn texture_2d(visibility: ShaderStages) -> Self
pub fn texture_2d(visibility: ShaderStages) -> Self
A filterable, non-multisampled 2D texture — the common case.
Sourcepub fn texture_2d_array(visibility: ShaderStages) -> Self
pub fn texture_2d_array(visibility: ShaderStages) -> Self
Same as texture_2d but for a 2D texture array
(see GPUTextureArray).
Sourcepub fn texture_cubemap(visibility: ShaderStages) -> Self
pub fn texture_cubemap(visibility: ShaderStages) -> Self
Same as texture_2d but for a cubemap (see
GPUCubemap).
Sourcepub fn storage_texture(
visibility: ShaderStages,
format: TextureFormat,
access: StorageTextureAccess,
view_dimension: TextureViewDimension,
) -> Self
pub fn storage_texture( visibility: ShaderStages, format: TextureFormat, access: StorageTextureAccess, view_dimension: TextureViewDimension, ) -> Self
A storage texture bound for direct read/write/read-write access
(per access) rather than sampling.
Sourcepub fn sampler(visibility: ShaderStages) -> Self
pub fn sampler(visibility: ShaderStages) -> Self
A filtering sampler.
Sourcepub fn comparison_sampler(visibility: ShaderStages) -> Self
pub fn comparison_sampler(visibility: ShaderStages) -> Self
A comparison sampler (e.g. for shadow-map textureSampleCompare).
Sourcepub fn uniform_buffer(visibility: ShaderStages) -> Self
pub fn uniform_buffer(visibility: ShaderStages) -> Self
A uniform buffer, bound as a whole (no dynamic offset) — the common
case. See dynamic_uniform_buffer
for the per-draw/per-dispatch-offset variant.
Sourcepub fn dynamic_uniform_buffer(
visibility: ShaderStages,
element_size: u64,
) -> Self
pub fn dynamic_uniform_buffer( visibility: ShaderStages, element_size: u64, ) -> Self
A uniform buffer bound with a dynamic offset, e.g. one large buffer
holding many objects’/elements’ data, rebound at a different offset
via set_bind_group’s dynamic offsets slice instead of a bind group
per object/dispatch. element_size is the size in bytes of a single
element (before alignment padding). Use
crate::wgpu::buffers::build_dynamic_uniform_buffer to allocate
the backing buffer and crate::wgpu::buffers::dynamic_buffer_binding
(not buffer.as_entire_binding()) to build the bind group entry for
it — the entry must be scoped to one element’s size, not the whole
buffer, or dynamic offsets will fail validation.
Sourcepub fn storage_buffer_read_only(visibility: ShaderStages) -> Self
pub fn storage_buffer_read_only(visibility: ShaderStages) -> Self
A read-only storage buffer, bound as a whole (no dynamic offset).
Sourcepub fn storage_buffer_read_write(visibility: ShaderStages) -> Self
pub fn storage_buffer_read_write(visibility: ShaderStages) -> Self
A read-write storage buffer, bound as a whole (no dynamic offset).
Sourcepub fn dynamic_storage_buffer(
visibility: ShaderStages,
element_size: u64,
read_only: bool,
) -> Self
pub fn dynamic_storage_buffer( visibility: ShaderStages, element_size: u64, read_only: bool, ) -> Self
A storage buffer bound with a dynamic offset. See
Self::dynamic_uniform_buffer.
Sourcepub fn visibility(&self) -> ShaderStages
pub fn visibility(&self) -> ShaderStages
Which shader stage(s) this binding is visible to.
pub fn layout_entry(&self, binding: u32) -> BindGroupLayoutEntry
Trait Implementations§
Source§impl Clone for BindingKind
impl Clone for BindingKind
Source§fn clone(&self) -> BindingKind
fn clone(&self) -> BindingKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for BindingKind
impl Eq for BindingKind
Source§impl Hash for BindingKind
impl Hash for BindingKind
Source§impl PartialEq for BindingKind
impl PartialEq for BindingKind
impl StructuralPartialEq for BindingKind
Auto Trait Implementations§
impl Freeze for BindingKind
impl RefUnwindSafe for BindingKind
impl Send for BindingKind
impl Sync for BindingKind
impl Unpin for BindingKind
impl UnsafeUnpin for BindingKind
impl UnwindSafe for BindingKind
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> 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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