diff --git a/Cargo.toml b/Cargo.toml index ecf55d6..277784b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ wgpu-subscriber = "0.1.0" tobj = "2.0.3" gilrs = "0.8.0" gfx-backend-vulkan = { version = "0.6", features = ["x11"] } +lazy_static = "1.4.0" cgmath = "0.18.0" rapier3d = { version = "0.5.0", features = ["simd-nightly", "parallel"] } diff --git a/src/main.rs b/src/main.rs index d228e3b..f127969 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,8 @@ extern crate imgui; extern crate imgui_wgpu; extern crate tobj; extern crate winit_24; +#[macro_use] +extern crate lazy_static; use std::borrow::Borrow; use std::f32::consts::PI; diff --git a/src/render.rs b/src/render.rs index ae54d59..acec043 100644 --- a/src/render.rs +++ b/src/render.rs @@ -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)>::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,