Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-09-08 15:32:05 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-09-08 16:03:55 +0300
commit27e2317513afd0459120eaef7101ab3c1e025ea0 (patch)
tree95486ac6766399517df86cef99ba855217dd6107 /intern
parent3598a3d1d532bb74b6747d14447bb68fd7d6f4cf (diff)
Cycles: Add asserts to BVH node packing
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/bvh/bvh.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index bf301eb4ae6..5221aa506cc 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -425,6 +425,7 @@ RegularBVH::RegularBVH(const BVHParams& params_, const vector<Object*>& objects_
void RegularBVH::pack_leaf(const BVHStackEntry& e,
const LeafNode *leaf)
{
+ assert(e.idx + BVH_NODE_LEAF_SIZE <= pack.leaf_nodes.size());
float4 data[BVH_NODE_LEAF_SIZE];
memset(data, 0, sizeof(data));
if(leaf->num_triangles() == 1 && pack.prim_index[leaf->m_lo] == -1) {
@@ -472,8 +473,11 @@ void RegularBVH::pack_aligned_node(int idx,
int c0, int c1,
uint visibility0, uint visibility1)
{
- int4 data[BVH_NODE_SIZE] =
- {
+ assert(idx + BVH_NODE_SIZE <= pack.nodes.size());
+ assert(c0 < 0 || c0 < pack.nodes.size());
+ assert(c1 < 0 || c1 < pack.nodes.size());
+
+ int4 data[BVH_NODE_SIZE] = {
make_int4(visibility0 & ~PATH_RAY_NODE_UNALIGNED,
visibility1 & ~PATH_RAY_NODE_UNALIGNED,
c0, c1),
@@ -515,6 +519,10 @@ void RegularBVH::pack_unaligned_node(int idx,
int c0, int c1,
uint visibility0, uint visibility1)
{
+ assert(idx + BVH_UNALIGNED_NODE_SIZE <= pack.nodes.size());
+ assert(c0 < 0 || c0 < pack.nodes.size());
+ assert(c1 < 0 || c1 < pack.nodes.size());
+
float4 data[BVH_UNALIGNED_NODE_SIZE];
Transform space0 = BVHUnaligned::compute_node_transform(bounds0,
aligned_space0);
@@ -624,6 +632,7 @@ void RegularBVH::refit_nodes()
void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
{
if(leaf) {
+ assert(idx + BVH_NODE_LEAF_SIZE <= pack.leaf_nodes.size());
int4 *data = &pack.leaf_nodes[idx];
int c0 = data[0].x;
int c1 = data[0].y;
@@ -701,6 +710,7 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility
memcpy(&pack.leaf_nodes[idx], leaf_data, sizeof(float4)*BVH_NODE_LEAF_SIZE);
}
else {
+ assert(idx + BVH_NODE_SIZE <= pack.nodes.size());
int4 *data = &pack.nodes[idx];
int c0 = data[0].z;
int c1 = data[0].w;