mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 14:56:42 +00:00
Allow customizing the shader struct name
This commit is contained in:
parent
964ad0a27e
commit
3836c318dd
@ -27,6 +27,6 @@ void main() {
|
|||||||
"#;
|
"#;
|
||||||
|
|
||||||
let content = glsl_to_spirv::compile(Some((shader, glsl_to_spirv::ShaderType::Fragment))).unwrap();
|
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);
|
println!("{}", output);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ pub use parse::ParseError;
|
|||||||
mod enums;
|
mod enums;
|
||||||
mod parse;
|
mod parse;
|
||||||
|
|
||||||
pub fn reflect<R>(mut spirv: R) -> Result<String, Error>
|
pub fn reflect<R>(name: &str, mut spirv: R) -> Result<String, Error>
|
||||||
where R: Read
|
where R: Read
|
||||||
{
|
{
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
@ -22,18 +22,18 @@ pub fn reflect<R>(mut spirv: R) -> Result<String, Error>
|
|||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join(", ");
|
.join(", ");
|
||||||
output.push_str(&format!(r#"
|
output.push_str(&format!(r#"
|
||||||
pub struct Shader;
|
pub struct {name};
|
||||||
|
|
||||||
impl Shader {{
|
impl {name} {{
|
||||||
pub fn load(device: &::std::sync::Arc<::vulkano::Device>) {{
|
pub fn load(device: &::std::sync::Arc<::vulkano::Device>) {{
|
||||||
unsafe {{
|
unsafe {{
|
||||||
let data = [{spirv_data}];
|
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);
|
println!("{:#?}", doc);
|
||||||
|
Loading…
Reference in New Issue
Block a user