fix(gles): 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 4fa2fbb5aa
commit 74f514ca6b
2 changed files with 15 additions and 3 deletions

View File

@ -157,6 +157,7 @@ Bottom level categories:
- Fixes for being able to use an OpenGL 4.1 core context provided by macOS with wgpu. By @bes in [#5331](https://github.com/gfx-rs/wgpu/pull/5331).
- Don't create a program for shader-clearing if that workaround isn't required. By @Dinnerbone in [#5348](https://github.com/gfx-rs/wgpu/pull/5348).
- Fix crash when holding multiple devices on wayland/surfaceless. By @ashdnazg in [#5351](https://github.com/gfx-rs/wgpu/pull/5351).
- 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).
#### Vulkan

View File

@ -1125,8 +1125,10 @@ impl crate::Device for super::Device {
!0;
bg_layout
.entries
.last()
.map_or(0, |b| b.binding as usize + 1)
.iter()
.map(|b| b.binding)
.max()
.map_or(0, |idx| idx as usize + 1)
]
.into_boxed_slice();
@ -1179,7 +1181,16 @@ impl crate::Device for super::Device {
) -> Result<super::BindGroup, crate::DeviceError> {
let mut contents = Vec::new();
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 binding = match layout.ty {
wgt::BindingType::Buffer { .. } => {
let bb = &desc.buffers[entry.resource_index as usize];