diff options
Diffstat (limited to 'client/src/scene_render.rs')
-rw-r--r-- | client/src/scene_render.rs | 52 |
1 files changed, 8 insertions, 44 deletions
diff --git a/client/src/scene_render.rs b/client/src/scene_render.rs index 9dc14d1..9aceaef 100644 --- a/client/src/scene_render.rs +++ b/client/src/scene_render.rs @@ -20,21 +20,19 @@ use weareshared::{packets::Resource, resources::Prefab, tree::SceneTree}; use wgpu::{ BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType, BlendState, Color, ColorTargetState, ColorWrites, CommandEncoder, CompareFunction, DepthBiasState, - DepthStencilState, Device, Extent3d, FragmentState, FrontFace, IndexFormat, LoadOp, - MultisampleState, Operations, PipelineCompilationOptions, PipelineLayoutDescriptor, - PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange, RenderPassColorAttachment, + DepthStencilState, Device, FragmentState, FrontFace, IndexFormat, LoadOp, MultisampleState, + Operations, PipelineCompilationOptions, PipelineLayoutDescriptor, PolygonMode, PrimitiveState, + PrimitiveTopology, PushConstantRange, RenderPassColorAttachment, RenderPassDepthStencilAttachment, RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor, SamplerBindingType, ShaderStages, StencilState, StoreOp, - TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, - TextureView, TextureViewDescriptor, TextureViewDimension, VertexAttribute, VertexBufferLayout, - VertexFormat, VertexState, VertexStepMode, include_wgsl, + TextureFormat, TextureSampleType, TextureView, TextureViewDimension, VertexAttribute, + VertexBufferLayout, VertexFormat, VertexState, VertexStepMode, include_wgsl, }; use crate::scene_prepare::{DemandMap, RPrefab}; pub struct ScenePipeline { pipeline: RenderPipeline, - depth: TextureView, } macro_rules! v_attr { @@ -55,22 +53,6 @@ impl ScenePipeline { pub fn new(device: &Device, format: TextureFormat) -> (Self, BindGroupLayout) { let module = device.create_shader_module(include_wgsl!("shader.wgsl")); - let depth = device.create_texture(&TextureDescriptor { - label: None, - size: Extent3d { - height: 256, - width: 256, - depth_or_array_layers: 1, - }, - mip_level_count: 1, - sample_count: 1, - dimension: TextureDimension::D2, - format: TextureFormat::Depth32Float, - usage: TextureUsages::RENDER_ATTACHMENT, - view_formats: &[], - }); - let depth = depth.create_view(&TextureViewDescriptor::default()); - let bind_group_layout = device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[ BindGroupLayoutEntry { @@ -137,32 +119,14 @@ impl ScenePipeline { multiview: None, cache: None, }); - (Self { pipeline, depth }, bind_group_layout) - } - - pub fn resize(&mut self, device: &Device, width: u32, height: u32) { - self.depth = device - .create_texture(&TextureDescriptor { - label: None, - size: Extent3d { - height, - width, - depth_or_array_layers: 1, - }, - mip_level_count: 1, - sample_count: 1, - dimension: TextureDimension::D2, - format: TextureFormat::Depth32Float, - usage: TextureUsages::RENDER_ATTACHMENT, - view_formats: &[], - }) - .create_view(&TextureViewDescriptor::default()); + (Self { pipeline }, bind_group_layout) } pub fn draw( &mut self, commands: &mut CommandEncoder, target: &TextureView, + depth: &TextureView, scene: &SceneTree, prefabs: &mut DemandMap<Resource<Prefab>, Arc<RPrefab>>, projection: Mat4, @@ -183,7 +147,7 @@ impl ScenePipeline { }, })], depth_stencil_attachment: Some(RenderPassDepthStencilAttachment { - view: &self.depth, + view: &depth, depth_ops: Some(Operations { load: LoadOp::Clear(1.), store: StoreOp::Store, |