Skip to main content

KhalBuilder

Struct KhalBuilder 

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

Configures and runs the SPIR-V and PTX shader compilation pipeline.

Used in build.rs scripts to compile a shader crate before the host crate.

Implementations§

Source§

impl KhalBuilder

Source

pub fn new( shader_crate: impl AsRef<Path>, enable_builtin_features: bool, ) -> Self

Creates a new builder for the given shader crate directory. If enable_builtin_features is true, platform-specific features are auto-detected.

Source

pub fn from_dependency(links_name: &str, enable_builtin_features: bool) -> Self

Creates a new builder by locating the shader crate via cargo’s links metadata mechanism.

links_name must match the links value declared in the shader crate’s Cargo.toml. The shader crate’s build.rs must emit cargo::metadata=manifest_dir=$CARGO_MANIFEST_DIR, and the host crate must depend on the shader crate as a [build-dependencies] entry. Cargo then exposes DEP_<LINKS>_MANIFEST_DIR to this build script, which works identically for in-workspace path dependencies and for versions fetched from a registry.

Source

pub fn rust_min_stack(self, stack: u32) -> Self

Sets the RUST_MIN_STACK environment variable for the shader compilation processes.

Source

pub fn shader_src(self, src: impl AsRef<Path>) -> Self

Overrides the shader source directory (defaults to <shader_crate>/src).

Source

pub fn feature(self, feature: impl ToString) -> Self

Adds a cargo feature to enable when building the shader crate.

Source

pub fn build(self, output_dir: impl AsRef<Path>)

Compiles the shader crate and writes output files to output_dir.

Auto Trait Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.