target views
This commit is contained in:
@@ -326,7 +326,7 @@ impl RenderState {
|
||||
mapped_at_creation: false,
|
||||
});
|
||||
|
||||
// Pretty sure this is the camera projction
|
||||
// Uniform bind group for the view matrix
|
||||
let bind_group_layout =
|
||||
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: Some("g-buffer input pass bindgroup layout (cam)"),
|
||||
@@ -372,7 +372,7 @@ impl RenderState {
|
||||
});
|
||||
|
||||
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||
label: Some("shadow"),
|
||||
label: Some("g-buffer"),
|
||||
layout: Some(&pipeline_layout),
|
||||
|
||||
vertex: VertexState {
|
||||
@@ -447,14 +447,6 @@ impl RenderState {
|
||||
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
|
||||
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
layout: &bind_group_layout,
|
||||
@@ -778,7 +770,8 @@ impl RenderState {
|
||||
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| {
|
||||
Arc::new(shadow_texture.create_view(&wgpu::TextureViewDescriptor {
|
||||
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::iter::Chain;
|
||||
use std::slice::Iter;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread::current;
|
||||
use std::time::Duration;
|
||||
use std::{iter, num::NonZeroU32, ops::Range, rc::Rc};
|
||||
|
||||
use bytemuck::__core::mem;
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use bytemuck::__core::mem;
|
||||
use cgmath::{
|
||||
vec3, Decomposed, Deg, Euler, InnerSpace, Matrix4, Point3, Quaternion, Rad, Rotation3,
|
||||
Transform, Vector3,
|
||||
Decomposed, Deg, Euler, InnerSpace, Matrix4, Point3, Quaternion, Rad, Rotation3, Transform,
|
||||
vec3, Vector3,
|
||||
};
|
||||
use futures::executor::LocalPool;
|
||||
use imgui::sys::ImGuiContext;
|
||||
use imgui::*;
|
||||
use imgui::sys::ImGuiContext;
|
||||
use imgui_wgpu::{Renderer as ImguiRenderer, RendererConfig as ImguiRendererConfig};
|
||||
use legion::world::SubWorld;
|
||||
use legion::*;
|
||||
use legion::world::SubWorld;
|
||||
use rapier3d::parry::motion::RigidMotionComposition;
|
||||
use wgpu::util::DeviceExt;
|
||||
use wgpu::{
|
||||
BackendBit, BindGroup, BindGroupLayout, Buffer, BufferBindingType, CommandEncoder, Device,
|
||||
FragmentState, Instance, Queue, Surface, SwapChain, SwapChainDescriptor, SwapChainFrame,
|
||||
TextureView, VertexState,
|
||||
};
|
||||
use wgpu::util::DeviceExt;
|
||||
use winit_24::dpi::PhysicalSize;
|
||||
use winit_24::platform::unix::x11::ffi::Time;
|
||||
use winit_24::window::Window;
|
||||
@@ -35,8 +35,8 @@ use crate::current_ui;
|
||||
use crate::geometry::{load_obj, Vertex};
|
||||
use crate::imgui_supp::imgui_support::{ImguiContext, ImguiPlatform};
|
||||
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::{insert_debug_marker_checked, pop_debug_group_checked, push_debug_group_checked, EntityUniforms, ForwardUniforms};
|
||||
|
||||
#[system]
|
||||
#[write_component(Camera)]
|
||||
@@ -79,11 +79,12 @@ fn run_imgui_render_step<G: 'static + Sized + Send + Sync>(world: &mut SubWorld,
|
||||
.build(&ui, || (window_func.unwrap())(ui, v));
|
||||
}
|
||||
}
|
||||
|
||||
/// Go through each "global" window-data component and render it's data
|
||||
#[system]
|
||||
#[write_component(ImguiWindow<ImguiPerformanceProfilerLine>)]
|
||||
#[write_component(ImguiWindow < ImguiPerformanceProfilerLine >)]
|
||||
#[write_component(ImguiPerformanceProfilerLine)]
|
||||
#[write_component(ImguiWindow<ImguiGenericOutputLine>)]
|
||||
#[write_component(ImguiWindow < ImguiGenericOutputLine >)]
|
||||
#[write_component(ImguiGenericOutputLine)]
|
||||
pub fn render_imgui(world: &mut SubWorld, #[resource] loop_state: &mut LoopState) {
|
||||
let ui = unsafe { crate::current_ui().unwrap() };
|
||||
@@ -174,7 +175,7 @@ pub fn render_performance_flag(world: &mut SubWorld, #[resource] loop_state: &mu
|
||||
#[write_component(Camera)]
|
||||
#[write_component(Position)]
|
||||
#[write_component(ImguiPerformanceProfilerLine)]
|
||||
#[write_component(Point3<f32>)]
|
||||
#[write_component(Point3 < f32 >)]
|
||||
#[write_component(Mesh)]
|
||||
#[write_component(DirectionalLight)]
|
||||
pub fn render_test(
|
||||
@@ -256,9 +257,24 @@ pub fn render_test(
|
||||
// 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 {
|
||||
label: Some("render pass"),
|
||||
color_attachments: &[],
|
||||
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachmentDescriptor {
|
||||
color_attachments: &[
|
||||
wgpu::RenderPassColorAttachmentDescriptor {
|
||||
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 {
|
||||
load: wgpu::LoadOp::Clear(1.0),
|
||||
store: true,
|
||||
@@ -266,16 +282,17 @@ pub fn render_test(
|
||||
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_bind_group(1, &mesh.bind_group, &[]);
|
||||
// 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);
|
||||
}
|
||||
pass.set_pipeline(&renderer.gbuffer_pass.pipeline);
|
||||
pass.set_bind_group(0, &renderer.gbuffer_pass.bind_group, &[]);
|
||||
|
||||
// for mesh in &mesh_stack {
|
||||
// pass.set_bind_group(1, &mesh.bind_group, &[]);
|
||||
// // 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user