Skip to content

Commit

Permalink
Merge pull request #909 from hannobraun/features
Browse files Browse the repository at this point in the history
Prevent accidental use of graphics features
  • Loading branch information
hannobraun authored Aug 3, 2022
2 parents 0a6f259 + 4664744 commit e7d0a75
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions crates/fj-viewer/src/graphics/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,25 @@ 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(
&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(),
},
Expand Down

0 comments on commit e7d0a75

Please sign in to comment.