diff --git a/Cargo.toml b/Cargo.toml index 474058b45f447..16a933183d7e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -180,9 +180,6 @@ trace_tracy_memory = [ # Tracing support trace = ["bevy_internal/trace"] -# Save a trace of all wgpu calls -wgpu_trace = ["bevy_internal/wgpu_trace"] - # EXR image format support exr = ["bevy_internal/exr"] diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index 7505c8f0be369..424a1416beca2 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -24,7 +24,6 @@ trace = [ trace_chrome = ["bevy_log/tracing-chrome"] trace_tracy = ["bevy_render?/tracing-tracy", "bevy_log/tracing-tracy"] trace_tracy_memory = ["bevy_log/trace_tracy_memory"] -wgpu_trace = ["bevy_render/wgpu_trace"] detailed_trace = ["bevy_utils/detailed_trace"] sysinfo_plugin = ["bevy_diagnostic/sysinfo_plugin"] diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 9ebd06678bfc3..834fca03f102a 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -29,7 +29,6 @@ zstd = ["ruzstd"] trace = ["profiling"] tracing-tracy = [] -wgpu_trace = [] ci_limits = [] webgl = ["wgpu/webgl"] webgpu = ["wgpu/webgpu"] diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 478128f2198c3..582ad2d18150b 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -195,16 +195,6 @@ pub async fn initialize_renderer( ); } - #[cfg(feature = "wgpu_trace")] - let trace_path = { - let path = std::path::Path::new("wgpu_trace"); - // ignore potential error, wgpu will log it - let _ = std::fs::create_dir(path); - Some(path) - }; - #[cfg(not(feature = "wgpu_trace"))] - let trace_path = None; - // Maybe get features and limits based on what is supported by the adapter/backend let mut features = wgpu::Features::empty(); let mut limits = options.limits.clone(); @@ -357,7 +347,7 @@ pub async fn initialize_renderer( required_limits: limits, memory_hints: options.memory_hints.clone(), }, - trace_path, + options.trace_path.as_deref(), ) .await .unwrap(); diff --git a/crates/bevy_render/src/settings.rs b/crates/bevy_render/src/settings.rs index 1f9df24a78de5..7dbf016a8e4c2 100644 --- a/crates/bevy_render/src/settings.rs +++ b/crates/bevy_render/src/settings.rs @@ -1,7 +1,7 @@ use crate::renderer::{ RenderAdapter, RenderAdapterInfo, RenderDevice, RenderInstance, RenderQueue, }; -use std::borrow::Cow; +use std::{borrow::Cow, path::PathBuf}; pub use wgpu::{ Backends, Dx12Compiler, Features as WgpuFeatures, Gles3MinorVersion, InstanceFlags, @@ -52,6 +52,8 @@ pub struct WgpuSettings { pub instance_flags: InstanceFlags, /// This hints to the WGPU device about the preferred memory allocation strategy. pub memory_hints: MemoryHints, + /// The path to pass to wgpu for API call tracing. This only has an effect if wgpu's tracing functionality is enabled. + pub trace_path: Option, } impl Default for WgpuSettings { @@ -116,6 +118,7 @@ impl Default for WgpuSettings { gles3_minor_version, instance_flags, memory_hints: MemoryHints::default(), + trace_path: None, } } } diff --git a/docs/cargo_features.md b/docs/cargo_features.md index d2cbf06a23b64..c360c2eb8cfba 100644 --- a/docs/cargo_features.md +++ b/docs/cargo_features.md @@ -94,5 +94,4 @@ The default feature set enables most of the expected features of a game engine, |wayland|Wayland display server support| |webgpu|Enable support for WebGPU in Wasm. When enabled, this feature will override the `webgl2` feature and you won't be able to run Wasm builds with WebGL2, only with WebGPU.| |webp|WebP image format support| -|wgpu_trace|Save a trace of all wgpu calls| |zlib|For KTX2 supercompression| diff --git a/docs/debugging.md b/docs/debugging.md index f791e7d21b7d0..60ce21b918b97 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -13,6 +13,12 @@ When a suspected wgpu error occurs, you should capture a wgpu trace so that Bevy To capture a wgpu trace: -1. Create a new `wgpu_trace` folder in the root of your cargo workspace -2. Add the "wgpu_trace" feature to the bevy crate. (ex: `cargo run --example features wgpu_trace`) -3. Zip up the wgpu_trace folder and attach it to the relevant issue. New wgpu issues should generally be created [in the wgpu repository](https://github.com/gfx-rs/wgpu). Please include the wgpu revision in your bug reports. You can find the revision in the `Cargo.lock` file in your workspace. +1. Create a new folder in which to store your wgpu trace. +2. Pass the path to the folder you created for your wgpu trace to `bevy_render::RenderPlugin`, using the `render_creation` field. + * If you're manually creating the renderer resources, pass the path to wgpu when creating the `RenderDevice` and `RenderQueue`. + * Otherwise, pass the path to Bevy via the `trace_path` field in `bevy_render::settings::WgpuSettings`. +3. Add `wgpu = { version = "*", features = ["trace"]}` to your Cargo.toml. + * `version = "*"` tells Rust that this can be *any* version of the wgpu crate, so it will not try to pull in a different version of wgpu than what is already pulled in by Bevy. +4. Compile and run your application, performing any in-app actions necessary to replicate the wgpu error. + +Once you've captured a wgpu trace, zip up the folder and attach it to the relevant issue. New wgpu issues should generally be created [in the wgpu repository](https://github.com/gfx-rs/wgpu). Please include the wgpu revision in your bug reports. You can find the revision in the `Cargo.lock` file in your workspace.