From b01c606fbedcacb1e5002bb1958a38052ca99bc1 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Mon, 19 Apr 2021 21:38:42 +0200 Subject: [PATCH 1/2] Provide better error message when missing a render backend --- crates/bevy_render/src/lib.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 3f0ffe41efcbf..fbe6aaa8c7782 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -14,7 +14,7 @@ pub mod wireframe; use bevy_ecs::{ schedule::{ParallelSystemDescriptorCoercion, SystemStage}, - system::{IntoExclusiveSystem, IntoSystem}, + system::{IntoExclusiveSystem, IntoSystem, Res}, }; use bevy_transform::TransformSystem; use draw::{OutsideFrustum, Visible}; @@ -52,7 +52,7 @@ use render_graph::{ base::{self, BaseRenderGraphConfig, MainPass}, RenderGraph, }; -use renderer::{AssetRenderResourceBindings, RenderResourceBindings}; +use renderer::{AssetRenderResourceBindings, RenderResourceBindings, RenderResourceContext}; use shader::ShaderLoader; #[cfg(feature = "hdr")] use texture::HdrTextureLoader; @@ -160,6 +160,10 @@ impl Plugin for RenderPlugin { .init_resource::() .init_resource::() .init_resource::() + .add_startup_system_to_stage( + StartupStage::PreStartup, + check_for_render_resource_context.system(), + ) .add_system_to_stage(CoreStage::PreUpdate, draw::clear_draw_system.system()) .add_system_to_stage( CoreStage::PostUpdate, @@ -222,3 +226,9 @@ impl Plugin for RenderPlugin { } } } + +fn check_for_render_resource_context(context: Option>>) { + if context.is_none() { + panic!("bevy_render couldn't find a render backend. Try adding bevy_wgpu!") + } +} From e86cb6c80db4dbd959de0f31ec526e6c0ec85419 Mon Sep 17 00:00:00 2001 From: MinerSebas Date: Mon, 19 Apr 2021 23:17:25 +0200 Subject: [PATCH 2/2] Mention the bevy_wgpu plugin --- crates/bevy_render/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index fbe6aaa8c7782..1a9b293b95d9c 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -229,6 +229,8 @@ impl Plugin for RenderPlugin { fn check_for_render_resource_context(context: Option>>) { if context.is_none() { - panic!("bevy_render couldn't find a render backend. Try adding bevy_wgpu!") + panic!( + "bevy_render couldn't find a render backend. Perhaps try adding the bevy_wgpu plugin!" + ) } }