pub struct Compute { /* private fields */ }Expand description
A compute pipeline asset, plus the bind group values (buffers/textures)
it dispatches with — WGSL shader source and its bind group layout
compile into a wgpu::ComputePipeline; many Computes sharing the same
shader automatically share one compiled pipeline (see
ComputePipelineCache). Dispatch it via
Backend::dispatch_compute.
Implementations§
Source§impl Compute
impl Compute
pub fn new(shader_source: &'static str) -> Self
pub fn with_label(self, label: &'static str) -> Self
pub fn with_entry_point(self, entry: &'static str) -> Self
Sourcepub fn with_entry(self, name: &'static str, kind: BindingKind) -> Self
pub fn with_entry(self, name: &'static str, kind: BindingKind) -> Self
Declares one of this pass’s own (group 0) bind group entries, at the
next auto-assigned binding index — the low-level counterpart to the
streamlined .texture(...)/.buffer(...)/etc. calls, for a kind
one of those doesn’t produce (a dynamic-offset buffer, a non-default
sample type). Pair it with the matching value-only .with_texture(...)/etc.
Sourcepub fn with_entry_at(
self,
name: &'static str,
binding: u32,
kind: BindingKind,
) -> Self
pub fn with_entry_at( self, name: &'static str, binding: u32, kind: BindingKind, ) -> Self
Same as with_entry, pinning an explicit
binding index instead of auto-assigning the next one.
Sourcepub fn with_extra_group(self, group: GroupEntry) -> Self
pub fn with_extra_group(self, group: GroupEntry) -> Self
Appends a bind group beyond this pass’s own (group 0) — typically
GroupEntry::Global, a layout shared with other materials/computes
via GlobalLayoutPool. Groups append in call order, starting at
group 1.
Sourcepub fn with_texture(self, name: &'static str, handle: Handle<Texture>) -> Self
pub fn with_texture(self, name: &'static str, handle: Handle<Texture>) -> Self
Value-only counterpart to .texture(...) — see texture.
Sourcepub fn with_texture_array(
self,
name: &'static str,
handle: Handle<TextureArray>,
) -> Self
pub fn with_texture_array( self, name: &'static str, handle: Handle<TextureArray>, ) -> Self
Value-only counterpart to .texture_array(...) — see texture.
Sourcepub fn with_cubemap(self, name: &'static str, handle: Handle<Cubemap>) -> Self
pub fn with_cubemap(self, name: &'static str, handle: Handle<Cubemap>) -> Self
Value-only counterpart to .cubemap(...) — see texture.
Sourcepub fn with_texture_view(self, name: &'static str, view: TextureView) -> Self
pub fn with_texture_view(self, name: &'static str, view: TextureView) -> Self
Binds an already-built TextureView directly — e.g. one mip level
from GPUTexture::get_view,
or a standalone render target from
Texture::empty. Unlike
.with_texture/.with_texture_array/.with_cubemap, no Handle
lookup happens at upload time — view must already exist.
Sourcepub fn with_sampler(self, name: &'static str, kind: SamplerKind) -> Self
pub fn with_sampler(self, name: &'static str, kind: SamplerKind) -> Self
Value-only counterpart to .sampler(...) — see texture.
Sourcepub fn with_uniform(self, name: &'static str, data: Vec<u8>) -> Self
pub fn with_uniform(self, name: &'static str, data: Vec<u8>) -> Self
Value-only counterpart to .uniform(...) — see texture.
Sourcepub fn with_storage(self, name: &'static str, data: Vec<u8>) -> Self
pub fn with_storage(self, name: &'static str, data: Vec<u8>) -> Self
Value-only counterpart to .storage(...) — see texture.
Sourcepub fn with_uniform_value<T>(self, name: &'static str, value: &T) -> Selfwhere
T: ShaderType + WriteInto,
pub fn with_uniform_value<T>(self, name: &'static str, value: &T) -> Selfwhere
T: ShaderType + WriteInto,
Same as with_uniform, but takes a typed
value instead of pre-packed bytes — uses encase to lay it out with
correct WGSL uniform (std140) alignment. Value-only counterpart to
.uniform_value(...).
Sourcepub fn with_storage_value<T>(self, name: &'static str, value: &T) -> Selfwhere
T: ShaderType + WriteInto,
pub fn with_storage_value<T>(self, name: &'static str, value: &T) -> Selfwhere
T: ShaderType + WriteInto,
Same as with_storage, but takes a typed
value instead of pre-packed bytes — uses encase to lay it out with
correct WGSL storage (std430) alignment. Value-only counterpart to
.storage_value(...).
Sourcepub fn texture(self, name: &'static str, handle: Handle<Texture>) -> Self
pub fn texture(self, name: &'static str, handle: Handle<Texture>) -> Self
Declares a compute-visible texture_2d<f32> entry at the next
auto-assigned binding index and binds handle to it — the
streamlined one-call form of .with_entry(name, BindingKind::texture_2d(COMPUTE))
followed by .with_texture(name, handle). Reach for those two
directly for a non-default sample type or an explicit binding index
— visibility is always COMPUTE for a compute pass, so there’s no
visibility to override here.
Sourcepub fn texture_array(
self,
name: &'static str,
handle: Handle<TextureArray>,
) -> Self
pub fn texture_array( self, name: &'static str, handle: Handle<TextureArray>, ) -> Self
Streamlined form of .texture_array(...) — see texture.
Sourcepub fn cubemap(self, name: &'static str, handle: Handle<Cubemap>) -> Self
pub fn cubemap(self, name: &'static str, handle: Handle<Cubemap>) -> Self
Streamlined form of .cubemap(...) — see texture.
Sourcepub fn sampler(self, name: &'static str, kind: SamplerKind) -> Self
pub fn sampler(self, name: &'static str, kind: SamplerKind) -> Self
Streamlined form of .sampler(...) — see texture.
Sourcepub fn uniform(self, name: &'static str, data: Vec<u8>) -> Self
pub fn uniform(self, name: &'static str, data: Vec<u8>) -> Self
Streamlined form of .uniform(...) — see texture.
Sourcepub fn storage(self, name: &'static str, data: Vec<u8>) -> Self
pub fn storage(self, name: &'static str, data: Vec<u8>) -> Self
Streamlined form of .storage(...) (read-write — a compute pass
binding a storage buffer usually means to write it) — see
texture. Use .with_entry(...) +
.with_storage(...) directly for a read-only one.
Sourcepub fn uniform_value<T>(self, name: &'static str, value: &T) -> Selfwhere
T: ShaderType + WriteInto,
pub fn uniform_value<T>(self, name: &'static str, value: &T) -> Selfwhere
T: ShaderType + WriteInto,
Streamlined, typed form of .uniform(...) — declares the entry and
binds an encase-laid-out value in one call. See texture.
Sourcepub fn storage_value<T>(self, name: &'static str, value: &T) -> Selfwhere
T: ShaderType + WriteInto,
pub fn storage_value<T>(self, name: &'static str, value: &T) -> Selfwhere
T: ShaderType + WriteInto,
Streamlined, typed form of .storage(...) (read-write) — see
storage.
Sourcepub fn with_buffer(self, name: &'static str, buffer: Buffer) -> Self
pub fn with_buffer(self, name: &'static str, buffer: Buffer) -> Self
Binds an existing Buffer instead of uploading raw bytes — for a
buffer another pass already wrote to. Unlike .with_uniform/
.with_storage, no buffer is created here; buffer must already
carry the usage flags this binding needs.
Sourcepub fn with_dynamic_buffer(
self,
name: &'static str,
buffer: DynamicBuffer,
) -> Self
pub fn with_dynamic_buffer( self, name: &'static str, buffer: DynamicBuffer, ) -> Self
Binds an existing DynamicBuffer — the dynamic-offset counterpart
to .with_buffer.
pub fn with_param(self, name: &'static str, entry: BindingValue) -> Self
pub fn build_asset( self, name: &str, assets: &mut Assets<Compute>, ) -> Handle<Compute>
Trait Implementations§
Source§impl Asset<Backend> for Compute
impl Asset<Backend> for Compute
type Deps<'a> = (Read<'a, GlobalLayoutPool>, Read<'a, ComputePipelineCache>, Read<'a, Assets<Texture>>, Read<'a, Assets<TextureArray>>, Read<'a, Assets<Cubemap>>, Read<'a, GlobalSamplers>)
fn upload<'a>( &self, backend: &Backend, deps: &Self::Deps<'a>, ) -> Option<GPUCompute>
Source§impl AssetSource for Compute
impl AssetSource for Compute
type Processed = GPUCompute
Auto Trait Implementations§
impl !RefUnwindSafe for Compute
impl !UnwindSafe for Compute
impl Freeze for Compute
impl Send for Compute
impl Sync for Compute
impl Unpin for Compute
impl UnsafeUnpin for Compute
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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().