Skip to content

Commit

Permalink
Link to linux_dependencies.md in the panic message when failing to …
Browse files Browse the repository at this point in the history
…detect a GPU (bevyengine#6261)

As suggested in bevyengine#6104, it would be nice to link directly to `linux_dependencies.md` file in the panic message when running on Linux. And when not compiling for Linux, we fall back to the old message.

Signed-off-by: Lena Milizé <me@lvmn.org>

# Objective

Resolves bevyengine#6104.

## Solution

Add link to `linux_dependencies.md` when compiling for Linux, and fall back to the old one when not.
  • Loading branch information
lovelymono authored and james7132 committed Oct 28, 2022
1 parent 0966207 commit a1c7de2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/bevy_render/src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ pub struct RenderTextureFormat(pub wgpu::TextureFormat);
#[derive(Resource, Clone, Deref, DerefMut)]
pub struct AvailableTextureFormats(pub Arc<Vec<wgpu::TextureFormat>>);

const GPU_NOT_FOUND_ERROR_MESSAGE: &str = if cfg!(target_os = "linux") {
"Unable to find a GPU! Make sure you have installed required drivers! For extra information, see: https://github.com/bevyengine/bevy/blob/latest/docs/linux_dependencies.md"
} else {
"Unable to find a GPU! Make sure you have installed required drivers!"
};

/// Initializes the renderer by retrieving and preparing the GPU instance, device and queue
/// for the specified backend.
pub async fn initialize_renderer(
Expand All @@ -128,7 +134,7 @@ pub async fn initialize_renderer(
let adapter = instance
.request_adapter(request_adapter_options)
.await
.expect("Unable to find a GPU! Make sure you have installed required drivers!");
.expect(GPU_NOT_FOUND_ERROR_MESSAGE);

let adapter_info = adapter.get_info();
info!("{:?}", adapter_info);
Expand Down

0 comments on commit a1c7de2

Please sign in to comment.