[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22440] branches/soc-2009-jaguarandi/ source/blender/render/intern/raytrace/svbvh.h: Addition of some fake nodes to use SIMD even when theres only 3 nodes
Andre Susano Pinto
andresusanopinto at gmail.com
Thu Aug 13 22:35:53 CEST 2009
Revision: 22440
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22440
Author: jaguarandi
Date: 2009-08-13 22:35:53 +0200 (Thu, 13 Aug 2009)
Log Message:
-----------
Addition of some fake nodes to use SIMD even when theres only 3 nodes
Modified Paths:
--------------
branches/soc-2009-jaguarandi/source/blender/render/intern/raytrace/svbvh.h
Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/raytrace/svbvh.h
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/raytrace/svbvh.h 2009-08-13 20:16:17 UTC (rev 22439)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/raytrace/svbvh.h 2009-08-13 20:35:53 UTC (rev 22440)
@@ -147,6 +147,7 @@
float childs_per_node;
int nodes_with_childs[16];
+ int useless_bb;
int nodes;
Reorganize_SVBVH(Tree *t)
@@ -154,6 +155,7 @@
tree = t;
nodes = 0;
childs_per_node = 0;
+ useless_bb = 0;
for(int i=0; i<16; i++)
nodes_with_childs[i] = 0;
@@ -161,7 +163,8 @@
~Reorganize_SVBVH()
{
- printf("%f childs per node\n", childs_per_node / nodes);
+ 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));
}
@@ -176,7 +179,7 @@
return node;
}
- void copy_bb(float *bb, float *old_bb)
+ void copy_bb(float *bb, const float *old_bb)
{
std::copy( old_bb, old_bb+6, bb );
}
@@ -224,6 +227,12 @@
}
}
+ /* amt must be power of two */
+ inline int padup(int num, int amt)
+ {
+ return ((num+(amt-1))&~(amt-1));
+ }
+
SVBVHNode *transform(OldNode *old)
{
if(is_leaf(old))
@@ -232,13 +241,26 @@
return (SVBVHNode*)old->child;
int nchilds = count_childs(old);
- SVBVHNode *node = create_node(nchilds);
+ int alloc_childs = nchilds;
+ if(nchilds % 4 > 2)
+ alloc_childs = padup(nchilds, 4);
+
+ SVBVHNode *node = create_node(alloc_childs);
childs_per_node += nchilds;
nodes++;
if(nchilds < 16)
nodes_with_childs[nchilds]++;
+ useless_bb += alloc_childs-nchilds;
+ while(alloc_childs > nchilds)
+ {
+ const static float def_bb[6] = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MIN, FLT_MIN, FLT_MIN };
+ alloc_childs--;
+ node->child[alloc_childs] = 0;
+ copy_bb(node->child_bb+alloc_childs*6, def_bb);
+ }
+
int i=nchilds;
for(OldNode *o_child = old->child; o_child; o_child = o_child->sibling)
{
@@ -258,6 +280,7 @@
}
}
assert( i == 0 );
+
if(SVBVH_SIMD)
prepare_for_simd(node);
More information about the Bf-blender-cvs
mailing list