mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 15:00:57 +01:00
[core] Don't skip binding index checks for derived layouts. (#8325)
When deriving a bind group layout for a pipeline, bother to enforce `wgpu_types::Limits::max_bindings_per_bind_group`. Move the check: - from `wgpu_core::device::bgl::EntryMap::from_entries`, which is only used for explicit bind group creation - into `wgpu_core::device::Device::create_bind_group_layout`, which is used for all bind group layout creation.
This commit is contained in:
1 parent
665772a536
commit
6beea7c20d
3 files changed
+10
-10
No files matched your search
@@ -63,19 +63,10 @@ impl EntryMap {
|
||||
/// Errors if there are duplicate bindings or if any binding index is greater than
|
||||
/// the device's limits.
|
||||
pub fn from_entries(
|
||||
device_limits: &wgt::Limits,
|
||||
entries: &[wgt::BindGroupLayoutEntry],
|
||||
) -> Result<Self, binding_model::CreateBindGroupLayoutError> {
|
||||
let mut inner = FastIndexMap::with_capacity_and_hasher(entries.len(), Default::default());
|
||||
for entry in entries {
|
||||
if entry.binding >= device_limits.max_bindings_per_bind_group {
|
||||
return Err(
|
||||
binding_model::CreateBindGroupLayoutError::InvalidBindingIndex {
|
||||
binding: entry.binding,
|
||||
maximum: device_limits.max_bindings_per_bind_group,
|
||||
},
|
||||
);
|
||||
}
|
||||
if inner.insert(entry.binding, *entry).is_some() {
|
||||
return Err(binding_model::CreateBindGroupLayoutError::ConflictBinding(
|
||||
entry.binding,
|
||||
|
||||
@@ -693,7 +693,7 @@ impl Global {
|
||||
break 'error e.into();
|
||||
}
|
||||
|
||||
let entry_map = match bgl::EntryMap::from_entries(&device.limits, &desc.entries) {
|
||||
let entry_map = match bgl::EntryMap::from_entries(&desc.entries) {
|
||||
Ok(map) => map,
|
||||
Err(e) => break 'error e,
|
||||
};
|
||||
|
||||
@@ -2292,6 +2292,15 @@ impl Device {
|
||||
}
|
||||
|
||||
for entry in entry_map.values() {
|
||||
if entry.binding >= self.limits.max_bindings_per_bind_group {
|
||||
return Err(
|
||||
binding_model::CreateBindGroupLayoutError::InvalidBindingIndex {
|
||||
binding: entry.binding,
|
||||
maximum: self.limits.max_bindings_per_bind_group,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
use wgt::BindingType as Bt;
|
||||
|
||||
let mut required_features = wgt::Features::empty();
|
||||
|
||||
Reference in new issue
Block a user