Skip to content

Commit

Permalink
make plane optional
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopengli89 committed Oct 30, 2023
1 parent 5afea28 commit 6eff324
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion deno_webgpu/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub fn op_webgpu_create_texture_view(
format: args.format,
dimension: args.dimension,
range: args.range,
plane: 0,
plane: None,
};

gfx_put!(texture => instance.texture_create_view(
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/nv12_texture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ static NV12_TEXTURE_CREATION_SAMPLING: GpuTestConfiguration = GpuTestConfigurati
});
let y_view = tex.create_view(&wgpu::TextureViewDescriptor {
format: Some(wgpu::TextureFormat::R8Unorm),
plane: 0,
plane: Some(0),
..Default::default()
});
let uv_view = tex.create_view(&wgpu::TextureViewDescriptor {
format: Some(wgpu::TextureFormat::Rg8Unorm),
plane: 1,
plane: Some(1),
..Default::default()
});
let sampler = ctx.device.create_sampler(&wgpu::SamplerDescriptor {
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ impl<A: HalApi> Device<A> {
base_array_layer: array_layer,
array_layer_count: Some(1),
},
plane: 0,
plane: None,
};
clear_views.push(
unsafe { self.raw.create_texture_view(&raw_texture, &desc) }
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
dimension: wgt::TextureViewDimension::D2,
usage: hal::TextureUses::COLOR_TARGET,
range: wgt::ImageSubresourceRange::default(),
plane: 0,
plane: None,
};
let mut clear_views = smallvec::SmallVec::new();
clear_views.push(
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ pub struct TextureViewDescriptor<'a> {
/// Range within the texture that is accessible via this view.
pub range: wgt::ImageSubresourceRange,
/// The plane of the texture view.
pub plane: u32,
pub plane: Option<u32>,
}

#[derive(Debug)]
Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/examples/halmark/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ impl<A: hal::Api> Example<A> {
dimension: wgt::TextureViewDimension::D2,
usage: hal::TextureUses::RESOURCE,
range: wgt::ImageSubresourceRange::default(),
plane: 0,
plane: None,
};
let texture_view = unsafe { device.create_texture_view(&texture, &view_desc).unwrap() };

Expand Down Expand Up @@ -658,7 +658,7 @@ impl<A: hal::Api> Example<A> {
dimension: wgt::TextureViewDimension::D2,
usage: hal::TextureUses::COLOR_TARGET,
range: wgt::ImageSubresourceRange::default(),
plane: 0,
plane: None,
};
let surface_tex_view = unsafe {
self.device
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/examples/raw-gles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ fn fill_screen(exposed: &hal::ExposedAdapter<hal::api::Gles>, width: u32, height
dimension: wgt::TextureViewDimension::D2,
usage: hal::TextureUses::COLOR_TARGET,
range: wgt::ImageSubresourceRange::default(),
plane: 0,
plane: None,
},
)
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ pub struct TextureViewDescriptor<'a> {
pub dimension: wgt::TextureViewDimension,
pub usage: TextureUses,
pub range: wgt::ImageSubresourceRange,
pub plane: u32,
pub plane: Option<u32>,
}

#[derive(Clone, Debug)]
Expand Down
3 changes: 1 addition & 2 deletions wgpu-hal/src/vulkan/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,8 +1062,7 @@ impl crate::Device<super::Api> for super::Device {
texture: &super::Texture,
desc: &crate::TextureViewDescriptor,
) -> Result<super::TextureView, crate::DeviceError> {
let subresource_range =
conv::map_subresource_range(&desc.range, desc.format, Some(desc.plane));
let subresource_range = conv::map_subresource_range(&desc.range, desc.format, desc.plane);
let mut vk_info = vk::ImageViewCreateInfo::builder()
.flags(vk::ImageViewCreateFlags::empty())
.image(texture.raw)
Expand Down
2 changes: 1 addition & 1 deletion wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ pub struct TextureViewDescriptor<'a> {
/// If `None`, considered to include the rest of the array layers, but at least 1 in total.
pub array_layer_count: Option<u32>,
/// The index (plane slice number) of the plane to use in the texture.
pub plane: u32,
pub plane: Option<u32>,
}
static_assertions::assert_impl_all!(TextureViewDescriptor: Send, Sync);

Expand Down

0 comments on commit 6eff324

Please sign in to comment.