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
impl Kernel
Sourcepub fn compile(
runtime: &Runtime,
name: &'static str,
spirv: &[u8],
bindings: u32,
workgroup_size: [u32; 3],
) -> Result<Self>
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.
Sourcepub const fn push_words(&self) -> usize
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.
Sourcepub const fn binding_count(&self) -> usize
pub const fn binding_count(&self) -> usize
The kernel’s declared storage-binding count.