From 310d9f837e4e85a538f1f6701c8ff777467c8827 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Thu, 26 Mar 2026 09:36:07 -0700 Subject: [PATCH] graphics: need depth texture --- engine/graphics/src/graphics.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/engine/graphics/src/graphics.rs b/engine/graphics/src/graphics.rs index 741acee4..ab5d5b23 100644 --- a/engine/graphics/src/graphics.rs +++ b/engine/graphics/src/graphics.rs @@ -127,6 +127,7 @@ pub struct GraphicsState{ camera_buf:wgpu::Buffer, temp_squid_texture_view:wgpu::TextureView, models:Vec, + depth:wgpu::Texture, depth_view:wgpu::TextureView, staging_belt:wgpu::util::StagingBelt, model_instances_uniform_len:usize, @@ -137,8 +138,8 @@ impl GraphicsState{ fn create_depth_texture( size:glam::UVec2, device:&wgpu::Device, - )->wgpu::TextureView{ - let depth_texture=device.create_texture(&wgpu::TextureDescriptor{ + )->wgpu::Texture{ + device.create_texture(&wgpu::TextureDescriptor{ size:wgpu::Extent3d{ width:size.x, height:size.y, @@ -151,9 +152,10 @@ impl GraphicsState{ usage:wgpu::TextureUsages::RENDER_ATTACHMENT, label:None, view_formats:&[], - }); - - depth_texture.create_view(&wgpu::TextureViewDescriptor::default()) + }) + } + pub const fn depth_texture(&self)->&wgpu::Texture{ + &self.depth } pub const fn depth_texture_view(&self)->&wgpu::TextureView{ &self.depth_view @@ -881,7 +883,8 @@ impl GraphicsState{ label:Some("Sky Texture"), }); - let depth_view=Self::create_depth_texture(size,device); + let depth=Self::create_depth_texture(size,device); + let depth_view=depth.create_view(&wgpu::TextureViewDescriptor::default()); Self{ pipelines:GraphicsPipelines{ @@ -895,6 +898,7 @@ impl GraphicsState{ camera, camera_buf, models:Vec::new(), + depth, depth_view, staging_belt:wgpu::util::StagingBelt::new(device.clone(),0x100), bind_group_layouts:GraphicsBindGroupLayouts{model:model_bind_group_layout}, @@ -909,7 +913,8 @@ impl GraphicsState{ size:glam::UVec2, fov:glam::Vec2, ){ - self.depth_view=Self::create_depth_texture(size,device); + self.depth=Self::create_depth_texture(size,device); + self.depth_view=self.depth.create_view(&wgpu::TextureViewDescriptor::default()); self.camera.screen_size=size; self.camera.fov=fov; }