From 7d0e9847b00a3b02df4413713eb048faa420a1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Capucho?= Date: Mon, 5 Sep 2022 23:45:55 +0100 Subject: [PATCH] Remove the glsl-validate feature When it was introduced it was supposed to allow for fast compiles by skipping glsl specific validation, but as it turns the subset of glsl that's compilable code is already pretty close to the subset of valid glsl code. So the current code gated behind glsl-validate amounts to a single branch that isn't even performance sensitive, and most of the validation is not specific to glsl and is made by naga's validator which can be turned off, so the original goal of fast compile times by disabling validation can still be accomplished. --- Cargo.toml | 1 - cli/Cargo.toml | 2 +- src/front/glsl/error.rs | 1 - src/front/glsl/variables.rs | 2 -- 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5a6d62805d..cbad28e8e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ default = [] clone = [] dot-out = [] glsl-in = ["pp-rs"] -glsl-validate = [] glsl-out = [] msl-out = [] serialize = ["serde", "indexmap/serde-1"] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index ac5238bd51..daf169f428 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -14,7 +14,7 @@ name = "naga" path = "src/main.rs" [dependencies] -naga = { version = "0.9", path = "../", features = ["validate", "span", "wgsl-in", "wgsl-out", "glsl-in", "glsl-out", "spv-in", "spv-out", "msl-out", "hlsl-out", "dot-out", "glsl-validate", "serialize", "deserialize"] } +naga = { version = "0.9", path = "../", features = ["validate", "span", "wgsl-in", "wgsl-out", "glsl-in", "glsl-out", "spv-in", "spv-out", "msl-out", "hlsl-out", "dot-out", "serialize", "deserialize"] } bincode = "1" log = "0.4" codespan-reporting = "0.11" diff --git a/src/front/glsl/error.rs b/src/front/glsl/error.rs index c9ea102fab..299bf57aa4 100644 --- a/src/front/glsl/error.rs +++ b/src/front/glsl/error.rs @@ -101,7 +101,6 @@ pub enum ErrorKind { #[error("unsupported matrix of the form matCx2 in std140 block layout")] UnsupportedMatrixTypeInStd140, /// A variable with the same name already exists in the current scope. - #[cfg(feature = "glsl-validate")] #[error("Variable already declared: {0}")] VariableAlreadyDeclared(String), /// A semantic error was detected in the shader. diff --git a/src/front/glsl/variables.rs b/src/front/glsl/variables.rs index d6f9d7e0ff..1634fb40cb 100644 --- a/src/front/glsl/variables.rs +++ b/src/front/glsl/variables.rs @@ -637,10 +637,8 @@ impl Parser { let expr = ctx.add_expression(Expression::LocalVariable(handle), decl.meta, body); if let Some(name) = decl.name { - #[allow(unused_variables)] let maybe_var = ctx.add_local_var(name.clone(), expr, mutable); - #[cfg(feature = "glsl-validate")] if maybe_var.is_some() { self.errors.push(Error { kind: ErrorKind::VariableAlreadyDeclared(name),