Skip to content

Commit 1cbebdc

Browse files
authored
[core] Don't skip binding index checks for derived layouts. (gfx-rs#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.
1 parent 2e48faf commit 1cbebdc

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ SamplerDescriptor {
8484

8585
- Reject fragment shader output `location`s > `max_color_attachments` limit. By @ErichDonGubler in [#8316](https://github.com/gfx-rs/wgpu/pull/8316).
8686
- WebGPU device requests now support the required limits `maxColorAttachments` and `maxColorAttachmentBytesPerSample`. By @evilpie in [#8328](https://github.com/gfx-rs/wgpu/pull/8328)
87+
- Reject binding indices that exceed `wgpu_types::Limits::max_bindings_per_bind_group` when deriving a bind group layout for a pipeline. By @jimblandy in [#8325](https://github.com/gfx-rs/wgpu/pull/8325).
8788

8889
## v27.0.2 (2025-10-03)
8990

wgpu-core/src/device/bgl.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,10 @@ impl EntryMap {
6363
/// Errors if there are duplicate bindings or if any binding index is greater than
6464
/// the device's limits.
6565
pub fn from_entries(
66-
device_limits: &wgt::Limits,
6766
entries: &[wgt::BindGroupLayoutEntry],
6867
) -> Result<Self, binding_model::CreateBindGroupLayoutError> {
6968
let mut inner = FastIndexMap::with_capacity_and_hasher(entries.len(), Default::default());
7069
for entry in entries {
71-
if entry.binding >= device_limits.max_bindings_per_bind_group {
72-
return Err(
73-
binding_model::CreateBindGroupLayoutError::InvalidBindingIndex {
74-
binding: entry.binding,
75-
maximum: device_limits.max_bindings_per_bind_group,
76-
},
77-
);
78-
}
7970
if inner.insert(entry.binding, *entry).is_some() {
8071
return Err(binding_model::CreateBindGroupLayoutError::ConflictBinding(
8172
entry.binding,

wgpu-core/src/device/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ impl Global {
693693
break 'error e.into();
694694
}
695695

696-
let entry_map = match bgl::EntryMap::from_entries(&device.limits, &desc.entries) {
696+
let entry_map = match bgl::EntryMap::from_entries(&desc.entries) {
697697
Ok(map) => map,
698698
Err(e) => break 'error e,
699699
};

wgpu-core/src/device/resource.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,15 @@ impl Device {
22922292
}
22932293

22942294
for entry in entry_map.values() {
2295+
if entry.binding >= self.limits.max_bindings_per_bind_group {
2296+
return Err(
2297+
binding_model::CreateBindGroupLayoutError::InvalidBindingIndex {
2298+
binding: entry.binding,
2299+
maximum: self.limits.max_bindings_per_bind_group,
2300+
},
2301+
);
2302+
}
2303+
22952304
use wgt::BindingType as Bt;
22962305

22972306
let mut required_features = wgt::Features::empty();

0 commit comments

Comments
 (0)