Skip to content

Commit

Permalink
update submod
Browse files Browse the repository at this point in the history
  • Loading branch information
shiinamiyuki committed Nov 17, 2023
1 parent 32c81d7 commit eb0c2f6
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 48 deletions.
8 changes: 4 additions & 4 deletions luisa_compute/examples/path_tracer_cutout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use winit::event_loop::EventLoop;
use luisa::prelude::*;
use luisa::rtx::{
offset_ray_origin, Accel, AccelBuildRequest, AccelOption, AccelVar, Index, Ray, RayComps,
RayQuery, TriangleCandidate,
RayQuery, SurfaceCandidate,
};
use luisa_compute as luisa;

Expand Down Expand Up @@ -359,7 +359,7 @@ fn main() {
let light_area = light_u.cross(light_v).length();
let light_normal = light_u.cross(light_v).normalize();

let filter = |c: &TriangleCandidate| {
let filter = |c: &SurfaceCandidate| {
let valid = true.var();
if c.inst == 5u32 {
*valid = (c.bary.y * 6.0f32).fract() < 0.6f32;
Expand All @@ -377,7 +377,7 @@ fn main() {
ray,
255,
RayQuery {
on_triangle_hit: |c: TriangleCandidate| {
on_triangle_hit: |c: SurfaceCandidate| {
if filter(&c) {
c.commit();
}
Expand Down Expand Up @@ -440,7 +440,7 @@ fn main() {
shadow_ray,
255,
RayQuery {
on_triangle_hit: |c: TriangleCandidate| {
on_triangle_hit: |c: SurfaceCandidate| {
if_!(filter(&c), {
c.commit();
});
Expand Down
4 changes: 2 additions & 2 deletions luisa_compute/examples/ray_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use luisa::lang::types::vector::alias::*;
use luisa::lang::types::vector::*;
use luisa::prelude::*;
use luisa::rtx::{
Aabb, AccelBuildRequest, AccelOption, ProceduralCandidate, Ray, RayQuery, TriangleCandidate,
Aabb, AccelBuildRequest, AccelOption, ProceduralCandidate, Ray, RayQuery, SurfaceCandidate,
};
use luisa_compute as luisa;
use winit::event::{Event as WinitEvent, WindowEvent};
Expand Down Expand Up @@ -140,7 +140,7 @@ fn main() {
ray,
255,
RayQuery {
on_triangle_hit: |candidate: TriangleCandidate| {
on_triangle_hit: |candidate: SurfaceCandidate| {
let bary = candidate.bary;
let uvw = Float3::expr(1.0 - bary.x - bary.y, bary.x, bary.y);
let t = candidate.committed_ray_t;
Expand Down
11 changes: 11 additions & 0 deletions luisa_compute/src/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::internal_prelude::*;

use bumpalo::Bump;
use indexmap::IndexMap;
use luisa_compute_ir::ir::CurveBasisSet;

use crate::runtime::{RawCallable, WeakDevice};

Expand Down Expand Up @@ -314,9 +315,13 @@ pub(crate) struct FnRecorder {
pub(crate) const_builder: IrBuilder,
pub(crate) index_const_pool: IndexMap<i32, NodeRef>,
pub(crate) rt: ResourceTracker,
pub(crate) curve_bases: CurveBasisSet,
}
pub(crate) type FnRecorderPtr = Rc<RefCell<FnRecorder>>;
impl FnRecorder {
pub(crate) fn add_required_curve_basis(&mut self, basis: CurveBasisSet) {
self.curve_bases.merge(basis);
}
pub(crate) fn make_index_const(&mut self, idx: i32) -> NodeRef {
if let Some(node) = self.index_const_pool.get(&idx) {
return *node;
Expand Down Expand Up @@ -412,6 +417,7 @@ impl FnRecorder {
.map(|p| p.borrow().inaccessible.clone())
.unwrap_or_else(|| Rc::new(RefCell::new(HashSet::new()))),
scopes: vec![],
curve_bases: CurveBasisSet::empty(),
captured_resources: IndexMap::new(),
cpu_custom_ops: IndexMap::new(),
callables: IndexMap::new(),
Expand Down Expand Up @@ -561,6 +567,7 @@ fn process_potential_capture(node: SafeNodeRef) -> SafeNodeRef {
if node.node.is_user_data() {
return node;
}

if r.inaccessible.borrow().contains(&node.node) {
panic!(
r#"Detected using node outside of its scope. It is possible that you use `RefCell` or `Cell` to store an `Expr<T>` or `Var<T>`
Expand All @@ -573,6 +580,10 @@ Please define a `Var<T>` in the parent scope and assign to it instead!"#
if ptr == node.recorder {
return node;
}
let ty = node.node.type_();
if ty.is_opaque("LC_RayQueryAny") || ty.is_opaque("LC_RayQueryAll") {
panic!("RayQuery cannot be captured!");
}
r.map_captured_vars(node)
})
}
Expand Down
Loading

0 comments on commit eb0c2f6

Please sign in to comment.