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.
This commit is contained in:
Sergey Sharybin 2015-01-30 19:52:38 +05:00
parent d632ef7c66
commit cb2007906f
3 changed files with 2 additions and 3 deletions

@ -456,7 +456,7 @@ void BVH::pack_instances(size_t nodes_size)
size_t nsize_bbox = (use_qbvh)? 6: 3; size_t nsize_bbox = (use_qbvh)? 6: 3;
int4 *bvh_nodes = &bvh->pack.nodes[0]; int4 *bvh_nodes = &bvh->pack.nodes[0];
size_t bvh_nodes_size = bvh->pack.nodes.size(); 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++) { 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)); memcpy(pack_nodes + pack_nodes_offset, bvh_nodes + i, nsize_bbox*sizeof(int4));

@ -63,7 +63,7 @@ struct PackedBVH {
array<int> prim_object; array<int> prim_object;
/* quick array to lookup if a node is a leaf, not used for traversal, only /* quick array to lookup if a node is a leaf, not used for traversal, only
* for instance BVH merging */ * for instance BVH merging */
array<int> is_leaf; array<bool> is_leaf;
/* index of the root node. */ /* index of the root node. */
int root_index; int root_index;

@ -1124,7 +1124,6 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
} }
pool.wait_work(); pool.wait_work();
foreach(Shader *shader, scene->shaders) foreach(Shader *shader, scene->shaders)
shader->need_update_attributes = false; shader->need_update_attributes = false;