Gather downlevel flags and require them all at once
@@ -1039,6 +1039,7 @@ impl<A: HalApi> Device<A> {
use wgt::BindingType as Bt;
let mut required_features = wgt::Features::empty();
+ let mut required_downlevel_flags = wgt::DownlevelFlags::empty();
let (array_feature, writable_storage) = match entry.ty {
Bt::Buffer {
ty: wgt::BufferBindingType::Uniform,
@@ -1113,23 +1114,13 @@ impl<A: HalApi> Device<A> {
..
} = entry.ty
{
- self.require_downlevel_flags(wgt::DownlevelFlags::VERTEX_STORAGE)
- .map_err(binding_model::BindGroupLayoutEntryError::MissingDownlevelFlags)
- .map_err(|error| binding_model::CreateBindGroupLayoutError::Entry {
- binding: entry.binding,
- error,
- })?;
+ required_downlevel_flags |= wgt::DownlevelFlags::VERTEX_STORAGE;
}
}
if writable_storage == WritableStorage::Yes
&& entry.visibility.contains(wgt::ShaderStages::FRAGMENT)
{
- self.require_downlevel_flags(wgt::DownlevelFlags::FRAGMENT_WRITABLE_STORAGE)
- .map_err(binding_model::BindGroupLayoutEntryError::MissingDownlevelFlags)
- .map_err(|error| binding_model::CreateBindGroupLayoutError::Entry {
- binding: entry.binding,
- error,
- })?;
+ required_downlevel_flags |= wgt::DownlevelFlags::FRAGMENT_WRITABLE_STORAGE;
}
self.require_features(required_features)
@@ -1138,6 +1129,12 @@ impl<A: HalApi> Device<A> {
binding: entry.binding,
error,
})?;
+ self.require_downlevel_flags(required_downlevel_flags)
+ .map_err(binding_model::BindGroupLayoutEntryError::MissingDownlevelFlags)
+ .map_err(|error| binding_model::CreateBindGroupLayoutError::Entry {
+ binding: entry.binding,
+ error,
+ })?;
}
let mut hal_bindings = entry_map.values().cloned().collect::<Vec<_>>();
