Skip to content

Commit

Permalink
remove fixme and invalid render flag
Browse files Browse the repository at this point in the history
  • Loading branch information
0123456789-jpg committed Feb 23, 2024
1 parent d901d0a commit cefbd7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
14 changes: 6 additions & 8 deletions crates/flare3d/examples/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ fn main() {
state.resize(physical_size);
}
WindowEvent::RedrawRequested => {
if state.do_render() {
state.update();
match state.render() {
Ok(_) => {}
Err(wgpu::SurfaceError::Lost) => state.resize(state.size),
Err(wgpu::SurfaceError::OutOfMemory) => target.exit(),
Err(e) => eprintln!("{:?}", e),
}
state.update();
match state.render() {
Ok(_) => {}
Err(wgpu::SurfaceError::Lost) => state.resize(state.size),
Err(wgpu::SurfaceError::OutOfMemory) => target.exit(),
Err(e) => eprintln!("{:?}", e),
}
}
_ => (),
Expand Down
27 changes: 4 additions & 23 deletions crates/flare3d/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,7 @@ pub struct State<'s> {
instances: Vec<Instance>,
instance_buffer: wgpu::Buffer,
depth_texture: Texture,
/// # FIXME
/// There is a memory leak when the window is occluded on the `Apple M1`
/// platform. This field will stop `request_render()` when the window is
/// occluded or not focused. It decreases the speed of memory leak, but
/// the problem still exists. Find more in the issue section of the
/// __gfx-rs/wgpu__ repository.
should_render: bool,

}

impl<'s> State<'s> {
Expand Down Expand Up @@ -598,7 +592,6 @@ impl<'s> State<'s> {
instances,
instance_buffer,
depth_texture,
should_render: false,
}
}
}
Expand Down Expand Up @@ -680,21 +673,9 @@ impl<'s> State<'s> {
}

pub fn input(&mut self, event: &WindowEvent) -> bool {
match event {
WindowEvent::Occluded(val) => {
self.should_render = *val;
true
}
WindowEvent::Focused(val) => {
self.should_render = !*val;
true
}
_ => self.camera_controller.process_events(event),
}
self.camera_controller.process_events(event)

}

#[inline]
pub fn do_render(&self) -> bool {
!self.should_render
}

}

0 comments on commit cefbd7d

Please sign in to comment.