From 7e6d6a33edc09e7581bf6483af322f02eafec2d7 Mon Sep 17 00:00:00 2001 From: Alex S Date: Sat, 19 Jun 2021 23:24:06 +0300 Subject: [PATCH] Fix (?) texture array binding for Metal. Potentially needs more testing - Metal's binding model is quite different from Vulkan and WGPU, but as far as I understand from the documentation, arrays of textures occupy a contiguous range of binding slots, so unwrapping and binding one-by-one should be fine. Someone should actually go and test this on a Mac, maybe. --- wgpu-hal/src/metal/device.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index 3a6f80d669..2fd001a6b0 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -586,6 +586,7 @@ impl crate::Device for super::Device { has_dynamic_offset, .. } => { + debug_assert_eq!(entry.size, 1); let source = &desc.buffers[entry.resource_index as usize]; let remaining_size = wgt::BufferSize::new(source.buffer.size - source.offset); @@ -614,9 +615,14 @@ impl crate::Device for super::Device { counter.samplers += 1; } wgt::BindingType::Texture { .. } | wgt::BindingType::StorageTexture { .. } => { - let res = desc.textures[entry.resource_index as usize].view.as_raw(); - bg.textures.push(res); - counter.textures += 1; + let start = entry.resource_index; + let end = entry.resource_index + entry.size; + bg.textures.extend( + desc.textures[start as usize..end as usize] + .iter() + .map(|tex| tex.view.as_raw()), + ); + counter.textures += entry.size; } } }