|
|
|
@ -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,6 +79,7 @@ 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 >)]
|
|
|
|
@ -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);
|
|
|
|
|
|
|
|
|
|