pub struct ShaderKernel<T: Send + Sync> { /* private fields */ }Expand description
A named, parameterised GPU kernel ready for parallel dispatch.
Implementations§
Source§impl<T: Send + Sync> ShaderKernel<T>
impl<T: Send + Sync> ShaderKernel<T>
Sourcepub fn new(
name: impl Into<String>,
group_size: usize,
f: impl Fn(&ThreadGroupContext, &mut T) + Send + Sync + 'static,
) -> Self
pub fn new( name: impl Into<String>, group_size: usize, f: impl Fn(&ThreadGroupContext, &mut T) + Send + Sync + 'static, ) -> Self
Create a new kernel with an explicit group size.
§Panics
Does not panic; group_size = 0 is normalised to 1 at runtime.
Sourcepub fn execute(&self, data: &mut [T], work_groups: usize)
pub fn execute(&self, data: &mut [T], work_groups: usize)
Execute the kernel over data using work_groups groups in parallel.
Elements at indices >= work_groups * group_size are silently ignored,
matching GPU semantics where excess invocations are masked out.
Sourcepub fn group_size(&self) -> usize
pub fn group_size(&self) -> usize
The number of threads per work group.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ShaderKernel<T>
impl<T> !UnwindSafe for ShaderKernel<T>
impl<T> Freeze for ShaderKernel<T>
impl<T> Send for ShaderKernel<T>
impl<T> Sync for ShaderKernel<T>
impl<T> Unpin for ShaderKernel<T>
impl<T> UnsafeUnpin for ShaderKernel<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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