fix(metal): don't depend on BG{,L} entry order

This isn't guaranteed by `wgpu-core`; we should try to match by binding
slot index instead.
This commit is contained in:
Erich Gubler 2024-03-21 16:09:29 -04:00
parent 74f514ca6b
commit d12e89c483
2 changed files with 14 additions and 1 deletions

View File

@ -163,6 +163,10 @@ Bottom level categories:
- Set object labels when the DEBUG flag is set, even if the VALIDATION flag is disabled. By @DJMcNab in [#5345](https://github.com/gfx-rs/wgpu/pull/5345).
#### Metal
- Don't depend on bind group and bind group layout entry order in HAL. This caused incorrect severely incorrect command execution and, in some cases, crashes. By @ErichDonGubler in [#5421](https://github.com/gfx-rs/wgpu/pull/5421).
#### DX12
- Don't depend on bind group and bind group layout entry order in HAL. This caused incorrect severely incorrect command execution and, in some cases, crashes. By @ErichDonGubler in [#5421](https://github.com/gfx-rs/wgpu/pull/5421).

View File

@ -708,7 +708,16 @@ impl crate::Device for super::Device {
for (&stage, counter) in super::NAGA_STAGES.iter().zip(bg.counters.iter_mut()) {
let stage_bit = map_naga_stage(stage);
let mut dynamic_offsets_count = 0u32;
for (entry, layout) in desc.entries.iter().zip(desc.layout.entries.iter()) {
let layout_and_entry_iter = desc.entries.iter().map(|entry| {
let layout = desc
.layout
.entries
.iter()
.find(|layout_entry| layout_entry.binding == entry.binding)
.expect("internal error: no layout entry found with binding slot");
(entry, layout)
});
for (entry, layout) in layout_and_entry_iter {
let size = layout.count.map_or(1, |c| c.get());
if let wgt::BindingType::Buffer {
has_dynamic_offset: true,