Skip to content

Commit d07a20a

Browse files
authored
Gate WireframePlugin behind WgpuFeatures::POLYGON_MODE_LINE | WgpuFeatures::PUSH_CONSTANTS (#20591)
# Objective - Fix #20537 by showing a better error ## Solution - Gate the plugin behind GPU features, following our existing patterns ## Testing Not tested. Please compile for web and see what happens when you try to use wireframes. I'm not sure if the systems in build() should also be moved to finish() after the feature check.
1 parent 3da4116 commit d07a20a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

crates/bevy_pbr/src/wireframe.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use bevy_render::{
4545
SetItemPipeline, TrackedRenderPass, ViewBinnedRenderPhases,
4646
},
4747
render_resource::*,
48-
renderer::RenderContext,
48+
renderer::{RenderContext, RenderDevice},
4949
sync_world::{MainEntity, MainEntityHashMap},
5050
view::{
5151
ExtractedView, NoIndirectDrawing, RenderVisibilityRanges, RenderVisibleEntities,
@@ -55,7 +55,7 @@ use bevy_render::{
5555
};
5656
use bevy_shader::Shader;
5757
use core::{hash::Hash, ops::Range};
58-
use tracing::error;
58+
use tracing::{error, warn};
5959

6060
/// A [`Plugin`] that draws wireframes.
6161
///
@@ -108,11 +108,23 @@ impl Plugin for WireframePlugin {
108108
.after(AssetEventSystems)
109109
.run_if(resource_exists::<WireframeConfig>),
110110
);
111+
}
111112

113+
fn finish(&self, app: &mut App) {
112114
let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
113115
return;
114116
};
115117

118+
let required_features = WgpuFeatures::POLYGON_MODE_LINE | WgpuFeatures::PUSH_CONSTANTS;
119+
let render_device = render_app.world().resource::<RenderDevice>();
120+
if !render_device.features().contains(required_features) {
121+
warn!(
122+
"WireframePlugin not loaded. GPU lacks support for required features: {:?}.",
123+
required_features
124+
);
125+
return;
126+
}
127+
116128
render_app
117129
.init_resource::<WireframeEntitySpecializationTicks>()
118130
.init_resource::<SpecializedWireframePipelineCache>()

0 commit comments

Comments
 (0)