mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Update WGSL grammar for pointer access. (#1312)
* Update WGSL grammar for pointer access. Comes with a small test, which revealed a number of issues in the backends. * Validate pointer arguments to functions to only have function/private/workgroup classes. Comes with a small test. Also, "pointer-access.spv" test is temporarily disabled.
This commit is contained in:
@@ -76,6 +76,12 @@ pub enum FunctionError {
|
||||
},
|
||||
#[error("Argument '{name}' at index {index} has a type that can't be passed into functions.")]
|
||||
InvalidArgumentType { index: usize, name: String },
|
||||
#[error("Argument '{name}' at index {index} is a pointer of class {class:?}, which can't be passed into functions.")]
|
||||
InvalidArgumentPointerClass {
|
||||
index: usize,
|
||||
name: String,
|
||||
class: crate::StorageClass,
|
||||
},
|
||||
#[error("There are instructions after `return`/`break`/`continue`")]
|
||||
InstructionsAfterReturn,
|
||||
#[error("The `break` is used outside of a `loop` or `switch` context")]
|
||||
@@ -696,6 +702,19 @@ impl super::Validator {
|
||||
name: argument.name.clone().unwrap_or_default(),
|
||||
});
|
||||
}
|
||||
match module.types[argument.ty].inner.pointer_class() {
|
||||
Some(crate::StorageClass::Private)
|
||||
| Some(crate::StorageClass::Function)
|
||||
| Some(crate::StorageClass::WorkGroup)
|
||||
| None => {}
|
||||
Some(other) => {
|
||||
return Err(FunctionError::InvalidArgumentPointerClass {
|
||||
index,
|
||||
name: argument.name.clone().unwrap_or_default(),
|
||||
class: other,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.valid_expression_set.clear();
|
||||
|
||||
Reference in New Issue
Block a user