diff --git a/luisa_compute/src/lang/soa.rs b/luisa_compute/src/lang/soa.rs index cee5ed1..be9910f 100644 --- a/luisa_compute/src/lang/soa.rs +++ b/luisa_compute/src/lang/soa.rs @@ -5,6 +5,36 @@ use crate::prelude::*; /** A buffer with SOA layout. */ pub struct SoaBuffer { - inner: ByteBuffer, + storage: ByteBuffer, + view: SoaBufferView<'static, T>, _marker: std::marker::PhantomData, } + +pub struct SoaBufferView<'a, T: Value> { + inner: ByteBufferView<'a>, + _marker: std::marker::PhantomData, +} + +fn compute_number_of_32bits_buffers(ty: &Type) -> usize { + match ty { + Type::Void => unreachable!(), + Type::UserData => unreachable!(), + Type::Primitive(_) => todo!(), + Type::Vector(_) => todo!(), + Type::Matrix(_) => todo!(), + Type::Struct(_) => todo!(), + Type::Array(_) => todo!(), + Type::Opaque(_) => todo!(), + } +} + +// impl IndexRead for SoaBuffer +// where +// T: Value, +// { +// type Element = T; +// fn read(&self, i: I) -> Expr { +// let i = i.to_u64(); +// todo!() +// } +// } diff --git a/luisa_compute/src/runtime.rs b/luisa_compute/src/runtime.rs index 1006b52..c8f1491 100644 --- a/luisa_compute/src/runtime.rs +++ b/luisa_compute/src/runtime.rs @@ -677,10 +677,10 @@ impl Drop for StreamHandle { /// To prevent a scope from synchronizing on drop, use [`Scope::detach`].Note this is only /// available for `Scope<'static>` as certain commands such as `copy_to_async<'a>` requires /// synchronization. -/// +/// /// **WARNING**: attempting to circumvent `drop` on `Scope<'a>, 'a != 'static` can result in /// undefined behavior. -/// +/// pub struct Scope<'a> { handle: Arc, marker: PhantomData<&'a ()>, @@ -1310,6 +1310,13 @@ pub struct RawKernelDef { pub(crate) resource_tracker: ResourceTracker, } +impl RawKernelDef { + #[doc(hidden)] + pub fn kernel_module(&self) -> &KernelModule { + self.module.as_ref() + } +} + /// A kernel definition /// See [`Kernel`] for more information pub struct KernelDef { @@ -1317,6 +1324,13 @@ pub struct KernelDef { pub(crate) _marker: PhantomData, } +impl KernelDef { + #[doc(hidden)] + pub fn raw_def(&self) -> &RawKernelDef { + &self.inner + } +} + /// An executable kernel /// Kernel creation can be done in multiple ways: /// - Seperate recording and compilation: