639: Make BindingResource::TextureViewArray more flexible (addresses #588) r=grovesNL a=98devin

Fixes #588 

Rather than having a field of `&[TextureView]`, which requires either keeping all TextureViews in a vector in the first place or moving them into a temporary vector or array and back, use `&[&TextureView]` instead. Obviates the need for hacky workarounds if you keep your TextureViews in non-contiguous structs, maps, or can't move them, etc.

For those using a vector previously, the required transformation is merely `.iter().collect()`.

Co-authored-by: Devin Hill <98devin@gmail.com>
This commit is contained in:
bors[bot]
2020-11-25 04:07:29 +00:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@@ -218,8 +218,8 @@ impl framework::Example for Example {
wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::TextureViewArray(&[
red_texture_view,
green_texture_view,
&red_texture_view,
&green_texture_view,
]),
},
wgpu::BindGroupEntry {

View File

@@ -895,7 +895,7 @@ pub enum BindingResource<'a> {
///
/// Corresponds to [`BindingType::SampledTexture`] and [`BindingType::StorageTexture`] with
/// [`BindGroupLayoutEntry::count`] set to Some.
TextureViewArray(&'a [TextureView]),
TextureViewArray(&'a [&'a TextureView]),
}
/// Operation to perform to the output attachment at the start of a renderpass.