|
|
|
@ -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<Arc<TextureView>>,
|
|
|
|
|
pub(in crate::render) gbuffer_target_texture: wgpu::TextureView,
|
|
|
|
|
pub(in crate::render) gbuffer_target_views: Vec<Arc<TextureView>>,
|
|
|
|
|
|
|
|
|
|
// 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::<Vec<_>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|