pub struct ComputePass<'f> { /* private fields */ }Expand description
A compute pass wrapper that automatically returns the command buffer to the frame.
This struct mirrors RenderPass in its lifecycle management - it owns its
encoder and pushes the command buffer to the frame when dropped.
Implementations§
Source§impl<'f> ComputePass<'f>
impl<'f> ComputePass<'f>
Sourcepub fn wgpu_pass(&mut self) -> &mut ComputePass<'static>
pub fn wgpu_pass(&mut self) -> &mut ComputePass<'static>
Get the underlying wgpu compute pass (mutable).
Sourcepub fn wgpu_pass_ref(&self) -> &ComputePass<'static>
pub fn wgpu_pass_ref(&self) -> &ComputePass<'static>
Get the underlying wgpu compute pass (immutable).
Sourcepub fn raw_pass(&mut self) -> &mut ComputePass<'static>
pub fn raw_pass(&mut self) -> &mut ComputePass<'static>
Get raw access to the underlying wgpu compute pass.
This is an alias for wgpu_pass() for consistency with RenderPass::raw_pass().
Sourcepub fn graphics(&self) -> &GraphicsContext
pub fn graphics(&self) -> &GraphicsContext
Get the graphics context.
Sourcepub fn set_pipeline(&mut self, pipeline: &ComputePipeline)
pub fn set_pipeline(&mut self, pipeline: &ComputePipeline)
Set the compute pipeline to use.
Sourcepub fn set_bind_group(
&mut self,
index: u32,
bind_group: &BindGroup,
offsets: &[u32],
)
pub fn set_bind_group( &mut self, index: u32, bind_group: &BindGroup, offsets: &[u32], )
Set a bind group.
Sourcepub fn dispatch_workgroups(&mut self, x: u32, y: u32, z: u32)
pub fn dispatch_workgroups(&mut self, x: u32, y: u32, z: u32)
Dispatch workgroups.
§Arguments
x- Number of workgroups in the X dimensiony- Number of workgroups in the Y dimensionz- Number of workgroups in the Z dimension
Sourcepub fn dispatch_workgroups_1d(&mut self, x: u32)
pub fn dispatch_workgroups_1d(&mut self, x: u32)
Dispatch workgroups with a 1D configuration.
Equivalent to dispatch_workgroups(x, 1, 1).
Sourcepub fn dispatch_workgroups_2d(&mut self, x: u32, y: u32)
pub fn dispatch_workgroups_2d(&mut self, x: u32, y: u32)
Dispatch workgroups with a 2D configuration.
Equivalent to dispatch_workgroups(x, y, 1).
Sourcepub fn dispatch_workgroups_indirect(&mut self, buffer: &Buffer, offset: u64)
pub fn dispatch_workgroups_indirect(&mut self, buffer: &Buffer, offset: u64)
Dispatch workgroups indirectly from a buffer.
The buffer should contain a DispatchIndirect struct:
#[repr(C)]
struct DispatchIndirect {
x: u32,
y: u32,
z: u32,
}Sourcepub fn insert_debug_marker(&mut self, label: &str)
pub fn insert_debug_marker(&mut self, label: &str)
Insert a debug marker.
Sourcepub fn push_debug_group(&mut self, label: &str)
pub fn push_debug_group(&mut self, label: &str)
Push a debug group.
Sourcepub fn pop_debug_group(&mut self)
pub fn pop_debug_group(&mut self)
Pop a debug group.
Sourcepub fn set_push_constants<T: Pod>(&mut self, offset: u32, data: &T)
pub fn set_push_constants<T: Pod>(&mut self, offset: u32, data: &T)
Set push constants for the compute shader.
Push constants are a fast way to pass small amounts of data to shaders
without using uniform buffers. They require the PUSH_CONSTANTS feature
to be enabled on the device.
§Arguments
offset- Byte offset into the push constant rangedata- Data to set (must bePodfor safe byte casting)
§Example
#[repr(C)]
#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
struct ComputeConstants {
workgroup_count: u32,
time: f32,
}
let constants = ComputeConstants {
workgroup_count: 64,
time: 1.5,
};
pass.set_push_constants(0, &constants);Sourcepub fn set_push_constants_raw(&mut self, offset: u32, data: &[u8])
pub fn set_push_constants_raw(&mut self, offset: u32, data: &[u8])
Set push constants from raw bytes.
Use this when you need more control over the data layout.
Trait Implementations§
Source§impl<'a> AsWgpu for ComputePass<'a>
impl<'a> AsWgpu for ComputePass<'a>
Source§impl<'a> AsWgpuMut for ComputePass<'a>
impl<'a> AsWgpuMut for ComputePass<'a>
Source§fn as_wgpu_mut(&mut self) -> &mut Self::WgpuType
fn as_wgpu_mut(&mut self) -> &mut Self::WgpuType
Auto Trait Implementations§
impl<'f> Freeze for ComputePass<'f>
impl<'f> !RefUnwindSafe for ComputePass<'f>
impl<'f> !Send for ComputePass<'f>
impl<'f> !Sync for ComputePass<'f>
impl<'f> Unpin for ComputePass<'f>
impl<'f> UnsafeUnpin for ComputePass<'f>
impl<'f> !UnwindSafe for ComputePass<'f>
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
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> 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