Added some additional ray tracing stats.

This commit is contained in:
Nathan Vegdahl 2019-06-29 09:20:04 +09:00
parent 14b16896ac
commit 5a53d7f6f6
3 changed files with 16 additions and 0 deletions

View File

@ -292,6 +292,11 @@ fn main() {
"\t\tTrace: {:.3}s",
ntime * rstats.trace_time
);
println!("\t\t\tRays traced: {}", rstats.ray_count);
println!(
"\t\t\tRays/sec: {}",
(rstats.ray_count as f64 / (ntime * rstats.trace_time) as f64) as u64
);
println!(
"\t\t\tTraversal: {:.3}s",
ntime * rstats.accel_traversal_time

View File

@ -42,6 +42,7 @@ pub struct RenderStats {
pub trace_time: f64,
pub accel_traversal_time: f64,
pub accel_node_visits: u64,
pub ray_count: u64,
pub initial_ray_generation_time: f64,
pub ray_generation_time: f64,
pub sample_writing_time: f64,
@ -54,6 +55,7 @@ impl RenderStats {
trace_time: 0.0,
accel_traversal_time: 0.0,
accel_node_visits: 0,
ray_count: 0,
initial_ray_generation_time: 0.0,
ray_generation_time: 0.0,
sample_writing_time: 0.0,
@ -65,6 +67,7 @@ impl RenderStats {
self.trace_time += other.trace_time;
self.accel_traversal_time += other.accel_traversal_time;
self.accel_node_visits += other.accel_node_visits;
self.ray_count += other.ray_count;
self.initial_ray_generation_time += other.initial_ray_generation_time;
self.ray_generation_time += other.ray_generation_time;
self.sample_writing_time += other.sample_writing_time;
@ -344,6 +347,7 @@ impl<'a> Renderer<'a> {
}
stats.total_time += total_timer.tick() as f64;
stats.ray_count = tracer.rays_traced();
ACCEL_TRAV_TIME.with(|att| {
stats.accel_traversal_time = att.get();
att.set(0.0);

View File

@ -13,6 +13,7 @@ use crate::{
};
pub struct Tracer<'a> {
ray_trace_count: u64,
ray_stack: RayStack,
inner: TracerInner<'a>,
}
@ -20,6 +21,7 @@ pub struct Tracer<'a> {
impl<'a> Tracer<'a> {
pub fn from_assembly(assembly: &'a Assembly) -> Tracer<'a> {
Tracer {
ray_trace_count: 0,
ray_stack: RayStack::new(),
inner: TracerInner {
root: assembly,
@ -30,8 +32,13 @@ impl<'a> Tracer<'a> {
}
pub fn trace<'b>(&'b mut self, rays: &mut RayBatch) -> &'b [SurfaceIntersection] {
self.ray_trace_count += rays.len() as u64;
self.inner.trace(rays, &mut self.ray_stack)
}
pub fn rays_traced(&self) -> u64 {
self.ray_trace_count
}
}
struct TracerInner<'a> {