|
|
|
@ -10,6 +10,7 @@ pub use reflection::LayoutData;
|
|
|
|
|
pub use watch::{Message, Watch};
|
|
|
|
|
pub use error::*;
|
|
|
|
|
|
|
|
|
|
use shaderc::CompileOptions;
|
|
|
|
|
use spirv_reflect as sr;
|
|
|
|
|
use vulkano as vk;
|
|
|
|
|
use std::path::Path;
|
|
|
|
@ -26,9 +27,16 @@ pub fn load<T>(vertex: T, fragment: T) -> Result<CompiledShaders, Error>
|
|
|
|
|
where
|
|
|
|
|
T: AsRef<Path>,
|
|
|
|
|
{
|
|
|
|
|
let options = CompileOptions::new().ok_or(CompileError::CreateCompiler).unwrap();
|
|
|
|
|
|
|
|
|
|
let vertex = compiler::compile(vertex, ShaderKind::Vertex).map_err(Error::Compile)?;
|
|
|
|
|
let fragment = compiler::compile(fragment, ShaderKind::Fragment).map_err(Error::Compile)?;
|
|
|
|
|
Ok(CompiledShaders{ vertex, fragment, compute: Vec::new() })
|
|
|
|
|
|
|
|
|
|
Ok(CompiledShaders{
|
|
|
|
|
vertex,
|
|
|
|
|
fragment,
|
|
|
|
|
compute: Vec::new(),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO this should be incorpoarted into load but that would be
|
|
|
|
@ -37,8 +45,20 @@ pub fn load_compute<T>(compute: T) -> Result<CompiledShaders, Error>
|
|
|
|
|
where
|
|
|
|
|
T: AsRef<Path>,
|
|
|
|
|
{
|
|
|
|
|
let compute = compiler::compile(compute, ShaderKind::Compute).map_err(Error::Compile)?;
|
|
|
|
|
Ok(CompiledShaders{ vertex: Vec::new(), fragment: Vec::new(), compute })
|
|
|
|
|
let options = CompileOptions::new().ok_or(CompileError::CreateCompiler).unwrap();
|
|
|
|
|
load_compute_with_options(compute, options)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn load_compute_with_options<T>(compute: T, options: CompileOptions) -> Result<CompiledShaders, Error>
|
|
|
|
|
where
|
|
|
|
|
T: AsRef<Path>,
|
|
|
|
|
{
|
|
|
|
|
let compute = compiler::compile_with_options(compute, ShaderKind::Compute, options).map_err(Error::Compile)?;
|
|
|
|
|
Ok(CompiledShaders{
|
|
|
|
|
vertex: Vec::new(),
|
|
|
|
|
fragment: Vec::new(),
|
|
|
|
|
compute,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn parse_compute(code: &CompiledShaders) -> Result<Entry, Error> {
|
|
|
|
|