From afc20a0efab20eb1b9ebc7a41e933bb4b116dc3c Mon Sep 17 00:00:00 2001 From: mitchellhansen Date: Thu, 18 Mar 2021 23:26:53 -0700 Subject: [PATCH] tweaks --- src/render/state.rs | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/render/state.rs b/src/render/state.rs index c32e4e5..281f1ed 100644 --- a/src/render/state.rs +++ b/src/render/state.rs @@ -67,7 +67,9 @@ pub struct RenderState { // Gbuffer bs pub(in crate::render) gbuffer_pass: Pass, pub(in crate::render) gbuffer_cam_projection_buffer: wgpu::Buffer, - pub(in crate::render) gbuffer_depth: wgpu::TextureView, + pub(in crate::render) gbuffer_depth_texture: wgpu::TextureView, + pub(in crate::render) gbuffer_depth_views: Vec>, + pub(in crate::render) gbuffer_target_texture: wgpu::TextureView, pub(in crate::render) gbuffer_target_views: Vec>, // this is for the set=1 entity uniforms @@ -884,6 +886,37 @@ impl RenderState { label: Some("Forward Depth Texture"), }); + let g_buffer_depth_texture = device.create_texture(&wgpu::TextureDescriptor { + size: wgpu::Extent3d { + width: sc_desc.width, + height: sc_desc.height, + depth: 5, + }, + mip_level_count: 1, + sample_count: 1, + dimension: wgpu::TextureDimension::D2, + format: Self::DEPTH_FORMAT, + usage: wgpu::TextureUsage::RENDER_ATTACHMENT | wgpu::TextureUsage::SAMPLED, + label: Some("g-buffer depth texture"), + }); + + // I need one of these for each of the g-buffer elements I'm calculating + let mut g_buffer_depth_texture_views = (0..4) + .map(|i| { + Arc::new(g_buffer_depth_texture.create_view(&wgpu::TextureViewDescriptor { + label: Some("g-buffer depth texture"), + format: None, + dimension: Some(wgpu::TextureViewDimension::D2), + aspect: wgpu::TextureAspect::All, + base_mip_level: 0, + level_count: None, + base_array_layer: i as u32, + array_layer_count: NonZeroU32::new(1), + })) + }) + .collect::>(); + + let g_buffer_depth_texture = device.create_texture(&wgpu::TextureDescriptor { size: wgpu::Extent3d { width: sc_desc.width, @@ -925,7 +958,7 @@ impl RenderState { RenderState { gbuffer_pass: g_buffer_pass, gbuffer_cam_projection_buffer: g_buffer_camera_projection_uniform, - gbuffer_depth: g_buffer_depth_texture.create_view(&wgpu::TextureViewDescriptor::default()), + gbuffer_depth_texture: g_buffer_depth_texture.create_view(&wgpu::TextureViewDescriptor::default()), gbuffer_target_views: g_buffer_depth_texture_views, swapchain: swap_chain,