Skip to content

Commit

Permalink
Merge pull request #1035 from hannobraun/present
Browse files Browse the repository at this point in the history
Use any availably vsync present mode
  • Loading branch information
hannobraun authored Sep 2, 2022
2 parents 83624cb + fb65e94 commit 3941fa9
Showing 1 changed file with 21 additions and 8 deletions.
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

0 comments on commit 3941fa9

Please sign in to comment.