|
|
|
@ -18,11 +18,7 @@ use legion::world::SubWorld;
|
|
|
|
|
use legion::*;
|
|
|
|
|
use rapier3d::parry::motion::RigidMotionComposition;
|
|
|
|
|
use wgpu::util::DeviceExt;
|
|
|
|
|
use wgpu::{
|
|
|
|
|
BackendBit, BindGroup, BindGroupLayout, Buffer, BufferBindingType, Device, FragmentState,
|
|
|
|
|
Instance, Queue, Surface, SwapChain, SwapChainDescriptor, SwapChainFrame, TextureView,
|
|
|
|
|
VertexState,
|
|
|
|
|
};
|
|
|
|
|
use wgpu::{BackendBit, BindGroup, BindGroupLayout, Buffer, BufferBindingType, Device, FragmentState, Instance, Queue, Surface, SwapChain, SwapChainDescriptor, SwapChainFrame, TextureView, VertexState, CommandEncoder};
|
|
|
|
|
use winit_24::dpi::PhysicalSize;
|
|
|
|
|
use winit_24::platform::unix::x11::ffi::Time;
|
|
|
|
|
use winit_24::window::Window;
|
|
|
|
@ -119,7 +115,8 @@ pub fn render_test(
|
|
|
|
|
let mut encoder = renderer
|
|
|
|
|
.device
|
|
|
|
|
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
|
|
|
|
|
encoder.push_debug_group("start render function");
|
|
|
|
|
push_debug_group_checked("start render function", &mut encoder);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let frame = renderer.get_current_frame();
|
|
|
|
|
|
|
|
|
@ -175,12 +172,13 @@ pub fn render_test(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
encoder.push_debug_group("shadow passes");
|
|
|
|
|
push_debug_group_checked("shadow passes", &mut encoder);
|
|
|
|
|
|
|
|
|
|
let mut query = <(&mut DirectionalLight, &mut Point3<f32>)>::query();
|
|
|
|
|
|
|
|
|
|
for (i, (light, pos)) in query.iter_mut(world).enumerate() {
|
|
|
|
|
encoder.insert_debug_marker(&format!("shadow pass {} (light at position {:?})", i, pos));
|
|
|
|
|
insert_debug_marker_checked(&format!("shadow pass {} (light at position {:?})", i, pos), &mut encoder);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The light uniform buffer already has the projection,
|
|
|
|
|
// let's just copy it over to the shadow uniform buffer.
|
|
|
|
@ -192,7 +190,8 @@ pub fn render_test(
|
|
|
|
|
64,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
encoder.insert_debug_marker("render entities");
|
|
|
|
|
insert_debug_marker_checked("render entities", &mut encoder);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
|
|
|
|
label: Some("render pass"),
|
|
|
|
@ -217,9 +216,10 @@ pub fn render_test(
|
|
|
|
|
pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
encoder.pop_debug_group();
|
|
|
|
|
pop_debug_group_checked(&mut encoder);
|
|
|
|
|
// forward pass
|
|
|
|
|
encoder.push_debug_group("forward rendering pass");
|
|
|
|
|
push_debug_group_checked("forward rendering pass", &mut encoder);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
|
|
|
|
label: Some("forward render pass"),
|
|
|
|
@ -258,8 +258,8 @@ pub fn render_test(
|
|
|
|
|
pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
encoder.pop_debug_group();
|
|
|
|
|
encoder.pop_debug_group();
|
|
|
|
|
pop_debug_group_checked(&mut encoder);
|
|
|
|
|
pop_debug_group_checked(&mut encoder);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
let mut imgui_context = &mut imgui_context.lock().unwrap().context;
|
|
|
|
@ -307,6 +307,27 @@ pub fn render_test(
|
|
|
|
|
|
|
|
|
|
renderer.queue.submit(iter::once(encoder.finish()));
|
|
|
|
|
}
|
|
|
|
|
lazy_static! {
|
|
|
|
|
static ref INTEL_DEBUG_SHINANIGANS : bool = std::env::var("INTEL_FIX").map_or(false, |a| true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn insert_debug_marker_checked(name: &str, command_encoder: &mut CommandEncoder) {
|
|
|
|
|
if !*INTEL_DEBUG_SHINANIGANS {
|
|
|
|
|
command_encoder.insert_debug_marker(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn push_debug_group_checked(name: &str, command_encoder: &mut CommandEncoder) {
|
|
|
|
|
if !*INTEL_DEBUG_SHINANIGANS {
|
|
|
|
|
command_encoder.push_debug_group(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn pop_debug_group_checked(command_encoder: &mut CommandEncoder) {
|
|
|
|
|
if !*INTEL_DEBUG_SHINANIGANS {
|
|
|
|
|
command_encoder.pop_debug_group();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct Renderer {
|
|
|
|
|
swapchain: SwapChain,
|
|
|
|
|