Skip to main content

Kernel

Struct Kernel 

Source
pub struct Kernel { /* private fields */ }
Expand description

A compiled extension compute kernel on one runtime’s device.

Compile cost is paid once at construction; identical SPIR-V on the same device reuses the cached pipeline. The kernel may be dispatched any number of times via Runtime::dispatch_kernel. It is not part of the semantic graph or fusion system: dispatches record as physical nodes with the caller-declared binding accesses.

Implementations§

Source§

impl Kernel

Source

pub fn compile( runtime: &Runtime, name: &'static str, spirv: &[u8], bindings: u32, workgroup_size: [u32; 3], ) -> Result<Self>

Compile SPIR-V bytes into a dispatchable extension kernel.

spirv is the little-endian SPIR-V byte stream, exactly as produced by slangc/glslc or embedded via the include_bytes! macro.

bindings is the number of storage-buffer slots the kernel declares; those leading push-constant words are reserved for descriptor indices and supplied automatically at dispatch. The remaining reflected push-constant words are the caller’s push surface — validated against the actual SPIR-V at compile time.

workgroup_size must match the shader’s local_size declaration; it is validated against device limits here and again per dispatch.

§Errors

Returns an error when the bytes are not valid compute SPIR-V, when the reflected push-constant range is smaller than bindings words, when workgroup_size exceeds device limits, or when pipeline creation fails.

Source

pub const fn push_words(&self) -> usize

The kernel’s caller push-constant surface in four-byte words.

Runtime::dispatch_kernel requires exactly this many KernelPush entries.

Source

pub const fn binding_count(&self) -> usize

The kernel’s declared storage-binding count.

Auto Trait Implementations§

§

impl Forget for Kernel

§

impl Freeze for Kernel
where &'static str: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<Device> is !null: Freeze, PhantomData<ArcInner<Device>>: Freeze,

§

impl Move for Kernel

§

impl RefUnwindSafe for Kernel
where Atomic<usize>: RefUnwindSafe, Mutex<TransferableAllocator<'static>>: RefUnwindSafe, Condvar: RefUnwindSafe, Mutex<CommandPool>: RefUnwindSafe, Mutex<Option<CommandPool>>: RefUnwindSafe, Atomic<u64>: RefUnwindSafe, Mutex<Vec<u32>>: RefUnwindSafe, Mutex<StoragePool>: RefUnwindSafe, OnceLock<ComputePipeline>: RefUnwindSafe, Mutex<PipelineCreation>: RefUnwindSafe, Mutex<JitFusion>: RefUnwindSafe, Mutex<HashMap<Vec<u8>, Arc<ComputePipeline>>>: RefUnwindSafe,

§

impl Send for Kernel
where &'static str: Send, RawVecInner: Send, Arc<Device>: Send,

§

impl Sync for Kernel
where RawVecInner: Sync, Arc<Device>: Sync,

§

impl Unpin for Kernel
where &'static str: Unpin, *const u8 is !null: Unpin, Arc<Device>: Unpin,

§

impl UnsafeUnpin for Kernel
where &'static str: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<Device> is !null: UnsafeUnpin, PhantomData<ArcInner<Device>>: UnsafeUnpin,

§

impl UnwindSafe for Kernel
where &'static str: UnwindSafe, RawVecInner: UnwindSafe, Arc<Device>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.