From 01103aa7813dc4100685675adfd08b1cdcb46607 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 15 Jan 2024 16:42:47 +0800 Subject: [PATCH] fix cuda rq --- src/base/geometry.cpp | 42 ++++++++++++++++++++++++------------------ src/compute | 2 +- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/base/geometry.cpp b/src/base/geometry.cpp index 883cae62..228b1298 100644 --- a/src/base/geometry.cpp +++ b/src/base/geometry.cpp @@ -245,15 +245,18 @@ Var Geometry::trace_closest(const Var &ray_in) const noexcept { return Var{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{rq_hit.inst, rq_hit.prim, rq_hit.bary}; + Callable impl = [this](Var 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{rq_hit.inst, rq_hit.prim, rq_hit.bary}; + }; + return impl(ray_in); } Var Geometry::trace_any(const Var &ray) const noexcept { @@ -261,15 +264,18 @@ Var Geometry::trace_any(const Var &ray) const noexcept { // 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) 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 Geometry::interaction(Expr inst_id, Expr prim_id, diff --git a/src/compute b/src/compute index 7107f16d..86cfb35c 160000 --- a/src/compute +++ b/src/compute @@ -1 +1 @@ -Subproject commit 7107f16df137eb0d18a36f02526c092bfb9ff570 +Subproject commit 86cfb35c18bd02fc9ab38e1a757a660d76747c68