Skip to main content

pebble/graphics/pipeline/
texture_view.rs

1/// A GPU texture view — what a [`ColorTarget`](crate::graphics::render::targets::ColorTarget)/
2/// [`DepthTarget`](crate::graphics::render::targets::DepthTarget) or a bind
3/// group entry actually points at. Build one via a texture's `get_view()` —
4/// for a standalone render target, `Texture::empty(w, h, format)`
5/// (`.with_sample_count(...)`/`.with_extra_usage(...)` for MSAA or extra
6/// usage flags) build_asset'd like any other [`Texture`](super::textures::Texture), then
7/// `GPUTexture::get_view(mip)` once it's uploaded.
8#[derive(Clone)]
9pub struct TextureView {
10    view: wgpu::TextureView,
11    _texture: wgpu::Texture,
12}
13
14impl TextureView {
15    pub(crate) fn raw(&self) -> &wgpu::TextureView {
16        &self.view
17    }
18
19    pub(crate) fn from_raw(view: wgpu::TextureView, texture: wgpu::Texture) -> Self {
20        Self { view, _texture: texture }
21    }
22}