Link to linux_dependencies.md in the panic message when failing to detect a GPU (#6261)

As suggested in #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 #6104.

## Solution

Add link to `linux_dependencies.md` when compiling for Linux, and fall back to the old one when not.
This commit is contained in:
Lena Milizé 2022-10-17 14:01:52 +00:00
parent f9c56b321d
commit 5878a62c3f

View file

@ -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(
@ -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);