mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 23:11:01 +01:00
Validate structure resource types
This commit is contained in:
1 parent
5c3bee6959
commit
df6ce9aa9c
1 file changed
+11
-7
+11
-7
@@ -355,13 +355,7 @@ impl super::Validator {
|
||||
true,
|
||||
)
|
||||
}
|
||||
crate::StorageClass::Handle => {
|
||||
match types[var.ty].inner {
|
||||
crate::TypeInner::Image { .. } | crate::TypeInner::Sampler { .. } => {}
|
||||
_ => return Err(GlobalVariableError::InvalidType),
|
||||
};
|
||||
(TypeFlags::empty(), true)
|
||||
}
|
||||
crate::StorageClass::Handle => (TypeFlags::empty(), true),
|
||||
crate::StorageClass::Private | crate::StorageClass::WorkGroup => {
|
||||
(TypeFlags::DATA | TypeFlags::SIZED, false)
|
||||
}
|
||||
@@ -378,6 +372,16 @@ impl super::Validator {
|
||||
}
|
||||
};
|
||||
|
||||
let is_handle = var.class == crate::StorageClass::Handle;
|
||||
let good_type = match types[var.ty].inner {
|
||||
crate::TypeInner::Struct { .. } => !is_handle,
|
||||
crate::TypeInner::Image { .. } | crate::TypeInner::Sampler { .. } => is_handle,
|
||||
_ => false,
|
||||
};
|
||||
if is_resource && !good_type {
|
||||
return Err(GlobalVariableError::InvalidType);
|
||||
}
|
||||
|
||||
if !type_info.flags.contains(required_type_flags) {
|
||||
return Err(GlobalVariableError::MissingTypeFlags {
|
||||
seen: type_info.flags,
|
||||
|
||||
Reference in new issue
Block a user