target views

deferred
mitchellhansen 4 years ago
parent bd2e2557b8
commit 8cc76b7052

@ -326,7 +326,7 @@ impl RenderState {
mapped_at_creation: false, mapped_at_creation: false,
}); });
// Pretty sure this is the camera projction // Uniform bind group for the view matrix
let bind_group_layout = let bind_group_layout =
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("g-buffer input pass bindgroup layout (cam)"), label: Some("g-buffer input pass bindgroup layout (cam)"),
@ -372,7 +372,7 @@ impl RenderState {
}); });
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("shadow"), label: Some("g-buffer"),
layout: Some(&pipeline_layout), layout: Some(&pipeline_layout),
vertex: VertexState { vertex: VertexState {
@ -447,14 +447,6 @@ impl RenderState {
mapped_at_creation: false, mapped_at_creation: false,
}); });
// Holds the shadow uniforms, which is just a 4 vec of quaternians
let g_buffer = device.create_buffer(&wgpu::BufferDescriptor {
label: Some("shadow_pass_g_buffer"),
size: uniform_size,
usage: wgpu::BufferUsage::STORAGE | wgpu::BufferUsage::COPY_DST,
mapped_at_creation: false,
});
// Create bind group // Create bind group
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &bind_group_layout, layout: &bind_group_layout,
@ -778,7 +770,8 @@ impl RenderState {
label: Some("g-buffer depth texture"), label: Some("g-buffer depth texture"),
}); });
let mut g_buffer_depth_texture_views = (0..2) // 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| { .map(|i| {
Arc::new(shadow_texture.create_view(&wgpu::TextureViewDescriptor { Arc::new(shadow_texture.create_view(&wgpu::TextureViewDescriptor {
label: Some("g-buffer depth texture"), label: Some("g-buffer depth texture"),

@ -1,30 +1,30 @@
use std::{iter, num::NonZeroU32, ops::Range, rc::Rc};
use std::cell::RefCell; use std::cell::RefCell;
use std::iter::Chain; use std::iter::Chain;
use std::slice::Iter; use std::slice::Iter;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::thread::current; use std::thread::current;
use std::time::Duration; use std::time::Duration;
use std::{iter, num::NonZeroU32, ops::Range, rc::Rc};
use bytemuck::__core::mem;
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use bytemuck::__core::mem;
use cgmath::{ use cgmath::{
vec3, Decomposed, Deg, Euler, InnerSpace, Matrix4, Point3, Quaternion, Rad, Rotation3, Decomposed, Deg, Euler, InnerSpace, Matrix4, Point3, Quaternion, Rad, Rotation3, Transform,
Transform, Vector3, vec3, Vector3,
}; };
use futures::executor::LocalPool; use futures::executor::LocalPool;
use imgui::sys::ImGuiContext;
use imgui::*; use imgui::*;
use imgui::sys::ImGuiContext;
use imgui_wgpu::{Renderer as ImguiRenderer, RendererConfig as ImguiRendererConfig}; use imgui_wgpu::{Renderer as ImguiRenderer, RendererConfig as ImguiRendererConfig};
use legion::world::SubWorld;
use legion::*; use legion::*;
use legion::world::SubWorld;
use rapier3d::parry::motion::RigidMotionComposition; use rapier3d::parry::motion::RigidMotionComposition;
use wgpu::util::DeviceExt;
use wgpu::{ use wgpu::{
BackendBit, BindGroup, BindGroupLayout, Buffer, BufferBindingType, CommandEncoder, Device, BackendBit, BindGroup, BindGroupLayout, Buffer, BufferBindingType, CommandEncoder, Device,
FragmentState, Instance, Queue, Surface, SwapChain, SwapChainDescriptor, SwapChainFrame, FragmentState, Instance, Queue, Surface, SwapChain, SwapChainDescriptor, SwapChainFrame,
TextureView, VertexState, TextureView, VertexState,
}; };
use wgpu::util::DeviceExt;
use winit_24::dpi::PhysicalSize; use winit_24::dpi::PhysicalSize;
use winit_24::platform::unix::x11::ffi::Time; use winit_24::platform::unix::x11::ffi::Time;
use winit_24::window::Window; use winit_24::window::Window;
@ -35,8 +35,8 @@ use crate::current_ui;
use crate::geometry::{load_obj, Vertex}; use crate::geometry::{load_obj, Vertex};
use crate::imgui_supp::imgui_support::{ImguiContext, ImguiPlatform}; use crate::imgui_supp::imgui_support::{ImguiContext, ImguiPlatform};
use crate::light::{DirectionalLight, LightRaw}; use crate::light::{DirectionalLight, LightRaw};
use crate::render::{EntityUniforms, ForwardUniforms, insert_debug_marker_checked, pop_debug_group_checked, push_debug_group_checked};
use crate::render::state::RenderState; use crate::render::state::RenderState;
use crate::render::{insert_debug_marker_checked, pop_debug_group_checked, push_debug_group_checked, EntityUniforms, ForwardUniforms};
#[system] #[system]
#[write_component(Camera)] #[write_component(Camera)]
@ -79,6 +79,7 @@ fn run_imgui_render_step<G: 'static + Sized + Send + Sync>(world: &mut SubWorld,
.build(&ui, || (window_func.unwrap())(ui, v)); .build(&ui, || (window_func.unwrap())(ui, v));
} }
} }
/// Go through each "global" window-data component and render it's data /// Go through each "global" window-data component and render it's data
#[system] #[system]
#[write_component(ImguiWindow < ImguiPerformanceProfilerLine >)] #[write_component(ImguiWindow < ImguiPerformanceProfilerLine >)]
@ -256,9 +257,24 @@ pub fn render_test(
// top of the shadow texture. So the attachment is a RW buffer which clears on load // top of the shadow texture. So the attachment is a RW buffer which clears on load
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("render pass"), label: Some("render pass"),
color_attachments: &[], color_attachments: &[
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachmentDescriptor { wgpu::RenderPassColorAttachmentDescriptor {
attachment: &renderer.gbuffer_target_views.get(0).unwrap(), attachment: &renderer.gbuffer_target_views.get(0).unwrap(),
resolve_target: None,
ops: Default::default(),
},
wgpu::RenderPassColorAttachmentDescriptor {
attachment: &renderer.gbuffer_target_views.get(1).unwrap(),
resolve_target: None,
ops: Default::default(),
},
wgpu::RenderPassColorAttachmentDescriptor {
attachment: &renderer.gbuffer_target_views.get(2).unwrap(),
resolve_target: None,
ops: Default::default(),
}],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachmentDescriptor {
attachment: &renderer.gbuffer_target_views.get(3).unwrap(),
depth_ops: Some(wgpu::Operations { depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0), load: wgpu::LoadOp::Clear(1.0),
store: true, store: true,
@ -266,16 +282,17 @@ pub fn render_test(
stencil_ops: None, stencil_ops: None,
}), }),
}); });
pass.set_pipeline(&renderer.shadow_pass.pipeline);
pass.set_bind_group(0, &renderer.shadow_pass.bind_group, &[]);
for mesh in &mesh_stack { pass.set_pipeline(&renderer.gbuffer_pass.pipeline);
pass.set_bind_group(1, &mesh.bind_group, &[]); pass.set_bind_group(0, &renderer.gbuffer_pass.bind_group, &[]);
// TODO, pipe through this index format through the mesh
pass.set_index_buffer(mesh.index_buffer.slice(..), mesh.index_format); // for mesh in &mesh_stack {
pass.set_vertex_buffer(0, mesh.vertex_buffer.slice(..)); // pass.set_bind_group(1, &mesh.bind_group, &[]);
pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1); // // TODO, pipe through this index format through the mesh
} // pass.set_index_buffer(mesh.index_buffer.slice(..), mesh.index_format);
// pass.set_vertex_buffer(0, mesh.vertex_buffer.slice(..));
// pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1);
// }
} }
pop_debug_group_checked(&mut encoder); pop_debug_group_checked(&mut encoder);

Loading…
Cancel
Save