Instrument code to count ray/node tests during BVH traversal.
This commit is contained in:
parent
649a6a0869
commit
f371e0643a
|
@ -13,6 +13,7 @@ use timer::Timer;
|
||||||
|
|
||||||
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
||||||
use super::ACCEL_TRAV_TIME;
|
use super::ACCEL_TRAV_TIME;
|
||||||
|
use super::ACCEL_NODE_RAY_TESTS;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
@ -80,6 +81,7 @@ impl<'a> BVH<'a> {
|
||||||
|
|
||||||
let mut timer = Timer::new();
|
let mut timer = Timer::new();
|
||||||
let mut trav_time: f64 = 0.0;
|
let mut trav_time: f64 = 0.0;
|
||||||
|
let mut node_tests: u64 = 0;
|
||||||
|
|
||||||
let ray_sign = [
|
let ray_sign = [
|
||||||
rays[0].dir_inv.x() >= 0.0,
|
rays[0].dir_inv.x() >= 0.0,
|
||||||
|
@ -93,6 +95,7 @@ impl<'a> BVH<'a> {
|
||||||
let mut stack_ptr = 1;
|
let mut stack_ptr = 1;
|
||||||
|
|
||||||
while stack_ptr > 0 {
|
while stack_ptr > 0 {
|
||||||
|
node_tests += ray_i_stack[stack_ptr] as u64;
|
||||||
match node_stack[stack_ptr] {
|
match node_stack[stack_ptr] {
|
||||||
&BVHNode::Internal {
|
&BVHNode::Internal {
|
||||||
children,
|
children,
|
||||||
|
@ -152,6 +155,10 @@ impl<'a> BVH<'a> {
|
||||||
let v = att.get();
|
let v = att.get();
|
||||||
att.set(v + trav_time);
|
att.set(v + trav_time);
|
||||||
});
|
});
|
||||||
|
ACCEL_NODE_RAY_TESTS.with(|anv| {
|
||||||
|
let v = anv.get();
|
||||||
|
anv.set(v + node_tests);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn construct_from_base(
|
fn construct_from_base(
|
||||||
|
|
|
@ -14,6 +14,7 @@ use timer::Timer;
|
||||||
use bvh_order::{TRAVERSAL_TABLE, SplitAxes, calc_traversal_code};
|
use bvh_order::{TRAVERSAL_TABLE, SplitAxes, calc_traversal_code};
|
||||||
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
||||||
use super::ACCEL_TRAV_TIME;
|
use super::ACCEL_TRAV_TIME;
|
||||||
|
use super::ACCEL_NODE_RAY_TESTS;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
@ -79,6 +80,7 @@ impl<'a> BVH4<'a> {
|
||||||
|
|
||||||
let mut timer = Timer::new();
|
let mut timer = Timer::new();
|
||||||
let mut trav_time: f64 = 0.0;
|
let mut trav_time: f64 = 0.0;
|
||||||
|
let mut node_tests: u64 = 0;
|
||||||
|
|
||||||
let traversal_table = {
|
let traversal_table = {
|
||||||
let ray_sign_is_neg = [
|
let ray_sign_is_neg = [
|
||||||
|
@ -97,6 +99,7 @@ impl<'a> BVH4<'a> {
|
||||||
let mut stack_ptr = 1;
|
let mut stack_ptr = 1;
|
||||||
|
|
||||||
while stack_ptr > 0 {
|
while stack_ptr > 0 {
|
||||||
|
node_tests += ray_i_stack[stack_ptr] as u64;
|
||||||
match node_stack[stack_ptr] {
|
match node_stack[stack_ptr] {
|
||||||
&BVH4Node::Inner {
|
&BVH4Node::Inner {
|
||||||
traversal_code,
|
traversal_code,
|
||||||
|
@ -195,6 +198,10 @@ impl<'a> BVH4<'a> {
|
||||||
let v = att.get();
|
let v = att.get();
|
||||||
att.set(v + trav_time);
|
att.set(v + trav_time);
|
||||||
});
|
});
|
||||||
|
ACCEL_NODE_RAY_TESTS.with(|anv| {
|
||||||
|
let v = anv.get();
|
||||||
|
anv.set(v + node_tests);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn construct_from_base(
|
fn construct_from_base(
|
||||||
|
|
|
@ -18,6 +18,7 @@ pub use self::light_array::LightArray;
|
||||||
// Track BVH traversal time
|
// Track BVH traversal time
|
||||||
thread_local! {
|
thread_local! {
|
||||||
pub static ACCEL_TRAV_TIME: Cell<f64> = Cell::new(0.0);
|
pub static ACCEL_TRAV_TIME: Cell<f64> = Cell::new(0.0);
|
||||||
|
pub static ACCEL_NODE_RAY_TESTS: Cell<u64> = Cell::new(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait LightAccel {
|
pub trait LightAccel {
|
||||||
|
|
|
@ -316,6 +316,7 @@ fn main() {
|
||||||
"\t\t\tTraversal: {:.3}s",
|
"\t\t\tTraversal: {:.3}s",
|
||||||
ntime * rstats.accel_traversal_time
|
ntime * rstats.accel_traversal_time
|
||||||
);
|
);
|
||||||
|
println!("\t\t\tRay/node tests: {}", rstats.accel_node_visits);
|
||||||
println!(
|
println!(
|
||||||
"\t\tInitial ray generation: {:.3}s",
|
"\t\tInitial ray generation: {:.3}s",
|
||||||
ntime * rstats.initial_ray_generation_time
|
ntime * rstats.initial_ray_generation_time
|
||||||
|
|
|
@ -10,7 +10,7 @@ use scoped_threadpool::Pool;
|
||||||
|
|
||||||
use halton;
|
use halton;
|
||||||
|
|
||||||
use accel::ACCEL_TRAV_TIME;
|
use accel::{ACCEL_TRAV_TIME, ACCEL_NODE_RAY_TESTS};
|
||||||
use algorithm::partition_pair;
|
use algorithm::partition_pair;
|
||||||
use color::{Color, XYZ, SpectralSample, map_0_1_to_wavelength};
|
use color::{Color, XYZ, SpectralSample, map_0_1_to_wavelength};
|
||||||
use float4::Float4;
|
use float4::Float4;
|
||||||
|
@ -40,6 +40,7 @@ pub struct Renderer<'a> {
|
||||||
pub struct RenderStats {
|
pub struct RenderStats {
|
||||||
pub trace_time: f64,
|
pub trace_time: f64,
|
||||||
pub accel_traversal_time: f64,
|
pub accel_traversal_time: f64,
|
||||||
|
pub accel_node_visits: u64,
|
||||||
pub initial_ray_generation_time: f64,
|
pub initial_ray_generation_time: f64,
|
||||||
pub ray_generation_time: f64,
|
pub ray_generation_time: f64,
|
||||||
pub sample_writing_time: f64,
|
pub sample_writing_time: f64,
|
||||||
|
@ -51,6 +52,7 @@ impl RenderStats {
|
||||||
RenderStats {
|
RenderStats {
|
||||||
trace_time: 0.0,
|
trace_time: 0.0,
|
||||||
accel_traversal_time: 0.0,
|
accel_traversal_time: 0.0,
|
||||||
|
accel_node_visits: 0,
|
||||||
initial_ray_generation_time: 0.0,
|
initial_ray_generation_time: 0.0,
|
||||||
ray_generation_time: 0.0,
|
ray_generation_time: 0.0,
|
||||||
sample_writing_time: 0.0,
|
sample_writing_time: 0.0,
|
||||||
|
@ -61,6 +63,7 @@ impl RenderStats {
|
||||||
fn collect(&mut self, other: RenderStats) {
|
fn collect(&mut self, other: RenderStats) {
|
||||||
self.trace_time += other.trace_time;
|
self.trace_time += other.trace_time;
|
||||||
self.accel_traversal_time += other.accel_traversal_time;
|
self.accel_traversal_time += other.accel_traversal_time;
|
||||||
|
self.accel_node_visits += other.accel_node_visits;
|
||||||
self.initial_ray_generation_time += other.initial_ray_generation_time;
|
self.initial_ray_generation_time += other.initial_ray_generation_time;
|
||||||
self.ray_generation_time += other.ray_generation_time;
|
self.ray_generation_time += other.ray_generation_time;
|
||||||
self.sample_writing_time += other.sample_writing_time;
|
self.sample_writing_time += other.sample_writing_time;
|
||||||
|
@ -341,6 +344,10 @@ impl<'a> Renderer<'a> {
|
||||||
stats.accel_traversal_time = att.get();
|
stats.accel_traversal_time = att.get();
|
||||||
att.set(0.0);
|
att.set(0.0);
|
||||||
});
|
});
|
||||||
|
ACCEL_NODE_RAY_TESTS.with(|anv| {
|
||||||
|
stats.accel_node_visits = anv.get();
|
||||||
|
anv.set(0);
|
||||||
|
});
|
||||||
|
|
||||||
// Collect stats
|
// Collect stats
|
||||||
collected_stats.write().unwrap().collect(stats);
|
collected_stats.write().unwrap().collect(stats);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user