Skip to main content

ShaderBuild

Struct ShaderBuild 

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

Builder for the shader build pipeline.

Configure source/output directories and optional custom file-type handlers, then call .build() to compile all shaders.

Implementations§

Source§

impl ShaderBuild

Source

pub fn new() -> Self

Creates a new ShaderBuild with default directories.

Defaults:

  • source_dir: "shaders/"
  • output_dir: "assets/build/shaders/"
  • spirv_dir: "build/shaders/spirv/"
  • hash_file: "build/shaders/hashes.json"
Source

pub fn source_dir(self, dir: &str) -> Self

Sets the source directory containing shader files.

Source

pub fn output_dir(self, dir: &str) -> Self

Sets the output directory for compiled GLSL ES shaders.

Source

pub fn slangc_path(self, path: &str) -> Self

Sets a custom path to the slangc compiler.

By default, slangc is located via PATH. Use this if slangc is not on PATH or you want to pin a specific version.

§Example
ShaderBuild::new()
    .slangc_path("/opt/slang/bin/slangc")
    .build();
Source

pub fn override_file_type_handler( self, extension: &str, handler: impl Fn(&Path, &Path) -> Vec<String> + 'static, ) -> Self

Registers a custom file-type handler for a given extension.

The handler receives (file_path, output_dir) and should:

  1. Compile the file and write output to output_dir
  2. Add the "//! DO NOT EDIT" header to generated files
  3. Return glob patterns for additional dependency files
§Example
ShaderBuild::new()
    .override_file_type_handler(".wgsl", |file_path, output_dir| {
        // Custom compilation logic here
        vec!["shaders/includes/**/*.wgsl".to_string()]
    })
    .build();
Source

pub fn build(self)

Runs the shader build pipeline.

This will:

  1. Scan the source directory for shader files
  2. Check content hashes for incremental builds
  3. Compile changed shaders using the appropriate pipeline
  4. Write compiled GLSL ES output to the output directory
  5. Update the hash file

Trait Implementations§

Source§

impl Default for ShaderBuild

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more