diff --git a/shader-parser/examples/example.rs b/shader-parser/examples/example.rs index dd86e6a8..bbf45246 100644 --- a/shader-parser/examples/example.rs +++ b/shader-parser/examples/example.rs @@ -27,6 +27,6 @@ void main() { "#; let content = glsl_to_spirv::compile(Some((shader, glsl_to_spirv::ShaderType::Fragment))).unwrap(); - let output = shader_parser::reflect(content).unwrap(); + let output = shader_parser::reflect("Shader", content).unwrap(); println!("{}", output); } diff --git a/shader-parser/src/lib.rs b/shader-parser/src/lib.rs index 5190fedb..2d2c3211 100644 --- a/shader-parser/src/lib.rs +++ b/shader-parser/src/lib.rs @@ -6,7 +6,7 @@ pub use parse::ParseError; mod enums; mod parse; -pub fn reflect(mut spirv: R) -> Result +pub fn reflect(name: &str, mut spirv: R) -> Result where R: Read { let mut data = Vec::new(); @@ -22,18 +22,18 @@ pub fn reflect(mut spirv: R) -> Result .collect::>() .join(", "); output.push_str(&format!(r#" -pub struct Shader; +pub struct {name}; -impl Shader {{ +impl {name} {{ pub fn load(device: &::std::sync::Arc<::vulkano::Device>) {{ unsafe {{ let data = [{spirv_data}]; - ::vulkano::Shader::new(device, &data) + ::vulkano::ShaderModule::new(device, &data) }} }} }} - "#, spirv_data = spirv_data)); + "#, name = name, spirv_data = spirv_data)); } println!("{:#?}", doc);