pub struct ComputeContext {
pub backend_type: GpuBackend,
/* private fields */
}Expand description
High-level compute context wrapping a backend.
Fields§
§backend_type: GpuBackendImplementations§
Source§impl ComputeContext
impl ComputeContext
pub fn new(backend: Box<dyn BackendContext>, backend_type: GpuBackend) -> Self
Sourcepub fn create_storage_buffer<T: Copy>(&mut self, data: &[T]) -> ComputeBuffer
pub fn create_storage_buffer<T: Copy>(&mut self, data: &[T]) -> ComputeBuffer
Create a typed storage buffer from a slice, copying element data.
Sourcepub fn create_empty_buffer<T>(&mut self, count: usize) -> ComputeBuffer
pub fn create_empty_buffer<T>(&mut self, count: usize) -> ComputeBuffer
Create an empty storage buffer with room for count elements of type T.
Sourcepub fn create_pipeline(
&mut self,
source: &str,
layout: BindGroupLayout,
workgroup_size: [u32; 3],
) -> ComputePipeline
pub fn create_pipeline( &mut self, source: &str, layout: BindGroupLayout, workgroup_size: [u32; 3], ) -> ComputePipeline
Create a compute pipeline.
Sourcepub fn dispatch(&mut self, pipeline: &ComputePipeline, x: u32, y: u32, z: u32)
pub fn dispatch(&mut self, pipeline: &ComputePipeline, x: u32, y: u32, z: u32)
Dispatch a compute pipeline.
Sourcepub fn indirect_dispatch(
&mut self,
pipeline: &ComputePipeline,
args_buffer: &ComputeBuffer,
)
pub fn indirect_dispatch( &mut self, pipeline: &ComputePipeline, args_buffer: &ComputeBuffer, )
Indirect dispatch: the workgroup counts come from a GPU buffer.
Sourcepub fn memory_barrier(&mut self)
pub fn memory_barrier(&mut self)
Insert a memory barrier.
Sourcepub fn read_back<T: Copy + Default>(&self, buffer: &ComputeBuffer) -> Vec<T>
pub fn read_back<T: Copy + Default>(&self, buffer: &ComputeBuffer) -> Vec<T>
Read back buffer contents as a typed slice.
Sourcepub fn write_buffer<T: Copy>(&mut self, buffer: &ComputeBuffer, data: &[T])
pub fn write_buffer<T: Copy>(&mut self, buffer: &ComputeBuffer, data: &[T])
Write typed data into an existing buffer.
Sourcepub fn profiler(&self) -> &ComputeProfiler
pub fn profiler(&self) -> &ComputeProfiler
Get the profiler.
Sourcepub fn profiler_mut(&mut self) -> &mut ComputeProfiler
pub fn profiler_mut(&mut self) -> &mut ComputeProfiler
Mutable access to the profiler.
Sourcepub fn supports_compute(&self) -> bool
pub fn supports_compute(&self) -> bool
Whether the backend supports compute shaders natively.
Sourcepub fn destroy_buffer(&mut self, buffer: &ComputeBuffer)
pub fn destroy_buffer(&mut self, buffer: &ComputeBuffer)
Destroy a compute buffer.
Auto Trait Implementations§
impl Freeze for ComputeContext
impl !RefUnwindSafe for ComputeContext
impl Send for ComputeContext
impl Sync for ComputeContext
impl Unpin for ComputeContext
impl UnsafeUnpin for ComputeContext
impl !UnwindSafe for ComputeContext
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
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>
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.Source§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.Source§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.Source§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.