pub struct ComputeShaderSimulator { /* private fields */ }Expand description
High-level entry point for simulated GPU compute.
Manages a default group size and provides factory methods for creating
typed ShaderKernel instances.
Implementations§
Source§impl ComputeShaderSimulator
impl ComputeShaderSimulator
Sourcepub fn new(default_group_size: usize) -> Self
pub fn new(default_group_size: usize) -> Self
Create a simulator with the given default work-group size.
Sizes of 0 are normalised to 64 (a common GPU default).
Sourcepub fn default_group_size(&self) -> usize
pub fn default_group_size(&self) -> usize
The default number of threads per work group.
Sourcepub fn create_kernel<T: Send + Sync + 'static>(
&self,
name: impl Into<String>,
f: impl Fn(&ThreadGroupContext, &mut T) + Send + Sync + 'static,
) -> ShaderKernel<T>
pub fn create_kernel<T: Send + Sync + 'static>( &self, name: impl Into<String>, f: impl Fn(&ThreadGroupContext, &mut T) + Send + Sync + 'static, ) -> ShaderKernel<T>
Create a kernel using the simulator’s default group size.
Sourcepub fn create_kernel_with_group_size<T: Send + Sync + 'static>(
&self,
name: impl Into<String>,
group_size: usize,
f: impl Fn(&ThreadGroupContext, &mut T) + Send + Sync + 'static,
) -> ShaderKernel<T>
pub fn create_kernel_with_group_size<T: Send + Sync + 'static>( &self, name: impl Into<String>, group_size: usize, f: impl Fn(&ThreadGroupContext, &mut T) + Send + Sync + 'static, ) -> ShaderKernel<T>
Create a kernel with a custom group size, ignoring the simulator default.
Sourcepub fn dispatch<T: Send + Sync>(
&self,
kernel: &ShaderKernel<T>,
data: &mut [T],
work_groups: usize,
)
pub fn dispatch<T: Send + Sync>( &self, kernel: &ShaderKernel<T>, data: &mut [T], work_groups: usize, )
Dispatch kernel over data using work_groups work groups.
Sourcepub fn dispatch_with_barrier<T: Send + Sync + Clone>(
&self,
kernel: &ShaderKernel<T>,
data: &mut [T],
work_groups: usize,
)
pub fn dispatch_with_barrier<T: Send + Sync + Clone>( &self, kernel: &ShaderKernel<T>, data: &mut [T], work_groups: usize, )
Dispatch kernel and wait for all threads to complete.
Rayon’s par_iter_mut already joins all threads before returning, so
this is semantically equivalent to dispatch. The method exists to
model GPU barriers explicitly in calling code.
Trait Implementations§
Source§impl Clone for ComputeShaderSimulator
impl Clone for ComputeShaderSimulator
Source§fn clone(&self) -> ComputeShaderSimulator
fn clone(&self) -> ComputeShaderSimulator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ComputeShaderSimulator
impl RefUnwindSafe for ComputeShaderSimulator
impl Send for ComputeShaderSimulator
impl Sync for ComputeShaderSimulator
impl Unpin for ComputeShaderSimulator
impl UnsafeUnpin for ComputeShaderSimulator
impl UnwindSafe for ComputeShaderSimulator
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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