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

Use any available vsync present mode #1035

Merged
merged 3 commits into from
Sep 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
29 changes: 21 additions & 8 deletions crates/fj-viewer/src/graphics/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl Renderer {
format: color_format,
width,
height,
present_mode: wgpu::PresentMode::Mailbox,
present_mode: wgpu::PresentMode::AutoVsync,
};
surface.configure(&device, &surface_config);

Expand Down Expand Up @@ -324,7 +324,20 @@ impl Renderer {
bytemuck::cast_slice(&[uniforms]),
);

let surface_texture = self.surface.get_current_texture()?;
let surface_texture = match self.surface.get_current_texture() {
Ok(surface_texture) => surface_texture,
Err(wgpu::SurfaceError::Timeout) => {
// I'm seeing this all the time now (as in, multiple times per
// microsecond), which `PresentMode::AutoVsync`. Not sure what's
// going on, but for now, it works to just ignore it.
//
// Issues for reference:
// - https://github.com/gfx-rs/wgpu/issues/1218
// - https://github.com/gfx-rs/wgpu/issues/1565
return Ok(());
}
result => result?,
};
let color_view = surface_texture
.texture
.create_view(&wgpu::TextureViewDescriptor::default());
Expand Down Expand Up @@ -669,24 +682,24 @@ impl Renderer {
/// Error describing the set of render surface initialization errors
#[derive(Error, Debug)]
pub enum InitError {
#[error("I/O error: {0}")]
/// General IO error
#[error("I/O error: {0}")]
Io(#[from] io::Error),

#[error("Error request adapter")]
/// Graphics accelerator acquisition error
#[error("Error request adapter")]
RequestAdapter,

#[error("Error requesting device: {0}")]
/// Device request errors
///
/// See: [wgpu::RequestDeviceError](https://docs.rs/wgpu/latest/wgpu/struct.RequestDeviceError.html)
#[error("Error requesting device: {0}")]
RequestDevice(#[from] wgpu::RequestDeviceError),

#[error("Error loading font: {0}")]
/// Error loading font
///
/// See: [ab_glyph::InvalidFont](https://docs.rs/ab_glyph/latest/ab_glyph/struct.InvalidFont.html)
#[error("Error loading font: {0}")]
InvalidFont(#[from] InvalidFont),
}

Expand All @@ -695,14 +708,14 @@ pub enum InitError {
/// Describes errors related to non initialization graphics errors.
#[derive(Error, Debug)]
pub enum DrawError {
#[error("Error acquiring output surface: {0}")]
/// Surface drawing error.
///
/// See - [wgpu::SurfaceError](https://docs.rs/wgpu/latest/wgpu/enum.SurfaceError.html)
#[error("Error acquiring output surface: {0}")]
Surface(#[from] wgpu::SurfaceError),

#[error("Error drawing text: {0}")]
/// Text rasterisation error.
#[error("Error drawing text: {0}")]
Text(String),
}

Expand Down