From d59dce5eeaa4731159905ddac4469fae9bffd78a Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Thu, 6 Feb 2025 13:42:10 -0800 Subject: [PATCH] More documentation for `TextureView`. (#7069) Explain how to make one and what its properties are. --- wgpu/src/api/texture.rs | 6 +++++- wgpu/src/api/texture_view.rs | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/wgpu/src/api/texture.rs b/wgpu/src/api/texture.rs index 03044bdf15..8ac80e6505 100644 --- a/wgpu/src/api/texture.rs +++ b/wgpu/src/api/texture.rs @@ -37,7 +37,11 @@ impl Texture { } } - /// Creates a view of this texture. + /// Creates a view of this texture, specifying an interpretation of its texels and + /// possibly a subset of its layers and mip levels. + /// + /// Texture views are needed to use a texture as a binding in a [`BindGroup`] + /// or as an attachment in a [`RenderPass`]. pub fn create_view(&self, desc: &TextureViewDescriptor<'_>) -> TextureView { let view = self.inner.create_view(desc); diff --git a/wgpu/src/api/texture_view.rs b/wgpu/src/api/texture_view.rs index 9b3a7d9386..490e0e6eca 100644 --- a/wgpu/src/api/texture_view.rs +++ b/wgpu/src/api/texture_view.rs @@ -2,8 +2,11 @@ use crate::*; /// Handle to a texture view. /// -/// A `TextureView` object describes a texture and associated metadata needed by a -/// [`RenderPipeline`] or [`BindGroup`]. +/// A `TextureView` object refers to a [`Texture`], or a subset of its layers and mip levels, and +/// specifies an interpretation of the texture’s texels, which is needed to use a texture as a +/// binding in a [`BindGroup`] or as an attachment in a [`RenderPass`]. +/// It can be created using [`Texture::create_view()`], which accepts a [`TextureViewDescriptor`] +/// specifying the properties of the view. /// /// Corresponds to [WebGPU `GPUTextureView`](https://gpuweb.github.io/gpuweb/#gputextureview). #[derive(Debug, Clone)]