diff --git a/src/front/glsl/parser.rs b/src/front/glsl/parser.rs index 97fa3a35cd..2e752e867c 100644 --- a/src/front/glsl/parser.rs +++ b/src/front/glsl/parser.rs @@ -5,12 +5,13 @@ pomelo! { %include { use super::super::{error::ErrorKind, token::*, ast::*}; use crate::{ + BOOL_WIDTH, Arena, BinaryOperator, Binding, Block, Constant, ConstantInner, Expression, Function, GlobalVariable, Handle, Interpolation, LocalVariable, ScalarValue, ScalarKind, Statement, StorageAccess, StorageClass, StructMember, - SwitchCase, Type, TypeInner, UnaryOperator, FunctionArgument + SwitchCase, Type, TypeInner, UnaryOperator, FunctionArgument, }; use pp_rs::token::PreprocessorError; } @@ -212,7 +213,7 @@ pomelo! { name: None, specialization: None, inner: ConstantInner::Scalar { - width: 1, + width: BOOL_WIDTH, value: ScalarValue::Bool(b.1) }, }); diff --git a/src/front/mod.rs b/src/front/mod.rs index 6ae985cd08..4177bddcbb 100644 --- a/src/front/mod.rs +++ b/src/front/mod.rs @@ -32,3 +32,13 @@ impl Emitter { } } } + +#[allow(dead_code)] +impl super::ConstantInner { + fn boolean(value: bool) -> Self { + Self::Scalar { + width: super::BOOL_WIDTH, + value: super::ScalarValue::Bool(value), + } + } +} diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index 64fac17586..cc4b9cebb7 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -2000,7 +2000,7 @@ impl> Parser { let id = self.next()?; let inner = crate::TypeInner::Scalar { kind: crate::ScalarKind::Bool, - width: 1, + width: crate::BOOL_WIDTH, }; self.lookup_type.insert( id, @@ -2608,10 +2608,7 @@ impl> Parser { handle: module.constants.append(crate::Constant { name: self.future_decor.remove(&id).and_then(|dec| dec.name), specialization: None, //TODO - inner: crate::ConstantInner::Scalar { - width: 1, - value: crate::ScalarValue::Bool(value), - }, + inner: crate::ConstantInner::boolean(value), }), type_id, }, diff --git a/src/front/wgsl/mod.rs b/src/front/wgsl/mod.rs index a028954c3d..b7e6f6445c 100644 --- a/src/front/wgsl/mod.rs +++ b/src/front/wgsl/mod.rs @@ -907,14 +907,8 @@ impl Parser { ) -> Result, Error<'a>> { self.scopes.push(Scope::ConstantExpr); let inner = match first_token_span { - (Token::Word("true"), _) => crate::ConstantInner::Scalar { - width: 1, - value: crate::ScalarValue::Bool(true), - }, - (Token::Word("false"), _) => crate::ConstantInner::Scalar { - width: 1, - value: crate::ScalarValue::Bool(false), - }, + (Token::Word("true"), _) => crate::ConstantInner::boolean(true), + (Token::Word("false"), _) => crate::ConstantInner::boolean(false), ( Token::Number { ref value, @@ -1516,7 +1510,7 @@ impl Parser { }, "bool" => crate::TypeInner::Scalar { kind: crate::ScalarKind::Bool, - width: 1, + width: crate::BOOL_WIDTH, }, "vec2" => { let (kind, width) = lexer.next_scalar_generic()?; diff --git a/src/proc/validator.rs b/src/proc/validator.rs index 157bea0c1a..92306d9598 100644 --- a/src/proc/validator.rs +++ b/src/proc/validator.rs @@ -346,7 +346,7 @@ impl crate::GlobalVariable { }), Bi::FrontFacing => Some(Ti::Scalar { kind: Sk::Bool, - width: 1, + width: crate::BOOL_WIDTH, }), Bi::GlobalInvocationId | Bi::LocalInvocationId