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.
This commit is contained in:
Alex S
2021-06-19 23:24:06 +03:00
parent dd4c681a2f
commit 7e6d6a33ed

View File

@@ -586,6 +586,7 @@ impl crate::Device<super::Api> 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<super::Api> 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;
}
}
}