Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent accidental use of graphics features #909

Merged
merged 2 commits into from
Aug 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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