[wgsl-in] eagerly evaluate const-expressions

[wgsl-in] support const-expressions in attributes

allow `Splat` as an evaluated const-expression type
This commit is contained in:
teoxoy
2023-04-19 14:55:07 +02:00
committed by Teodor Tanasoaia
parent c5d884fca8
commit a730236b68
44 changed files with 2917 additions and 2770 deletions

View File

@@ -134,6 +134,8 @@ pub enum ConstExpressionError {
NonConst,
#[error(transparent)]
Compose(#[from] super::ComposeError),
#[error("Splatting {0:?} can't be done")]
InvalidSplatType(Handle<crate::Expression>),
#[error("Type resolution failed")]
Type(#[from] ResolveError),
#[error(transparent)]
@@ -196,6 +198,10 @@ impl super::Validator {
components.iter().map(|&handle| mod_info[handle].clone()),
)?;
}
E::Splat { value, .. } => match *mod_info[value].inner_with(gctx.types) {
crate::TypeInner::Scalar { .. } => {}
_ => return Err(super::ConstExpressionError::InvalidSplatType(value)),
},
_ => return Err(super::ConstExpressionError::NonConst),
}