From 0ae0446f3a3c184ba462122edd4c89dbd07431b0 Mon Sep 17 00:00:00 2001 From: Elie Michel Date: Wed, 13 Sep 2023 15:23:58 +0200 Subject: [PATCH] [cli] Add support for `.{vert,frag,comp}.glsl` files (#2462) --- cli/src/bin/naga.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cli/src/bin/naga.rs b/cli/src/bin/naga.rs index 8f57984f56..8bd73b87f2 100644 --- a/cli/src/bin/naga.rs +++ b/cli/src/bin/naga.rs @@ -302,7 +302,7 @@ fn run() -> Result<(), Box> { } } } - ext @ ("vert" | "frag" | "comp") => { + ext @ ("vert" | "frag" | "comp" | "glsl") => { let input = String::from_utf8(input)?; let mut parser = naga::front::glsl::Frontend::default(); @@ -314,6 +314,20 @@ fn run() -> Result<(), Box> { "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(),