From 07fb340ec4bfb43a5de20caec95fd7183d32a566 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 15 May 2020 17:49:16 -0400 Subject: [PATCH] [rs] Read WGPU_TRACE environment in the examples --- wgpu/examples/framework.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wgpu/examples/framework.rs b/wgpu/examples/framework.rs index aca4dc9bd7..7bf5f37ae9 100644 --- a/wgpu/examples/framework.rs +++ b/wgpu/examples/framework.rs @@ -70,6 +70,7 @@ async fn run_async(event_loop: EventLoop<()>, window: Window) { .await .unwrap(); + let trace_dir = std::env::var("WGPU_TRACE"); let (device, queue) = adapter .request_device( &wgpu::DeviceDescriptor { @@ -78,7 +79,14 @@ async fn run_async(event_loop: EventLoop<()>, window: Window) { }, limits: wgpu::Limits::default(), }, - Some(std::path::Path::new("trace")), + match trace_dir { + Ok(ref value) if !cfg!(feature = "trace") => { + log::error!("Unable to trace into {:?} without \"trace\" feature enabled!", value); + None + } + Ok(ref value) => Some(std::path::Path::new(value)), + Err(_) => None, + }, ) .await .unwrap();