diff --git a/luisa_compute/src/lang/poly.rs b/luisa_compute/src/lang/poly.rs index 8c4f063..a45611f 100644 --- a/luisa_compute/src/lang/poly.rs +++ b/luisa_compute/src/lang/poly.rs @@ -37,16 +37,14 @@ pub trait PolymorphicImpl: Value { } #[macro_export] macro_rules! impl_new_poly_array { - ($buffer:expr, $tag:expr, $key:expr)=>{ - { - let buffer = unsafe { $buffer.shallow_clone() }; - luisa_compute::PolyArray::new( - $tag, - $key, - Box::new(move |_, index| Box::new(buffer.var().read(index))), - ) - } - } + ($buffer:expr, $tag:expr, $key:expr) => {{ + let buffer = unsafe { $buffer.shallow_clone() }; + luisa_compute::PolyArray::new( + $tag, + $key, + Box::new(move |_, index| Box::new(buffer.var().read(index))), + ) + }}; } #[macro_export] macro_rules! impl_polymorphic { @@ -163,17 +161,11 @@ impl PolymorphicBui let r = &mut array[index]; r as &mut dyn Any }), - build: Box::new( - move |array: &dyn Any, device: Device| -> PolyArray { - let array = array.downcast_ref::>().unwrap(); - let buffer = device.create_buffer_from_slice(&array); - PolymorphicImpl::::new_poly_array( - &buffer, - tag as i32, - key.clone(), - ) - }, - ), + build: Box::new(move |array: &dyn Any, device: Device| -> PolyArray { + let array = array.downcast_ref::>().unwrap(); + let buffer = device.create_buffer_from_slice(&array); + PolymorphicImpl::::new_poly_array(&buffer, tag as i32, key.clone()) + }), array: Box::new(Vec::::new()), }); tag @@ -222,7 +214,14 @@ pub struct Polymorphic { key_typeid_to_tag: HashMap<(DevirtualizationKey, TypeId), u32>, key_to_tag: HashMap>, } - +unsafe impl Send + for Polymorphic +{ +} +unsafe impl Sync + for Polymorphic +{ +} pub struct PolymorphicRef<'a, DevirtualizationKey, Trait: ?Sized + 'static> { parent: &'a Polymorphic, pub tag_index: Expr, diff --git a/luisa_compute/src/rtx.rs b/luisa_compute/src/rtx.rs index 0b4f6c5..02079c6 100644 --- a/luisa_compute/src/rtx.rs +++ b/luisa_compute/src/rtx.rs @@ -48,12 +48,15 @@ impl Drop for ProceduralPrimitiveHandle { self.device.inner.destroy_procedural_primitive(self.handle); } } +unsafe impl Send for ProceduralPrimitiveHandle {} +unsafe impl Sync for ProceduralPrimitiveHandle {} pub struct ProceduralPrimitive { pub(crate) handle: Arc, pub(crate) aabb_buffer: api::Buffer, pub(crate) aabb_buffer_offset: usize, pub(crate) aabb_buffer_count: usize, } + impl ProceduralPrimitive { pub fn native_handle(&self) -> *mut std::ffi::c_void { self.handle.native_handle diff --git a/luisa_compute/src/runtime.rs b/luisa_compute/src/runtime.rs index 8adb9f6..b267e0e 100644 --- a/luisa_compute/src/runtime.rs +++ b/luisa_compute/src/runtime.rs @@ -577,6 +577,9 @@ pub struct Stream { pub(crate) handle: Arc, } +unsafe impl Send for Stream {} +unsafe impl Sync for Stream {} + impl StreamHandle { #[inline] pub(crate) fn device(&self) -> Arc { diff --git a/luisa_compute_sys/LuisaCompute b/luisa_compute_sys/LuisaCompute index 40d9ffe..bbdc663 160000 --- a/luisa_compute_sys/LuisaCompute +++ b/luisa_compute_sys/LuisaCompute @@ -1 +1 @@ -Subproject commit 40d9ffeade76ca116004afe17748100cfc450ddf +Subproject commit bbdc66328c69cb23669d063c14b2727171fb9aea