Skip to main content

rustial_renderer_wgpu/gpu/
depth.rs

1//! Depth texture management.
2
3/// Create a depth texture for the given surface dimensions.
4pub fn create_depth_texture(device: &wgpu::Device, width: u32, height: u32) -> wgpu::TextureView {
5    let texture = device.create_texture(&wgpu::TextureDescriptor {
6        label: Some("rustial_depth"),
7        size: wgpu::Extent3d {
8            width: width.max(1),
9            height: height.max(1),
10            depth_or_array_layers: 1,
11        },
12        mip_level_count: 1,
13        sample_count: 1,
14        dimension: wgpu::TextureDimension::D2,
15        format: wgpu::TextureFormat::Depth32Float,
16        usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
17        view_formats: &[],
18    });
19    texture.create_view(&wgpu::TextureViewDescriptor::default())
20}
21
22/// The depth format used throughout the renderer.
23pub const DEPTH_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Depth32Float;