From 5fdf36dbb1e842f87abda0ea9cac50f95978df7a Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Sun, 16 Aug 2020 01:11:17 -0700 Subject: [PATCH] add optional wgpu tracing feature --- Cargo.toml | 1 + crates/bevy_wgpu/Cargo.toml | 1 + crates/bevy_wgpu/src/wgpu_renderer.rs | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 179c075e87..cb5fbf4d54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ exclude = ["assets/**/*", "tools/**/*", ".github/**/*", "crates/**/*"] [features] default = ["bevy_audio", "bevy_gltf", "bevy_wgpu", "bevy_winit", "png", "hdr", "mp3"] profiler = ["bevy_ecs/profiler", "bevy_diagnostic/profiler"] +wgpu_trace = ["bevy_wgpu/trace"] # Image format support for texture loading (PNG and HDR are enabled by default) png = ["bevy_render/png"] diff --git a/crates/bevy_wgpu/Cargo.toml b/crates/bevy_wgpu/Cargo.toml index 4d5eb8dbbd..11a9807aa6 100644 --- a/crates/bevy_wgpu/Cargo.toml +++ b/crates/bevy_wgpu/Cargo.toml @@ -11,6 +11,7 @@ keywords = ["bevy"] [features] default = ["bevy_winit"] +trace = ["wgpu/trace"] [dependencies] # bevy diff --git a/crates/bevy_wgpu/src/wgpu_renderer.rs b/crates/bevy_wgpu/src/wgpu_renderer.rs index 06837ca039..11da00a263 100644 --- a/crates/bevy_wgpu/src/wgpu_renderer.rs +++ b/crates/bevy_wgpu/src/wgpu_renderer.rs @@ -27,6 +27,11 @@ impl WgpuRenderer { .await .expect("Unable to find a GPU! Make sure you have installed required drivers!"); + #[cfg(feature = "trace")] + let trace_path = Some(std::path::Path::new("wgpu_trace")); + #[cfg(not(feature = "trace"))] + let trace_path = None; + let (device, queue) = adapter .request_device( &wgpu::DeviceDescriptor { @@ -34,7 +39,7 @@ impl WgpuRenderer { limits: wgpu::Limits::default(), shader_validation: true, }, - None, + trace_path, ) .await .unwrap();