Reduced the size of a hot return value.
Gives a small performance boost.
This commit is contained in:
parent
aed0f2ede1
commit
2fddcae0fd
|
@ -125,9 +125,9 @@ impl<'a> BVH4<'a> {
|
|||
|
||||
if hit {
|
||||
hit_count += 1;
|
||||
([0, 1, 2, 3, 4, 5, 6, 7], children.len())
|
||||
([0, 1, 2, 3], children.len())
|
||||
} else {
|
||||
([0, 1, 2, 3, 4, 5, 6, 7], 0)
|
||||
([0; 4], 0)
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -201,9 +201,9 @@ impl<'a> BVH4<'a> {
|
|||
);
|
||||
if hit {
|
||||
hit_count += 1;
|
||||
([0, 1, 2, 3, 4, 5, 6, 7], object_count)
|
||||
([0, 1, 2, 3], object_count)
|
||||
} else {
|
||||
([0, 1, 2, 3, 4, 5, 6, 7], 0)
|
||||
([0; 4], 0)
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ impl<'a> BVH4<'a> {
|
|||
// Ray testing
|
||||
ray_stack.pop_do_next_task(children.len(), |ray_idx| {
|
||||
if rays.is_done(ray_idx) {
|
||||
([0, 1, 2, 3, 4, 5, 6, 7], 0)
|
||||
([0; 4], 0)
|
||||
} else {
|
||||
let hits = lerp_slice(bounds, rays.time(ray_idx))
|
||||
.intersect_ray(
|
||||
|
@ -145,7 +145,7 @@ impl<'a> BVH4<'a> {
|
|||
|
||||
if hits != 0 {
|
||||
all_hits |= hits;
|
||||
let mut lanes = [0u8; 8];
|
||||
let mut lanes = [0u8; 4];
|
||||
let mut lane_count = 0;
|
||||
for i in 0..children.len() {
|
||||
if (hits >> i) & 1 != 0 {
|
||||
|
@ -155,7 +155,7 @@ impl<'a> BVH4<'a> {
|
|||
}
|
||||
(lanes, lane_count)
|
||||
} else {
|
||||
([0, 1, 2, 3, 4, 5, 6, 7], 0)
|
||||
([0; 4], 0)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -333,7 +333,7 @@ impl<'a> Surface for RectangleLight<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
([0, 0, 0, 0, 0, 0, 0, 0], 0)
|
||||
([0; 4], 0)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ impl<'a> Surface for SphereLight<'a> {
|
|||
let discriminant = (b * b) - (4.0 * a * c);
|
||||
if discriminant < 0.0 {
|
||||
// Discriminant less than zero? No solution => no intersection.
|
||||
return ([0, 0, 0, 0, 0, 0, 0, 0], 0);
|
||||
return ([0; 4], 0);
|
||||
}
|
||||
let discriminant = discriminant.sqrt();
|
||||
|
||||
|
@ -268,7 +268,7 @@ impl<'a> Surface for SphereLight<'a> {
|
|||
// Check our intersection for validity against this ray's extents
|
||||
if t0 > rays.max_t(ray_idx) || t1 <= 0.0 {
|
||||
// Didn't hit because sphere is entirely outside of ray's extents
|
||||
return ([0, 0, 0, 0, 0, 0, 0, 0], 0);
|
||||
return ([0; 4], 0);
|
||||
}
|
||||
|
||||
let t = if t0 > 0.0 {
|
||||
|
@ -278,7 +278,7 @@ impl<'a> Surface for SphereLight<'a> {
|
|||
} else {
|
||||
// Didn't hit because ray is entirely within the sphere, and
|
||||
// therefore doesn't hit its surface.
|
||||
return ([0, 0, 0, 0, 0, 0, 0, 0], 0);
|
||||
return ([0; 4], 0);
|
||||
};
|
||||
|
||||
// We hit the sphere, so calculate intersection info.
|
||||
|
@ -335,7 +335,7 @@ impl<'a> Surface for SphereLight<'a> {
|
|||
rays.set_max_t(ray_idx, t);
|
||||
}
|
||||
|
||||
([0, 0, 0, 0, 0, 0, 0, 0], 0)
|
||||
([0; 4], 0)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ impl RayStack {
|
|||
/// of lanes (by index) to add the given ray index back into.
|
||||
pub fn pop_do_next_task<F>(&mut self, needed_lanes: usize, mut handle_ray: F)
|
||||
where
|
||||
F: FnMut(usize) -> ([u8; 8], usize),
|
||||
F: FnMut(usize) -> ([u8; 4], usize),
|
||||
{
|
||||
// Prepare lanes.
|
||||
self.ensure_lane_count(needed_lanes);
|
||||
|
|
|
@ -276,7 +276,7 @@ impl<'a> Surface for TriangleMesh<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
([0, 0, 0, 0, 0, 0, 0, 0], 0)
|
||||
([0; 4], 0)
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
|
@ -99,7 +99,7 @@ impl<'a> TracerInner<'a> {
|
|||
ray_stack.pop_do_next_task(2, |ray_idx| {
|
||||
let t = rays.time(ray_idx);
|
||||
rays.update_local(ray_idx, &lerp_slice(xforms, t));
|
||||
([0, 1, 2, 3, 4, 5, 6, 7], 2)
|
||||
([0, 1, 0, 0], 2)
|
||||
});
|
||||
ray_stack.push_lanes_to_tasks(&[0, 1]);
|
||||
}
|
||||
|
@ -132,13 +132,13 @@ impl<'a> TracerInner<'a> {
|
|||
ray_stack.pop_do_next_task(0, |ray_idx| {
|
||||
let t = rays.time(ray_idx);
|
||||
rays.update_local(ray_idx, &lerp_slice(xforms, t));
|
||||
([0, 1, 2, 3, 4, 5, 6, 7], 0)
|
||||
([0; 4], 0)
|
||||
});
|
||||
} else {
|
||||
let ident = Matrix4x4::new();
|
||||
ray_stack.pop_do_next_task(0, |ray_idx| {
|
||||
rays.update_local(ray_idx, &ident);
|
||||
([0, 1, 2, 3, 4, 5, 6, 7], 0)
|
||||
([0; 4], 0)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user