From 6a0308aad332137c0b6f22152a439ca0f73914da Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Jan 2010 19:45:01 +0000 Subject: Raytrace: only print debug info when running with -d option. --- source/blender/render/intern/include/rayobject.h | 4 ++-- source/blender/render/intern/raytrace/rayobject_vbvh.cpp | 12 ++++++++---- source/blender/render/intern/raytrace/reorganize.h | 4 +++- source/blender/render/intern/raytrace/svbvh.h | 11 +++++++---- source/blender/render/intern/source/rayshade.c | 7 ++++++- 5 files changed, 26 insertions(+), 12 deletions(-) (limited to 'source/blender/render') diff --git a/source/blender/render/intern/include/rayobject.h b/source/blender/render/intern/include/rayobject.h index 5579f3896c1..309048d8efb 100644 --- a/source/blender/render/intern/include/rayobject.h +++ b/source/blender/render/intern/include/rayobject.h @@ -181,7 +181,7 @@ int RE_rayobjectcontrol_test_break(RayObjectControl *c); #include #define BENCH(a,name) \ - do { \ + { \ double _t1, _t2; \ struct timeval _tstart, _tend; \ clock_t _clock_init = clock(); \ @@ -191,7 +191,7 @@ int RE_rayobjectcontrol_test_break(RayObjectControl *c); _t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 ); \ _t2 = ( double ) _tend.tv_sec + ( double ) _tend.tv_usec/ ( 1000*1000 ); \ printf("BENCH:%s: %fs (real) %fs (cpu)\n", #name, _t2-_t1, (float)(clock()-_clock_init)/CLOCKS_PER_SEC);\ - } while(0) + } #else #define BENCH(a,name) (a) diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp index 4a2a56fa8ef..6185be324d6 100644 --- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp @@ -37,6 +37,7 @@ int tot_hints = 0; #include "RE_raytrace.h" #include "BLI_memarena.h" #include "MEM_guardedalloc.h" +#include "BKE_global.h" #include "BKE_utildefines.h" #include "BLI_math.h" @@ -145,10 +146,13 @@ void bfree(VBVHTree *tree) { if(tot_pushup + tot_pushdown + tot_hints + tot_moves) { - printf("tot pushups: %d\n", tot_pushup); - printf("tot pushdowns: %d\n", tot_pushdown); - printf("tot moves: %d\n", tot_moves); - printf("tot hints created: %d\n", tot_hints); + if(G.f & G_DEBUG) { + printf("tot pushups: %d\n", tot_pushup); + printf("tot pushdowns: %d\n", tot_pushdown); + printf("tot moves: %d\n", tot_moves); + printf("tot hints created: %d\n", tot_hints); + } + tot_pushup = 0; tot_pushdown = 0; tot_hints = 0; diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h index 7b14108760a..845f53605a8 100644 --- a/source/blender/render/intern/raytrace/reorganize.h +++ b/source/blender/render/intern/raytrace/reorganize.h @@ -32,6 +32,8 @@ #include #include +#include "BKE_global.h" + #ifdef _WIN32 #define INFINITY FLT_MAX // in mingw math.h: (1.0F/0.0F). This generates compile error, though. #endif @@ -515,7 +517,7 @@ struct VBVH_optimalPackSIMD if(num == 0) { num++; first = true; } calc_costs(node); - if(first) printf("expected cost = %f (%d)\n", node->cut_cost[0], node->best_cutsize ); + if((G.f & G_DEBUG) && first) printf("expected cost = %f (%d)\n", node->cut_cost[0], node->best_cutsize ); node->optimize(); } return node; diff --git a/source/blender/render/intern/raytrace/svbvh.h b/source/blender/render/intern/raytrace/svbvh.h index 80e6e2ea190..873f44d6d66 100644 --- a/source/blender/render/intern/raytrace/svbvh.h +++ b/source/blender/render/intern/raytrace/svbvh.h @@ -33,6 +33,7 @@ #include "bvh.h" #include "BLI_memarena.h" +#include "BKE_global.h" #include #include @@ -142,10 +143,12 @@ struct Reorganize_SVBVH ~Reorganize_SVBVH() { - printf("%f childs per node\n", childs_per_node / nodes); - printf("%d childs BB are useless\n", useless_bb); - for(int i=0; i<16; i++) - printf("%i childs per node: %d/%d = %f\n", i, nodes_with_childs[i], nodes, nodes_with_childs[i]/float(nodes)); + if(G.f & G_DEBUG) { + printf("%f childs per node\n", childs_per_node / nodes); + printf("%d childs BB are useless\n", useless_bb); + for(int i=0; i<16; i++) + printf("%i childs per node: %d/%d = %f\n", i, nodes_with_childs[i], nodes, nodes_with_childs[i]/float(nodes)); + } } SVBVHNode *create_node(int nchilds) diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 9fa23c73ec6..36284e7919d 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -435,7 +435,12 @@ void makeraytree(Render *re) if(re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE) re->r.raytrace_options &= ~( R_RAYTRACE_USE_INSTANCES | R_RAYTRACE_USE_LOCAL_COORDS); - BENCH(makeraytree_single(re), tree_build); + if(G.f & G_DEBUG) { + BENCH(makeraytree_single(re), tree_build); + } + else + makeraytree_single(re); + if(test_break(re)) { freeraytree(re); -- cgit v1.2.3