Validate structure resource types

This commit is contained in:
Dzmitry Malyshau committed 2022-01-11 22:52:02 -05:00
1 parent 5c3bee6959
commit df6ce9aa9c
1 file changed
+11 -7
+11 -7
View File
@@ -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,