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

Store and check adapter features before using them #902

Merged
merged 1 commit into from
Aug 2, 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
41 changes: 25 additions & 16 deletions crates/fj-viewer/src/graphics/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl std::fmt::Debug for EguiState {
#[derive(Debug)]
pub struct Renderer {
surface: wgpu::Surface,
features: wgpu::Features,
device: wgpu::Device,
queue: wgpu::Queue,

Expand Down Expand Up @@ -134,6 +135,8 @@ impl Renderer {
.await
.ok_or(InitError::RequestAdapter)?;

let features = adapter.features();

let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
Expand All @@ -144,7 +147,7 @@ impl Renderer {
//
// See this issue:
// https://github.com/hannobraun/fornjot/issues/33
features: wgpu::Features::POLYGON_MODE_LINE,
features,
limits: wgpu::Limits::default(),
},
None,
Expand Down Expand Up @@ -239,6 +242,7 @@ impl Renderer {

Ok(Self {
surface,
features,
device,
queue,

Expand Down Expand Up @@ -328,21 +332,26 @@ impl Renderer {
&self.bind_group,
);
}
if config.draw_mesh {
drawables.mesh.draw(
&mut encoder,
&color_view,
&self.depth_view,
&self.bind_group,
);
}
if config.draw_debug {
drawables.lines.draw(
&mut encoder,
&color_view,
&self.depth_view,
&self.bind_group,
);

// NOTE: This does not inform the user if the renderer cannot
// use the POLYGON_MODE_LINE feature.
if self.features.contains(wgpu::Features::POLYGON_MODE_LINE) {
if config.draw_mesh {
drawables.mesh.draw(
&mut encoder,
&color_view,
&self.depth_view,
&self.bind_group,
);
}
if config.draw_debug {
drawables.lines.draw(
&mut encoder,
&color_view,
&self.depth_view,
&self.bind_group,
);
}
}

if self.egui.options.show_original_ui {
Expand Down