From e9a01e15461d331c5b9c02dd9c563241efd74e38 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 3 Aug 2022 15:38:45 +0200 Subject: [PATCH 1/2] Remove obsolete comment --- crates/fj-viewer/src/graphics/renderer.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index e33acd19e..6dd58574e 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -141,12 +141,6 @@ impl Renderer { .request_device( &wgpu::DeviceDescriptor { label: None, - // Don't just blindly assume that we can request this - // feature. If it isn't available, that might cause a panic, - // or an error to be returned here. - // - // See this issue: - // https://github.com/hannobraun/fornjot/issues/33 features, limits: wgpu::Limits::default(), }, From 4664744fcf6cdeb13b1a6d4c7f8e7255d3bfce0a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 3 Aug 2022 15:44:01 +0200 Subject: [PATCH 2/2] Prevent accidental use of graphics features --- crates/fj-viewer/src/graphics/renderer.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index 6dd58574e..c73e6d0ee 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -135,7 +135,20 @@ impl Renderer { .await .ok_or(InitError::RequestAdapter)?; - let features = adapter.features(); + let features = { + let desired_features = wgpu::Features::POLYGON_MODE_LINE; + let available_features = adapter.features(); + + // By requesting the intersection of desired and available features, + // we ensure two things: + // + // 1. That requesting the device doesn't panic, which would happen + // if we requested unavailable features. + // 2. That a developer ends up accidentally using features that + // happen to be available on their machine, but that aren't + // necessarily available for all the users. + desired_features.intersection(available_features) + }; let (device, queue) = adapter .request_device(