From 3a131f5f60f285aa3a570db4cb2f3fff45573074 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Tue, 16 Mar 2021 13:13:41 -0400 Subject: [PATCH] [rs] Move from `tracing` to `log` + `profiling` --- wgpu/Cargo.toml | 16 ++++++++-------- wgpu/examples/capture/main.rs | 2 +- wgpu/examples/framework.rs | 5 +---- wgpu/examples/hello-compute/main.rs | 2 +- wgpu/examples/hello-triangle/main.rs | 2 +- wgpu/examples/hello-windows/main.rs | 2 +- wgpu/examples/hello/main.rs | 2 +- wgpu/src/backend/direct.rs | 14 +++++++------- wgpu/src/util/belt.rs | 4 ++-- 9 files changed, 23 insertions(+), 26 deletions(-) diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 5ecb007aaf..beef8c2e58 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -26,28 +26,28 @@ webgl = ["wgc"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "717c2d73e725c064a3c4696d6d7bdb428c9500b6" +rev = "2f3b398e3887a336c963c43e7954f94cae42dd31" features = ["raw-window-handle", "cross"] [target.'cfg(target_arch = "wasm32")'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "717c2d73e725c064a3c4696d6d7bdb428c9500b6" +rev = "2f3b398e3887a336c963c43e7954f94cae42dd31" features = ["raw-window-handle", "cross"] optional = true [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "717c2d73e725c064a3c4696d6d7bdb428c9500b6" +rev = "2f3b398e3887a336c963c43e7954f94cae42dd31" [dependencies] arrayvec = "0.5" parking_lot = "0.11" +profiling = { version = "0.1.10", default-features = false } # Need 0.1.10+ to avoid compliation error with proc macros off. raw-window-handle = "0.3" -smallvec = "1" -tracing = { version = "0.1", default-features = false, features = ["std"] } serde = { version = "1", features = ["derive"], optional = true } +smallvec = "1" [dev-dependencies] bytemuck = { version = "1.4", features = ["derive"] } @@ -63,18 +63,18 @@ winit = { version = "0.24", features = ["web-sys"] } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] async-executor = "1.0" pollster = "0.2" -wgpu-subscriber = "0.1" +env_logger = "0.8" # used to test all the example shaders [dev-dependencies.naga] git = "https://github.com/gfx-rs/naga" -tag = "gfx-14" +tag = "gfx-15" features = ["wgsl-in"] # used to generate SPIR-V for the Web target [target.'cfg(target_arch = "wasm32")'.dependencies.naga] git = "https://github.com/gfx-rs/naga" -tag = "gfx-14" +tag = "gfx-15" features = ["wgsl-in", "spv-out"] [[example]] diff --git a/wgpu/examples/capture/main.rs b/wgpu/examples/capture/main.rs index a1e9b21d30..330cb269f5 100644 --- a/wgpu/examples/capture/main.rs +++ b/wgpu/examples/capture/main.rs @@ -194,7 +194,7 @@ impl BufferDimensions { fn main() { #[cfg(not(target_arch = "wasm32"))] { - wgpu_subscriber::initialize_default_subscriber(None); + env_logger::init(); pollster::block_on(run("red.png")); } #[cfg(target_arch = "wasm32")] diff --git a/wgpu/examples/framework.rs b/wgpu/examples/framework.rs index a99d79ed07..c139027cd9 100644 --- a/wgpu/examples/framework.rs +++ b/wgpu/examples/framework.rs @@ -75,10 +75,7 @@ struct Setup { async fn setup(title: &str) -> Setup { #[cfg(not(target_arch = "wasm32"))] { - let chrome_tracing_dir = std::env::var("WGPU_CHROME_TRACE"); - wgpu_subscriber::initialize_default_subscriber( - chrome_tracing_dir.as_ref().map(std::path::Path::new).ok(), - ); + env_logger::init(); }; let event_loop = EventLoop::new(); diff --git a/wgpu/examples/hello-compute/main.rs b/wgpu/examples/hello-compute/main.rs index ad6c31c8dd..4e7f04dafd 100644 --- a/wgpu/examples/hello-compute/main.rs +++ b/wgpu/examples/hello-compute/main.rs @@ -191,7 +191,7 @@ async fn execute_gpu(numbers: Vec) -> Vec { fn main() { #[cfg(not(target_arch = "wasm32"))] { - wgpu_subscriber::initialize_default_subscriber(None); + env_logger::init(); pollster::block_on(run()); } #[cfg(target_arch = "wasm32")] diff --git a/wgpu/examples/hello-triangle/main.rs b/wgpu/examples/hello-triangle/main.rs index 960fdc5573..6ae9ea0f4e 100644 --- a/wgpu/examples/hello-triangle/main.rs +++ b/wgpu/examples/hello-triangle/main.rs @@ -131,7 +131,7 @@ fn main() { let window = winit::window::Window::new(&event_loop).unwrap(); #[cfg(not(target_arch = "wasm32"))] { - wgpu_subscriber::initialize_default_subscriber(None); + env_logger::init(); // Temporarily avoid srgb formats for the swapchain on the web pollster::block_on(run(event_loop, window)); } diff --git a/wgpu/examples/hello-windows/main.rs b/wgpu/examples/hello-windows/main.rs index d1ac37323d..68e584f1f2 100644 --- a/wgpu/examples/hello-windows/main.rs +++ b/wgpu/examples/hello-windows/main.rs @@ -191,7 +191,7 @@ fn main() { } } - wgpu_subscriber::initialize_default_subscriber(None); + env_logger::init(); // Temporarily avoid srgb formats for the swapchain on the web pollster::block_on(run(event_loop, viewports)); } diff --git a/wgpu/examples/hello/main.rs b/wgpu/examples/hello/main.rs index 705017be27..8ee08329e6 100644 --- a/wgpu/examples/hello/main.rs +++ b/wgpu/examples/hello/main.rs @@ -13,7 +13,7 @@ async fn run() { fn main() { #[cfg(not(target_arch = "wasm32"))] { - wgpu_subscriber::initialize_default_subscriber(None); + env_logger::init(); pollster::block_on(run()); } #[cfg(target_arch = "wasm32")] diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 4fa5563d6f..cc406a1e2e 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -397,7 +397,7 @@ mod pass_impl { &mut self, render_bundles: I, ) { - wgc::span!(_guard, TRACE, "RenderPass::execute_bundles wrapper"); + profiling::scope!("RenderPass::execute_bundles wrapper"); let temp_render_bundles = render_bundles.cloned().collect::>(); unsafe { wgpu_render_pass_execute_bundles( @@ -843,7 +843,7 @@ impl crate::Context for Context { device: &Self::DeviceId, desc: &BindGroupDescriptor, ) -> Self::BindGroupId { - wgc::span!(_guard, TRACE, "Device::create_bind_group wrapper"); + profiling::scope!("Device::create_bind_group wrapper"); use wgc::binding_model as bm; let mut arrayed_texture_views = Vec::new(); @@ -920,7 +920,7 @@ impl crate::Context for Context { device: &Self::DeviceId, desc: &PipelineLayoutDescriptor, ) -> Self::PipelineLayoutId { - wgc::span!(_guard, TRACE, "Device::create_pipeline_layout wrapper"); + profiling::scope!("Device::create_pipeline_layout wrapper"); // Limit is always less or equal to wgc::MAX_BIND_GROUPS, so this is always right // Guards following ArrayVec @@ -965,7 +965,7 @@ impl crate::Context for Context { device: &Self::DeviceId, desc: &RenderPipelineDescriptor, ) -> Self::RenderPipelineId { - wgc::span!(_guard, TRACE, "Device::create_render_pipeline wrapper"); + profiling::scope!("Device::create_render_pipeline wrapper"); use wgc::pipeline as pipe; let vertex_buffers: ArrayVec<[_; wgc::device::MAX_VERTEX_BUFFERS]> = desc @@ -1268,7 +1268,7 @@ impl crate::Context for Context { mode: MapMode, range: Range, ) -> Self::MapAsyncFuture { - wgc::span!(_guard, TRACE, "Buffer::buffer_map_async wrapper"); + profiling::scope!("Buffer::buffer_map_async wrapper"); let (future, completion) = native_gpu_future::new_gpu_future(); @@ -1313,7 +1313,7 @@ impl crate::Context for Context { sub_range.start, wgt::BufferSize::new(size) )) { - Ok(ptr) => BufferMappedRange { + Ok((ptr, size)) => BufferMappedRange { ptr, size: size as usize, }, @@ -1674,7 +1674,7 @@ impl crate::Context for Context { encoder: &Self::CommandEncoderId, desc: &crate::RenderPassDescriptor<'a, '_>, ) -> Self::RenderPassId { - wgc::span!(_guard, TRACE, "CommandEncoder::begin_render_pass wrapper"); + profiling::scope!("CommandEncoder::begin_render_pass wrapper"); let colors = desc .color_attachments .iter() diff --git a/wgpu/src/util/belt.rs b/wgpu/src/util/belt.rs index abaf03d844..fbdbf06950 100644 --- a/wgpu/src/util/belt.rs +++ b/wgpu/src/util/belt.rs @@ -113,7 +113,7 @@ impl StagingBelt { } else { let size = self.chunk_size.max(size.get()); #[cfg(not(target_arch = "wasm32"))] - wgc::span!(_guard, INFO, "Creating chunk of size {}", size); + profiling::scope!("Creating chunk of size {}"); Chunk { buffer: device.create_buffer(&BufferDescriptor { label: Some("staging"), @@ -149,7 +149,7 @@ impl StagingBelt { /// the GPU is done copying the data from them. pub fn finish(&mut self) { #[cfg(not(target_arch = "wasm32"))] - wgc::span!(_guard, DEBUG, "Finishing chunks"); + profiling::scope!("Finishing chunks"); for chunk in self.active_chunks.drain(..) { chunk.buffer.unmap();