render: Reset buffers after non-space-tracked rendering
This commit is contained in:
parent
81374ed282
commit
969cc8dae5
4 changed files with 51 additions and 6 deletions
|
|
@ -35,15 +35,25 @@ pub struct WinitState {
|
|||
backend: Rc<RefCell<WinitGraphicsBackend>>,
|
||||
//_global: GlobalDrop<WlOutput>,
|
||||
output: Output,
|
||||
age_reset: u8,
|
||||
#[cfg(feature = "debug")]
|
||||
fps: Fps,
|
||||
}
|
||||
|
||||
impl WinitState {
|
||||
pub fn render_output(&mut self, state: &mut Common) -> Result<()> {
|
||||
if render::needs_buffer_reset(&self.output, state) {
|
||||
self.reset_buffers();
|
||||
}
|
||||
|
||||
let backend = &mut *self.backend.borrow_mut();
|
||||
backend.bind().with_context(|| "Failed to bind buffer")?;
|
||||
let age = backend.buffer_age().unwrap_or(0);
|
||||
let age = if self.age_reset > 0 {
|
||||
self.age_reset -= 1;
|
||||
0
|
||||
} else {
|
||||
backend.buffer_age().unwrap_or(0)
|
||||
};
|
||||
|
||||
match render::render_output(
|
||||
None,
|
||||
|
|
@ -98,6 +108,10 @@ impl WinitState {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset_buffers(&mut self) {
|
||||
self.age_reset = 3;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Result<()> {
|
||||
|
|
@ -186,6 +200,7 @@ pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Res
|
|||
output: output.clone(),
|
||||
#[cfg(feature = "debug")]
|
||||
fps: Fps::default(),
|
||||
age_reset: 0,
|
||||
});
|
||||
state.common.output_conf.add_heads(std::iter::once(&output));
|
||||
state
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue