Fix T56612: crash in Cycles viewport render update, after recent changes.
BVH8 refitting code had a bug.
This commit is contained in:
@@ -460,26 +460,22 @@ void BVH8::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
|
|||||||
memcpy(&pack.leaf_nodes[idx], leaf_data, sizeof(float4)*BVH_ONODE_LEAF_SIZE);
|
memcpy(&pack.leaf_nodes[idx], leaf_data, sizeof(float4)*BVH_ONODE_LEAF_SIZE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int4 *data = &pack.nodes[idx];
|
float8 *data = (float8*)&pack.nodes[idx];
|
||||||
bool is_unaligned = (data[0].x & PATH_RAY_NODE_UNALIGNED) != 0;
|
bool is_unaligned = (__float_as_uint(data[0].a) & PATH_RAY_NODE_UNALIGNED) != 0;
|
||||||
int4 c;
|
|
||||||
if(is_unaligned) {
|
|
||||||
c = data[BVH_UNALIGNED_ONODE_SIZE-1];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c = data[BVH_ONODE_SIZE-1];
|
|
||||||
}
|
|
||||||
/* Refit inner node, set bbox from children. */
|
/* Refit inner node, set bbox from children. */
|
||||||
BoundBox child_bbox[8] = { BoundBox::empty, BoundBox::empty,
|
BoundBox child_bbox[8] = { BoundBox::empty, BoundBox::empty,
|
||||||
BoundBox::empty, BoundBox::empty,
|
BoundBox::empty, BoundBox::empty,
|
||||||
BoundBox::empty, BoundBox::empty,
|
BoundBox::empty, BoundBox::empty,
|
||||||
BoundBox::empty, BoundBox::empty };
|
BoundBox::empty, BoundBox::empty };
|
||||||
|
int child[8];
|
||||||
uint child_visibility[8] = { 0 };
|
uint child_visibility[8] = { 0 };
|
||||||
int num_nodes = 0;
|
int num_nodes = 0;
|
||||||
|
|
||||||
for(int i = 0; i < 8; ++i) {
|
for(int i = 0; i < 8; ++i) {
|
||||||
if(c[i] != 0) {
|
child[i] = __float_as_int(data[(is_unaligned) ? 13: 7][i]);
|
||||||
refit_node((c[i] < 0)? -c[i]-1: c[i], (c[i] < 0),
|
|
||||||
|
if(child[i] != 0) {
|
||||||
|
refit_node((child[i] < 0)? -child[i]-1: child[i], (child[i] < 0),
|
||||||
child_bbox[i], child_visibility[i]);
|
child_bbox[i], child_visibility[i]);
|
||||||
++num_nodes;
|
++num_nodes;
|
||||||
bbox.grow(child_bbox[i]);
|
bbox.grow(child_bbox[i]);
|
||||||
@@ -495,7 +491,7 @@ void BVH8::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
|
|||||||
pack_unaligned_node(idx,
|
pack_unaligned_node(idx,
|
||||||
aligned_space,
|
aligned_space,
|
||||||
child_bbox,
|
child_bbox,
|
||||||
&c[0],
|
child,
|
||||||
visibility,
|
visibility,
|
||||||
0.0f,
|
0.0f,
|
||||||
1.0f,
|
1.0f,
|
||||||
@@ -504,7 +500,7 @@ void BVH8::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
|
|||||||
else {
|
else {
|
||||||
pack_aligned_node(idx,
|
pack_aligned_node(idx,
|
||||||
child_bbox,
|
child_bbox,
|
||||||
&c[0],
|
child,
|
||||||
visibility,
|
visibility,
|
||||||
0.0f,
|
0.0f,
|
||||||
1.0f,
|
1.0f,
|
||||||
|
Reference in New Issue
Block a user