|
|
@ -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,11 +79,12 @@ 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 >)]
|
|
|
|
#[write_component(ImguiPerformanceProfilerLine)]
|
|
|
|
#[write_component(ImguiPerformanceProfilerLine)]
|
|
|
|
#[write_component(ImguiWindow<ImguiGenericOutputLine>)]
|
|
|
|
#[write_component(ImguiWindow < ImguiGenericOutputLine >)]
|
|
|
|
#[write_component(ImguiGenericOutputLine)]
|
|
|
|
#[write_component(ImguiGenericOutputLine)]
|
|
|
|
pub fn render_imgui(world: &mut SubWorld, #[resource] loop_state: &mut LoopState) {
|
|
|
|
pub fn render_imgui(world: &mut SubWorld, #[resource] loop_state: &mut LoopState) {
|
|
|
|
let ui = unsafe { crate::current_ui().unwrap() };
|
|
|
|
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(Camera)]
|
|
|
|
#[write_component(Position)]
|
|
|
|
#[write_component(Position)]
|
|
|
|
#[write_component(ImguiPerformanceProfilerLine)]
|
|
|
|
#[write_component(ImguiPerformanceProfilerLine)]
|
|
|
|
#[write_component(Point3<f32>)]
|
|
|
|
#[write_component(Point3 < f32 >)]
|
|
|
|
#[write_component(Mesh)]
|
|
|
|
#[write_component(Mesh)]
|
|
|
|
#[write_component(DirectionalLight)]
|
|
|
|
#[write_component(DirectionalLight)]
|
|
|
|
pub fn render_test(
|
|
|
|
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
|
|
|
|
// 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: &[
|
|
|
|
|
|
|
|
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 {
|
|
|
|
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachmentDescriptor {
|
|
|
|
attachment: &renderer.gbuffer_target_views.get(0).unwrap(),
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|