From 5878a62c3ff7e54405bd0f42ad6d64af70e1a878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lena=20Miliz=C3=A9?= Date: Mon, 17 Oct 2022 14:01:52 +0000 Subject: [PATCH] Link to `linux_dependencies.md` in the panic message when failing to detect a GPU (#6261) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é # Objective Resolves #6104. ## Solution Add link to `linux_dependencies.md` when compiling for Linux, and fall back to the old one when not. --- crates/bevy_render/src/renderer/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 8d5110d9e4..941b04a266 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -112,6 +112,12 @@ pub struct RenderTextureFormat(pub wgpu::TextureFormat); #[derive(Resource, Clone, Deref, DerefMut)] pub struct AvailableTextureFormats(pub Arc>); +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);