Skip to content

Commit

Permalink
Appease clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
LeshaInc committed Jul 12, 2023
1 parent 2137782 commit 3411d46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_render/src/renderer/graph_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl RenderGraphRunner {
}

let render_statistics_mutex = world.resource::<RenderStatisticsMutex>().0.clone();
render_context.download_statistics(&queue, move |statistics| {
render_context.download_statistics(queue, move |statistics| {
*render_statistics_mutex.lock() = Some(statistics);
});

Expand Down
31 changes: 14 additions & 17 deletions crates/bevy_render/src/renderer/statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,21 +210,18 @@ impl StatisticsRecorder {
let statistics = pass_records.into_iter().map(|(name, record)| {
let mut statistics = RenderPassStatistics::default();

statistics.elapsed_cpu = match (record.begin_instant, record.end_instant) {
(Some(begin), Some(end)) => Some(end - begin),
_ => None,
};

statistics.elapsed_gpu =
match (record.begin_timestamp_index, record.end_timestamp_index) {
(Some(begin), Some(end)) => {
let begin = timestamps[begin as usize] as f64;
let end = timestamps[end as usize] as f64;
let nanos = ((end - begin) * (timestamp_period as f64)).round() as u64;
Some(Duration::from_nanos(nanos))
}
_ => None,
};
if let (Some(begin), Some(end)) = (record.begin_instant, record.end_instant) {
statistics.elapsed_cpu = Some(end - begin);
}

if let (Some(begin), Some(end)) =
(record.begin_timestamp_index, record.end_timestamp_index)
{
let begin = timestamps[begin as usize] as f64;
let end = timestamps[end as usize] as f64;
let nanos = ((end - begin) * (timestamp_period as f64)).round() as u64;
statistics.elapsed_gpu = Some(Duration::from_nanos(nanos))
}

if let Some(index) = record.pipeline_statistics_index {
let index = (index as usize) * 5;
Expand Down Expand Up @@ -261,7 +258,7 @@ impl MeasuredRenderPass<'_> {
let mut render_pass = encoder.begin_render_pass(&desc);

if let Some(name) = &name {
recorder.begin_render_pass(&mut render_pass, name)
recorder.begin_render_pass(&mut render_pass, name);
}

MeasuredRenderPass {
Expand All @@ -279,7 +276,7 @@ impl Drop for MeasuredRenderPass<'_> {
}

if let Some(name) = &self.name {
self.recorder.end_render_pass(&mut self.render_pass, &name)
self.recorder.end_render_pass(&mut self.render_pass, name);
}
}
}
Expand Down

0 comments on commit 3411d46

Please sign in to comment.