[Bf-blender-cvs] [cb20079] master: Cycles: Use bool for is_lead array

Sergey Sharybin noreply at git.blender.org
Fri Jan 30 21:51:03 CET 2015


Commit: cb2007906f902e4daeaf773833ef61da4020ea89
Author: Sergey Sharybin
Date:   Fri Jan 30 19:52:38 2015 +0500
Branches: master
https://developer.blender.org/rBcb2007906f902e4daeaf773833ef61da4020ea89

Cycles: Use bool for is_lead array

This way we save 3 bytes per BVH node while building BVH, which overall
gives 100Mb memory save when preparing Frank for render.

It's not really much comparing to overall memory usage (which is 11Gb
during scene preparation here) but still doesn't harm to have solved.

===================================================================

M	intern/cycles/bvh/bvh.cpp
M	intern/cycles/bvh/bvh.h
M	intern/cycles/render/mesh.cpp

===================================================================

diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index 376a7f8..5877550 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -456,7 +456,7 @@ void BVH::pack_instances(size_t nodes_size)
 			size_t nsize_bbox = (use_qbvh)? 6: 3;
 			int4 *bvh_nodes = &bvh->pack.nodes[0];
 			size_t bvh_nodes_size = bvh->pack.nodes.size(); 
-			int *bvh_is_leaf = (bvh->pack.is_leaf.size() != 0) ? &bvh->pack.is_leaf[0] : NULL;
+			bool *bvh_is_leaf = (bvh->pack.is_leaf.size() != 0) ? &bvh->pack.is_leaf[0] : NULL;
 
 			for(size_t i = 0, j = 0; i < bvh_nodes_size; i+=nsize, j++) {
 				memcpy(pack_nodes + pack_nodes_offset, bvh_nodes + i, nsize_bbox*sizeof(int4));
diff --git a/intern/cycles/bvh/bvh.h b/intern/cycles/bvh/bvh.h
index a4a1270..d0b0ebe 100644
--- a/intern/cycles/bvh/bvh.h
+++ b/intern/cycles/bvh/bvh.h
@@ -63,7 +63,7 @@ struct PackedBVH {
 	array<int> prim_object;
 	/* quick array to lookup if a node is a leaf, not used for traversal, only
 	 * for instance BVH merging  */
-	array<int> is_leaf;
+	array<bool> is_leaf;
 
 	/* index of the root node. */
 	int root_index;
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 9aa0cbc..24d36a1 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -1124,7 +1124,6 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
 	}
 
 	pool.wait_work();
-	
 	foreach(Shader *shader, scene->shaders)
 		shader->need_update_attributes = false;




More information about the Bf-blender-cvs mailing list