Skip to content

Commit

Permalink
Remove the glsl-validate feature
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JCapucho authored and jimblandy committed Sep 6, 2022
1 parent d9c9fe6 commit 7d0e984
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 5 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ default = []
clone = []
dot-out = []
glsl-in = ["pp-rs"]
glsl-validate = []
glsl-out = []
msl-out = []
serialize = ["serde", "indexmap/serde-1"]
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/front/glsl/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions src/front/glsl/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 7d0e984

Please sign in to comment.