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
impl ShaderBuild
Sourcepub fn new() -> Self
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"
Sourcepub fn source_dir(self, dir: &str) -> Self
pub fn source_dir(self, dir: &str) -> Self
Sets the source directory containing shader files.
Sourcepub fn output_dir(self, dir: &str) -> Self
pub fn output_dir(self, dir: &str) -> Self
Sets the output directory for compiled GLSL ES shaders.
Sourcepub fn slangc_path(self, path: &str) -> Self
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();Sourcepub fn override_file_type_handler(
self,
extension: &str,
handler: impl Fn(&Path, &Path) -> Vec<String> + 'static,
) -> Self
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:
- Compile the file and write output to
output_dir - Add the
"//! DO NOT EDIT"header to generated files - 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();Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShaderBuild
impl !RefUnwindSafe for ShaderBuild
impl !Send for ShaderBuild
impl !Sync for ShaderBuild
impl Unpin for ShaderBuild
impl UnsafeUnpin for ShaderBuild
impl !UnwindSafe for ShaderBuild
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