Skip to content

Commit

Permalink
fix cuda rq
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Leo-Smith committed Jan 15, 2024
1 parent bf5919b commit 01103aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
42 changes: 24 additions & 18 deletions src/base/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,31 +245,37 @@ Var<Hit> Geometry::trace_closest(const Var<Ray> &ray_in) const noexcept {
return Var<Hit>{hit.inst, hit.prim, hit.bary};
}
// use ray query
auto rq_hit =
_accel->traverse(ray_in, {})
.on_surface_candidate([&](compute::SurfaceCandidate &c) noexcept {
$if(!this->_alpha_skip(c.ray(), c.hit())) {
c.commit();
};
})
.trace();
return Var<Hit>{rq_hit.inst, rq_hit.prim, rq_hit.bary};
Callable impl = [this](Var<Ray> ray) noexcept {
auto rq_hit =
_accel->traverse(ray, {})
.on_surface_candidate([&](compute::SurfaceCandidate &c) noexcept {
$if(!this->_alpha_skip(c.ray(), c.hit())) {
c.commit();
};
})
.trace();
return Var<Hit>{rq_hit.inst, rq_hit.prim, rq_hit.bary};
};
return impl(ray_in);
}

Var<bool> Geometry::trace_any(const Var<Ray> &ray) const noexcept {
if (!_any_non_opaque) {
// happy path
return _accel->intersect_any(ray, {});
}
auto rq_hit =
_accel->traverse_any(ray, {})
.on_surface_candidate([&](compute::SurfaceCandidate &c) noexcept {
$if(!this->_alpha_skip(c.ray(), c.hit())) {
c.commit();
};
})
.trace();
return !rq_hit->miss();
Callable impl = [this](Var<Ray> ray) noexcept {
auto rq_hit =
_accel->traverse_any(ray, {})
.on_surface_candidate([&](compute::SurfaceCandidate &c) noexcept {
$if(!this->_alpha_skip(c.ray(), c.hit())) {
c.commit();
};
})
.trace();
return !rq_hit->miss();
};
return impl(ray);
}

luisa::shared_ptr<Interaction> Geometry::interaction(Expr<uint> inst_id, Expr<uint> prim_id,
Expand Down

0 comments on commit 01103aa

Please sign in to comment.