driver: optimize the step_multiple step count calculation

this was using a stupid amount of compute.
we still have about 7% time unaccounted for. down from 12-15%.
This commit is contained in:
2022-08-22 01:07:27 -07:00
parent e5c8bcff95
commit 82af4b100d
2 changed files with 29 additions and 14 deletions

View File

@@ -535,6 +535,14 @@ impl<S> MultiRendererElement<S> {
Some(end) => frame < end,
}
}
fn next_frame_for_work(&self, after: u64) -> Option<u64> {
let max_frame = after + self.step_frequency;
let max_frame = max_frame - max_frame % self.step_frequency;
match self.step_limit {
None => Some(max_frame),
Some(end) => Some(max_frame).filter(|&f| f < end)
}
}
}
pub struct MultiRenderer<S> {
@@ -567,6 +575,9 @@ impl<S> MultiRenderer<S> {
pub fn any_work_for_frame(&self, frame: u64) -> bool {
self.renderers.read().unwrap().iter().any(|m| m.work_this_frame(frame))
}
pub fn next_frame_for_work(&self, after: u64) -> Option<u64> {
self.renderers.read().unwrap().iter().flat_map(|m| m.next_frame_for_work(after)).min()
}
}
impl<S: AbstractSim> Renderer<S> for MultiRenderer<S> {