Skip to content

Commit f8e165b

Browse files
msvbgmockersf
authored andcommitted
Print warning when using llvmpipe (#13780)
# Objective Numerous people have been confused that Bevy runs slowly, when the reason is that the `llvmpipe` software rendered is being used. ## Solution Printing a warning could reduce the confusion.
1 parent 4736fe0 commit f8e165b

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

crates/bevy_render/src/renderer/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod render_device;
33

44
use bevy_derive::{Deref, DerefMut};
55
use bevy_tasks::ComputeTaskPool;
6-
use bevy_utils::tracing::{error, info, info_span};
6+
use bevy_utils::tracing::{error, info, info_span, warn};
77
pub use graph_runner::*;
88
pub use render_device::*;
99

@@ -20,7 +20,8 @@ use bevy_time::TimeSender;
2020
use bevy_utils::Instant;
2121
use std::sync::Arc;
2222
use wgpu::{
23-
Adapter, AdapterInfo, CommandBuffer, CommandEncoder, Instance, Queue, RequestAdapterOptions,
23+
Adapter, AdapterInfo, CommandBuffer, CommandEncoder, DeviceType, Instance, Queue,
24+
RequestAdapterOptions,
2425
};
2526

2627
/// Updates the [`RenderGraph`] with all of its nodes and then runs it to render the entire frame.
@@ -187,6 +188,13 @@ pub async fn initialize_renderer(
187188
let adapter_info = adapter.get_info();
188189
info!("{:?}", adapter_info);
189190

191+
if adapter_info.device_type == DeviceType::Cpu {
192+
warn!(
193+
"The selected adapter is using the a driver that only supports software rendering. \
194+
This is likely to be very slow. See https://bevyengine.org/learn/errors/b0006/"
195+
);
196+
}
197+
190198
#[cfg(feature = "wgpu_trace")]
191199
let trace_path = {
192200
let path = std::path::Path::new("wgpu_trace");

errors/B0006.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# B0006
2+
3+
A runtime warning.
4+
5+
Bevy's renderer is designed to be used with hardware acceleration. When initializing the renderer, Bevy will print an `AdapterInfo` line. If the driver in the `AdapterInfo` is indicated to be a software renderer, then the driver does not support hardware acceleration and Bevy will most likely be slow.
6+
7+
## Possible solutions
8+
9+
- Update your graphics driver. Your driver could simply be outdated.
10+
- It is possible that the hardware itself is too old.
11+
- You could try using a different backend for the `RenderPlugin`, for example the OpenGL backend. However, please be aware that this could reduce the renderer's performance on other systems that don't have this problem. Here's an example of how to do this:
12+
13+
```rust
14+
fn main() {
15+
App::new()
16+
.add_plugins(
17+
DefaultPlugins.set(RenderPlugin {
18+
render_creation: WgpuSettings {
19+
backends: Some(Backends::GL),
20+
..default()
21+
}
22+
.into(),
23+
..default()
24+
}),
25+
)
26+
.run();
27+
}
28+
```
29+
30+
The backend can also be configured using environment variables, by setting `WGPU_BACKEND=[backend]` on Linux/Mac or `set WGPU_BACKEND=[backend]` on Windows, where `[backend]` is one of `vulkan`, `metal`, `dx12`, or `gl`.

0 commit comments

Comments
 (0)