clray

diff src/rt.cc @ 55:df239a52a091

extensive render stats for the CPU raytracer
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 11 Sep 2010 03:00:21 +0100
parents 6a30f27fa1e6
children 3d13924b22e6
line diff
     1.1 --- a/src/rt.cc	Fri Sep 10 16:47:00 2010 +0100
     1.2 +++ b/src/rt.cc	Sat Sep 11 03:00:21 2010 +0100
     1.3 @@ -35,6 +35,7 @@
     1.4  
     1.5  
     1.6  static RendInfo rinf;
     1.7 +static RenderStats rstat;
     1.8  static int saved_iter_val;
     1.9  
    1.10  static long timing_sample_sum;
    1.11 @@ -211,6 +212,31 @@
    1.12  	return &rinf;
    1.13  }
    1.14  
    1.15 +const RenderStats *get_render_stats()
    1.16 +{
    1.17 +	return &rstat;
    1.18 +}
    1.19 +
    1.20 +void print_render_stats(FILE *fp)
    1.21 +{
    1.22 +	fprintf(fp, "-- render stats --\n");
    1.23 +	fprintf(fp, "> timing\n");
    1.24 +	fprintf(fp, "   render time (msec): %lu\n", rstat.render_time);
    1.25 +	fprintf(fp, "   tex update time (msec): %lu\n", rstat.tex_update_time);
    1.26 +	fprintf(fp, "> counters\n");
    1.27 +	fprintf(fp, "   AABB tests: %d\n", rstat.aabb_tests);
    1.28 +	fprintf(fp, "   AABB tests per ray (min/max/avg): %d/%d/%f\n",
    1.29 +			rstat.min_aabb_tests, rstat.max_aabb_tests, rstat.avg_aabb_tests);
    1.30 +	fprintf(fp, "   triangle tests: %d\n", rstat.triangle_tests);
    1.31 +	fprintf(fp, "   triangle tests per ray (min/max/avg): %d/%d/%f\n",
    1.32 +			rstat.min_triangle_tests, rstat.max_triangle_tests, rstat.avg_triangle_tests);
    1.33 +	fprintf(fp, "   rays cast: %dp %dr %ds (sum: %d)\n", rstat.prim_rays,
    1.34 +			rstat.refl_rays, rstat.shadow_rays, rstat.rays_cast);
    1.35 +	fprintf(fp, "   rays per second: %d\n", rstat.rays_per_sec);
    1.36 +	fprintf(fp, "   BRDF evaluations: %d\n", rstat.brdf_evals);
    1.37 +	fputc('\n', fp);
    1.38 +}
    1.39 +
    1.40  void set_render_option(int opt, bool val)
    1.41  {
    1.42  	switch(opt) {