Skip to content

Commit

Permalink
[cli] Add support for .{vert,frag,comp}.glsl files (#2462)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliemichel authored Sep 13, 2023
1 parent 1281c11 commit 0ae0446
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cli/src/bin/naga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
}
}
}
ext @ ("vert" | "frag" | "comp") => {
ext @ ("vert" | "frag" | "comp" | "glsl") => {
let input = String::from_utf8(input)?;
let mut parser = naga::front::glsl::Frontend::default();

Expand All @@ -314,6 +314,20 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
"vert" => naga::ShaderStage::Vertex,
"frag" => naga::ShaderStage::Fragment,
"comp" => naga::ShaderStage::Compute,
"glsl" => {
let internal_name = input_path.to_string_lossy();
match Path::new(&internal_name[..internal_name.len()-5])
.extension()
.ok_or(CliError("Input filename ending with .glsl has no internal extension"))?
.to_str()
.ok_or(CliError("Input filename not valid unicode"))?
{
"vert" => naga::ShaderStage::Vertex,
"frag" => naga::ShaderStage::Fragment,
"comp" => naga::ShaderStage::Compute,
_ => unreachable!(),
}
},
_ => unreachable!(),
},
defines: Default::default(),
Expand Down

0 comments on commit 0ae0446

Please sign in to comment.